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
Related
I have the following build.gradle file for my project
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.guava:guava:23.6-jre';
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
manifest {
attributes 'Main-Class': 'Runner.ClientRunner'
}
}
However, when I run "gradle jar" and attempt to run the given jar, I get the error:
java.lang.NoClassDefFoundError: com/google/common/base/Preconditions
I can't seem to nail down what I've done wrong here, guava is included in the dependencies for gradle and the jar file appears to build fine otherwise (it only crashes when it gets to the first class that depends on guava). Any assistance appreciated.
If it helps I'm doing this from IntelliJ.
I solved my problem using the solution at https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571
My build.gradle now looks like
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
// configuration that holds jars to include in the jar
extraLibs
}
dependencies {
compile 'com.google.guava:guava:23.6-jre';
extraLibs group: 'com.google.guava', name: 'guava', version: '23.6-jre'
testCompile group: 'junit', name: 'junit', version: '4.12'
configurations.compile.extendsFrom(configurations.extraLibs)
}
jar {
manifest {
attributes 'Main-Class': 'Runner.ClientRunner'
}
from {
configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) }
}
}
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?
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 am doing a simple gradle build and I have deployed a particular artifact to my internal sonatype maven repo
My build.gradle file looks like this:
apply plugin: 'java'
sourceCompatibility = 1.8
version = '1.0'
repositories {
mavenCentral()
maven {url "http://maven.ebay.com/nexus/content/repositories/sre-snapshots/"}
}
dependencies {
compile group: "com.typesafe", name: "config", version: "1.3.0"
//compile project(':metrics')
compile group: 'com.ebay.telemetry', name: 'client-library', version: '0.1-SNAPSHOT'
compile group: "org.slf4j", name: "slf4j-jdk14", version: "1.7.12"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
I run this command on the command line: gradle build
I get this error:
> Could not find net.alchim31:metrics-influxdb:0.7.1-ebay-SNAPSHOT.
Searched in the following locations:
https://repo1.maven.org/maven2/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.pom
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar
However when I go to http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/
I see the following files :
metrics-influxdb-0.7.1-ebay-20150708.054830-3.pom
metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
So why is gradle looking for metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar when my repo has metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
It seems like you have declared another dependency besides the one you showed above. It should probably look something like this:
compile group: 'net.alchim31', name: 'metrics-influxdb', version: '0.7.1-ebay-SNAPSHOT'
If you find this dependency declaration, you might also find the source of the problem.
The second possibility is, that your maven-metadata.xml (at http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml) is messed up and points towards the nonexisting build 4.