Gradle dependency - com.google.auto:auto-common:1.0-SNAPSHOT - maven

How do I get com.google.auto:auto-common:1.0-SNAPSHOT (transitive dependency) to resolve, in my gradle build?
build.gradle:
apply plugin: 'java'
repositories {
maven {
mavenLocal()
mavenCentral()
url "http://snapshots.maven.codehaus.org/maven2"
url "http://oss.sonatype.org/content/groups/public"
url "http://nativelibs4java.sourceforge.net/maven"
url "http://repository.jboss.org/"
}
}
dependencies {
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
compile 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
compile 'com.google.guava:guava:18.0'
compile 'com.google.protobuf:protobuf-java:2.6.1'
compile 'com.nativelibs4java:javacl:1.0-SNAPSHOT'
compile 'org.jogamp.gluegen:gluegen-rt-main:2.0.2'
compile 'org.jogamp.jogl:jogl-all-main:2.0.2'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'com.google.truth:truth:0.25'
}
Results:
$ gradle build
:compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Artifact 'com.google.auto:auto-common:1.0-SNAPSHOT#jar' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Dependency Tree: (truncated)
$ gradle dependencies
compile - Classpath for compiling the main sources.
+--- com.google.dagger:dagger:2.0-SNAPSHOT
| \--- javax.inject:javax.inject:1
+--- com.google.dagger:dagger-compiler:2.0-SNAPSHOT
| +--- com.google.dagger:dagger:2.0-SNAPSHOT (*)
| +--- com.google.dagger:dagger-producers:2.0-SNAPSHOT
| | +--- com.google.dagger:dagger:2.0-SNAPSHOT (*)
| | \--- com.google.guava:guava:18.0
| +--- com.google.auto:auto-common:1.0-SNAPSHOT <-------auto-common--------
| | \--- com.google.guava:guava:18.0
| \--- com.google.guava:guava:18.0
+--- com.google.guava:guava:18.0
+--- com.google.protobuf:protobuf-java:2.6.1
+--- com.nativelibs4java:javacl:1.0-SNAPSHOT
| \--- com.nativelibs4java:javacl-core:1.0-SNAPSHOT
| +--- com.nativelibs4java:opencl4java:1.0-SNAPSHOT
| | \--- com.nativelibs4java:bridj:0.7-SNAPSHOT
| | \--- com.google.android.tools:dx:1.7
| \--- com.nativelibs4java:nativelibs4java-utils:1.6-SNAPSHOT
+--- org.jogamp.gluegen:gluegen-rt-main:2.0.2
| \--- org.jogamp.gluegen:gluegen-rt:2.0.2
\--- org.jogamp.jogl:jogl-all-main:2.0.2
\--- org.jogamp.jogl:jogl-all:2.0.2
I have tried adding an explicit dependency for auto-common, with no luck.
To my surprise, searching things like "com.google.auto:auto-common:1.0-SNAPSHOT repository" turns up very little. It looks like the 1.0-SNAPSHOT simply isn't in Maven Central. Interestingly enough, it looks like the 1.0-SNAPSHOT is in jboss's repository, but my gradle build doesn't seem to find it.
Anyone seen something like this before? Help?

It will work in the following way - every maven url should be specified in a separate maven{} block - run copyToLibs task to verify:
apply plugin: 'java'
repositories {
mavenLocal()
mavenCentral()
[
"http://snapshots.maven.codehaus.org/maven2",
"http://oss.sonatype.org/content/groups/public",
"http://nativelibs4java.sourceforge.net/maven",
"http://repository.jboss.org/"
].each { address ->
maven {
url address
}
}
}
dependencies {
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
compile 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
compile 'com.google.guava:guava:18.0'
compile 'com.google.protobuf:protobuf-java:2.6.1'
compile 'com.nativelibs4java:javacl:1.0-SNAPSHOT'
compile 'org.jogamp.gluegen:gluegen-rt-main:2.0.2'
compile 'org.jogamp.jogl:jogl-all-main:2.0.2'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'com.google.truth:truth:0.25'
}
task copyToLib(type: Copy) {
from configurations.runtime
into 'libs'
}
In the way You specified the urls the last one was winning (covering all previously defined).

