I'm trying to debug my client-side code from IntelliJ.
Currently i build the project using this gradle plugin: https://github.com/steffenschaefer/gwt-gradle-plugin.
This is the gradle task:
task oneClickGwtSuperDev(type:de.richsource.gradle.plugins.gwt.GwtSuperDev){
group = "gwt"
workDir = file("$buildDir/gwt/work")
noPrecompile = true
bindAddress = '127.0.0.1'
launcherDir = file("$projectDir/devWar")
logLevel = 'INFO'
port = 9876
sourceLevel = '1.8'
}
This depends on another task that starts a tomcat container, therefore i'm not using the embedded server.
My goal is to stop using the gradle task for develpment, and create a GWT configuration in intellij, in order to debug from the IDE, and not the browser.
This is what i've tried:
The codeserver starts, but when module compiles i get a NoSuchMethodError.
Caused by: java.lang.NoSuchMethodError: com.google.gwt.core.ext.linker.GeneratedResource.setPrivate(Z)V
at org.atmosphere.gwt20.rebind.SerializerGenerator.generateIncrementally(SerializerGenerator.java:134)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:739)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:103)
My assumption is, when i build with the GWT configuration, the dependencies are messed up.
The working configuration (Gradle) has some excludes in the dependencies, and i think my problem is related to this.
providedCompile ('com.google.gwt:gwt-dev:' + mambu.versions.gwt) {
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'commons-collections', module: 'commons-collections'
exclude group: 'org.apache.commons', module: 'commons-lang3'
exclude group: 'commons-io', module: 'commons-io'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
providedCompile('com.google.gwt:gwt-user:' + mambu.versions.gwt) {
exclude group: 'javax.validation', module: 'validation-api'
}
Any ideas?
Related
I use gretty to easily run a dev server and webapp-runner for deployment to heroku.
The following is my gradle.build:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty:+'
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'org.akhikhl.gretty'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-webmvc:4.3.10.RELEASE'
compile 'org.springframework:spring-orm:4.3.10.RELEASE'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.0'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.10.Final'
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.1.1'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.1.Final'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
compile 'com.github.jsimone:webapp-runner:8.5.11.3'
}
gretty {
httpPort = 8080
servletContainer = 'jetty9'
contextPath = '/'
}
eclipse {
wtp {
component {
contextPath = '/'
}
}
}
///////// Tasks for deployment to heroku
task stage() {
dependsOn clean, war
}
war.mustRunAfter clean
task copyToLib(type: Copy) {
dependsOn war
into "$buildDir/server"
from(configurations.compile) {
include "webapp-runner*"
}
}
stage.dependsOn(copyToLib)
If I remove webapp-runner everything runs fine, but with it I get the following error when trying to start gretty:
java.lang.IllegalStateException: Duplicate fragment name: org_apache_jasper for jar
Not an expert but I figure its something to do with the fact that both gretty and webapp-runner download similar files and that's causing a clash?
Would really appreciate some info on this. How do I get past this? Is there a better way to have a dev server + be able to deploy to heroku? (maybe use webapp-runner for both?)
I recommend running locally the same way as Heroku runs your app, with these commands:
$ ./gradlew stage
$ heroku local web
If you want to use gretty for development, you'll need to exclude webapp-runner from your dev build (maybe with a stageDev task), and exclude gretty from your stage build.
I am trying to run Instrumental tests for my project. But they don't run on devices(emulators as well) that have version lower than 5 (API 21).
I have been trying to solve this problem, but still facing with it.
I get following exception.
02-15 10:46:08.965 1127-1143/? E/AndroidRuntime: FATAL EXCEPTION: Instr: android.support.test.runner.AndroidJUnitRunner
java.lang.ExceptionInInitializerError
at android.support.test.internal.runner.TestRequestBuilder.<init>(TestRequestBuilder.java:81)
at android.support.test.internal.runner.TestRequestBuilder.<init>(TestRequestBuilder.java:524)
at android.support.test.runner.AndroidJUnitRunner.createTestRequestBuilder(AndroidJUnitRunner.java:379)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:352)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:269)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
Caused by: java.lang.NoClassDefFoundError: org.junit.runner.manipulation.Filter$1
at org.junit.runner.manipulation.Filter.<clinit>(Filter.java:21)
at android.support.test.internal.runner.TestRequestBuilder.<init>(TestRequestBuilder.java:81)
at android.support.test.internal.runner.TestRequestBuilder.<init>(TestRequestBuilder.java:524)
at android.support.test.runner.AndroidJUnitRunner.createTestRequestBuilder(AndroidJUnitRunner.java:379)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:352)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:269)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
I have already tried all solutions for similar questions.
Here how my project structure looks.
And gradle dependencies for tests
/************* TEST STUFF ***************/
androidTestCompile 'junit:junit:4.12'
androidTestCompile fileTree(include: ['robotium-solo-5.5.2.jar'], dir: 'libs')
//mockito dependencies
androidTestCompile 'org.mockito:mockito-core:2.7.6'
androidTestCompile files('libs/dexmaker-mockito-1.0.jar')
androidTestCompile files('libs/dexmaker-1.0.jar')
// Set this dependency to build and run Espresso tests
androidTestCompile('com.android.support.test.espresso:espresso-core:+') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.5') {
exclude group: 'com.android.support', module: 'support-annotations'
}
// Set this dependency to use JUnit 4 rules
androidTestCompile('com.android.support.test:rules:+') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-intents:+') {
exclude group: 'com.android.support', module: 'support-annotations'
}
//MockWebServer - Version 2.2 of mockwebserver doesn't work because of an issue, so forcing v2.1 - https://github.com/square/okhttp/issues/1069
androidTestCompile('com.squareup.okhttp3:mockwebserver:+') {
exclude module: 'okhttp'
}
androidTestCompile "org.slf4j:slf4j-api:1.7.12"
//WireMock
androidTestCompile("com.github.tomakehurst:wiremock:2.5.0") {
//Using Android Version Instead
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
//Version conflict with our app's slf4j version
exclude group: 'org.slf4j', module: 'slf4j-api'
//Was getting a classpath conflict for org.objectweb.asm.AnnotationVisitor which is a part of 'net.minidev:asm'
exclude group: 'org.ow2.asm', module: 'asm'
//Was getting this warning, so decided to ignore this version included by WireMock.
//Warning:Dependency org.json:json:20090211 is ignored as it may be conflicting with the internal version provided by Android.
//In case of problem, please repackage with jarjar to change the class packages
exclude group: 'org.json', module: 'json'
}
androidTestCompile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
And BaseTestClass have the following structure
#RunWith(AndroidJUnit4.class)
public abstract class InstrumentalSuperTest {
private SystemAnimations mSystemAnimations;
#Rule
public IntentsTestRule rule = provideActivity();
#Rule
public WireMockRule wireMockRule = new WireMockRule(WireMockConfiguration.wireMockConfig().port(BuildConfig.PORT), false);
protected abstract IntentsTestRule provideActivity();
}
And this happens not only with my project, but with Wiremock examples as well, the same error.
Maybe I run test incorrectly, I just click on a test class and choose Run ... Test.
Please help to solve this problem, I have no idea what is wrong.
You may try newer version of wiremock. later than 2.0.8-beta.
for more about this have a look at this stackoverflow answer
I'm trying to exclude some modules from my build.gradle file but it(code1 and code2) still downloads the excluded files.
code 1:
compile (group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.7') {
exclude group: 'com.amazonaws', module: 'aws-java-sdk-machinelearning'
}
code 2:
compile (group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.7') {
exclude module: 'aws-java-sdk-machinelearning'
}
when I tried using the following code,
configurations {
compile.exclude module: 'aws-java-sdk-machinelearning'
}
it excludes the files but I don't want to use this method to exclude files
I second/confirm with #Opal that code1 works fine in Gradle 2.13.
What is likely happening is that you have some other (maybe non-aws) dependency, that may be transitively using aws-java-sdk which then brings in the machine-learning dependency. Which is why, it works fine when you do a global exclude, but not when you do a local exclude on just aws-java-sdk.
Try running gradlew dependencies --configuration=compile to get a tree of dependencies, including transitives, to check which dependency might be bringing in aws-java-sdk-machinelearning
In my build.gradle I have the following snipped:
dependencies {
compile project(':utils')
compile (project(':cache')) {
// excludings because of dropwizard conflicts
exclude group: 'org.glassfish.jersey.core'
exclude group: 'javax.ws.rs'
exclude group: 'com.codahale.metrics'
}
but in fact the artifacts are not excluded I still end up with different jersey and metrics in my classpath. Ony if I put this in my cache/build.gradle it will compile and run.
configurations {
all*.exclude group: 'com.codahale.metrics'
all*.exclude group: 'org.glassfish.jersey.core'
}
But then my cache project is broken because of missing dependencies which is not what I wanted.
I've had issues with this in the past, what worked was when I included module: explicitly along with the group. like so:
exclude group: 'commons-math3', module: 'commons-math3'
If you use configurations to exclude, you don't have to do it on all*, you can do it on just local project compile as :
compile.exclude group: 'commons-math3', module: 'commons-math3'
I have a simple build.gradle that pulls in a few java dependencies. On my mac, gradle keeps saying that its unable to resolve dependencies for any jar. This only started happening yesterday, rebooting doesn't solve this. I have tried running the project on linux and things work just as expected. Any idea whats up with my mac thats causing this?
Cause 2: java.lang.InternalError
[...]
at javax.xml.parsers.SecuritySupport$4.run(SecuritySupport.java:92)
at java.security.AccessController.doPrivileged(Native Method)
at javax.xml.parsers.SecuritySupport.getResourceAsStream(SecuritySupport.java:87)
at javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:288)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:255)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:121)
at org.apache.ivy.util.XMLHelper.getDocBuilder(XMLHelper.java:208)
at org.apache.ivy.util.XMLHelper.parseToDom(XMLHelper.java:193)
at org.apache.ivy.plugins.parser.m2.PomReader.<init>(PomReader.java:95)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorParser.parseDescriptor(GradlePomModuleDescriptorParser.java:91)
[...]
Caused by: java.util.zip.ZipException: error in opening zip file
When I run on linux, things are working fine.
Here is my build.gradle file:
buildscript {
repositories {
mavenCentral()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.7'
}
apply plugin: 'scala'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.10.3'
compile('com.twitter:finagle-core_2.10:6.9.0') {
exclude group: 'junit', module: 'junit'
exclude group: 'org.mockito', module: 'mockito-all'
exclude group: 'org.scala-tools.testing', module: 'specs_2.10'
exclude group: 'org.scalatest', module: 'scalatest_2.10'
}
compile('com.twitter:finagle-http_2.10:6.9.0') {
exclude group: 'junit', module: 'junit'
exclude group: 'org.mockito', module: 'mockito-all'
exclude group: 'org.scala-tools.testing', module: 'specs_2.10'
exclude group: 'org.scalatest', module: 'scalatest_2.10'
}
compile 'com.fasterxml.jackson.module:jackson-module-scala_2.10:2.3.0'
}
Using Java 7 and Gradle 1.7
Try dropping maven and/or gradle cache for the dependencies that make problems or just altogether:
rm -rf ~/.gradle/
rm -rf ~/.m2/repository/
Please note that the later may lead to significant network traffic and build times next time the build is run!
Turns out my java got corrupted; reinstalling java fixed the issue