1

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?

kd8azz
  • 613
  • 5
  • 21

1 Answers1

2

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).

Opal
  • 81,889
  • 28
  • 189
  • 210
  • Thank you, that's about the best answer I could have hoped for. I'll try it tonight and let you know. – kd8azz Feb 25 '15 at 12:41
  • Unfortunately, it seems there's no difference between my original build.gradle file and the one you proposed. I also tried it the way you suggested before your edit. All three have the same result. – kd8azz Feb 25 '15 at 23:36
  • SUCCESS! Turns out you are right. However, it appears that repositories are visited in order, and my mavenLocal() repo was messing it up. Thus, using your suggestion, and putting mavenLocal() at the end, fixed this issue. Now I have to sort out the repo order, but that's something I can handle. – kd8azz Feb 26 '15 at 04:30
  • If you could edit your answer to mention the order in which repos are visited, I'd appreciate it (for the next guy). – kd8azz Feb 26 '15 at 04:31