Related

Enforce the highest version from among several conflicting transitive dependencies in gradle

I work on a large project with multiple services and libraries, mostly in grails, with gradle builder. I'm trying to update a library (say logback) for security reasons.
I already updated it in one of our libraries (say our-logger), like so:
#our-logger/build.gradle
...
dependencies {
...
compile 'ch.qos.logback:logback-classic:1.2.3'
...
}
when I update a service (say our-service) to use the new version of our-logger i get logback included from other libraries, and gradle chooses the lower version coming through cobertura and some other dependencies, instead of the higher version coming through our-logger.
#our-service/build.gradle
...
apply plugin: 'cobertura'
...
dependencies {
...
compile 'our-logger:9.99' # safe now with logback-1.2.3
...
}
~/our-service $ ./gradlew dependencies
...
cobertura
\--- net.sourceforge.cobertura:cobertura:2.1.1
+--- ch.qos.logback:logback-classic:1.0.13 -> 1.1.11
| \--- ch.qos.logback:logback-core:1.1.11
...
compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- org.grails:grails-dependencies:3.3.8
| +--- org.springframework.boot:spring-boot-starter-logging:1.4.2.RELEASE -> 1.5.15.RELEASE
| | +--- ch.qos.logback:logback-classic:1.1.11
| | | +--- ch.qos.logback:logback-core:1.1.11
...
+--- our-logger:9.99
| +--- ch.qos.logback:logback-classic:1.2.3 -> 1.1.11 (*)
How do I enforce logback-1.2.3 without explicitly declaring it in all services?
The gradle docs file this under Advanced Dependency Management. You should be able to satisfy your goal using excludes. There are other ways too Gradle Docs
compile(“some:other:dependency”) {
exclude group: 'ch.qos.logback', module: 'logback-classic'
}

spring boot gradle plugin change project dependencies version

I ran into a problem that puzzled me.
I use gradle build spring-boot project and i want package a runtime jar.
this is my dependencies :
buildscript {
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.5.RELEASE")
}
}
plugins {
id 'org.springframework.boot' version '1.5.5.RELEASE'
}
dependencies {
....
compile 'org.elasticsearch:elasticsearch:5.0.0'
compile 'org.elasticsearch.client:transport:5.0.0'
....
}
i run the cmd gradle dependencies :
+--- org.elasticsearch:elasticsearch:5.0.0 -> 2.4.5
| | +--- org.apache.lucene:lucene-core:5.5.4
| | +--- org.apache.lucene:lucene-backward-codecs:5.5.4
| | | \--- org.apache.lucene:lucene-core:5.5.4
| | +--- org.apache.lucene:lucene-analyzers-common:5.5.4
when i remove spring-boot plugin, Everything is normal.
i change spring-boot plugin version. some time There are some dependencies Will change the version.
please help me check it question, thx !

Gradle dependency hierarchy in script

My goal is to print the dependencies of a gradle build including there hierarchy. The idea is to graphically build a dependency graph. The information I need would be the same as when I type gradle dependencies.
How can I achive this? Where do I get the information from, when I create my own task?
Perhaps this is what you're looking for:
project.configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
println it.name // << the artifact name
println it.file // << the file reference
}
It comes from How to retrieve a list of actual dependencies (including transitive deps) - Old Forum - Gradle Forums
I'm just a gradle newbie, so perhaps there is depth to your question I don't see. Do you mean:
> gradle dependencies
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Compile classpath for source set 'main'.
\--- commons-collections:commons-collections:3.2
default - Configuration for default artifacts.
\--- commons-collections:commons-collections:3.2
runtime - Runtime classpath for source set 'main'.
\--- commons-collections:commons-collections:3.2
testCompile - Compile classpath for source set 'test'.
+--- commons-collections:commons-collections:3.2
\--- junit:junit:4.+ -> 4.12
\--- org.hamcrest:hamcrest-core:1.3
testRuntime - Runtime classpath for source set 'test'.
+--- commons-collections:commons-collections:3.2
\--- junit:junit:4.+ -> 4.12
\--- org.hamcrest:hamcrest-core:1.3
BUILD SUCCESSFUL
Total time: 4.47 secs
This was created from a build.gradle file with only these direct dependencies:
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}

Grails 2.2 to 2.3 - jersey jaxrs plugin dependencies could not be resolved

I'm migrating my project from grails 2.2 to 2.3 and everything work fine except jaxrs plugin
My BuildConfig.groovy looks like:
...
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
plugins {
compile ':jaxrs:0.8'
}
}
I got this error message:
| Error Resolve error obtaining dependencies: The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
| Error Resolve error obtaining dependencies: The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
| Error Resolve error obtaining dependencies: The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
| Error The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins)
| Run 'grails dependency-report' for further information.
When I run the report, I got:
+--- org.grails.plugins:jaxrs:0.8
| >>>> org.restlet.gae:org.restlet.ext.json:2.0.0
| >>>> org.restlet.gae:org.restlet:2.0.0
| \--- com.sun.jersey:jersey-core:1.14
| \--- javax.ws.rs:jsr311-api:1.1.1
| \--- com.sun.jersey:jersey-json:1.14
| >>>> org.restlet.gae:org.restlet.ext.servlet:2.0.0
| \--- com.sun.jersey.contribs:jersey-spring:1.14
| \--- org.springframework:spring-core:3.0.0.RC3
| \--- org.springframework:spring-asm:3.0.0.RC3
| \--- commons-logging:commons-logging:1.1.1
| \--- org.springframework:spring-beans:3.0.0.RC3
| \--- org.springframework:spring-context:3.0.0.RC3
| \--- org.springframework:spring-web:3.0.0.RC3
| \--- org.springframework:spring-aop:3.0.0.RC3
| \--- com.sun.jersey:jersey-server:1.14
| \--- com.sun.jersey:jersey-servlet:1.14
| \--- asm:asm:3.3
| \--- org.spockframework:spock-grails-support:0.7-groovy-2.0
| \--- org.grails.plugins:spock:0.7
How can I fix this ?
I found this post. There's a beta version being develop.
I've done what is suggested:
I added the mavenRepo
mavenRepo 'https://noams.artifactoryonline.com/noams/grails-jaxrs-plugin-snapshots'
And as I use the new Aether (Maven) resolver I configure the jaxrs plugin like this:
compile (':jaxrs:0.10-SNAPSHOT') {
excludes 'spring-core', 'spring-beans', 'spring-context', 'spring-web', 'spring-aop'
}
But org.restlet.ext.json:jar:2.1.4 was still missing so I also have to add this mavenRepo:
mavenRepo 'http://maven.restlet.org'
Application cleaned! Tests Passed!

Finding unwanted code dependencies on transitive dependencies

I want to find all my Java code dependencies on libraries that I have not included as top level dependencies in Gradle.
My first though as to how to accomplish this is to turn off all transitive dependencies in Gradle and see what compilation errors I get.
From my research the way to do this seems to be:
configurations.all { transitive = false }
Is there a better way, or does this do it?
I'm not sure I understand the question, but the command line "gradle dependencies" might help.
For example, consider this (from this modest project):
dependencies {
groovy 'org.codehaus.groovy:groovy-all:1.6.4'
groovy 'com.google.guava:guava-collections:r03'
releaseJars 'org.codehaus.groovy:groovy-all:1.6.4'
releaseJars 'com.google.guava:guava-collections:r03'
}
Using gradle dependencies gives output such as:
compile - Classpath for compiling the main sources.
+--- org.codehaus.groovy:groovy-all:1.6.4
| +--- junit:junit:3.8.2
| +--- org.apache.ant:ant:1.7.1
| | \--- org.apache.ant:ant-launcher:1.7.1
| +--- org.apache.ant:ant-launcher:1.7.1
| \--- jline:jline:0.9.94
| \--- junit:junit:3.8.1 -> 3.8.2
\--- com.google.guava:guava-collections:r03
+--- com.google.guava:guava-annotations:r03
\--- com.google.guava:guava-primitives:r03
....

Resources