1

如何在我的 gradle 构建中获得 com.google.auto:auto-common:1.0-SNAPSHOT (传递依赖)来解决?

构建.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'
}

结果:

$ 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

依赖树:(截断)

$ 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

我尝试为自动通用添加显式依赖项,但没有成功。

令我惊讶的是,搜索“com.google.auto:auto-common:1.0-SNAPSHOT repository”之类的东西很少。看起来 1.0-SNAPSHOT 根本不在 Maven Central 中。有趣的是,看起来 1.0-SNAPSHOTjboss 的存储库中,但我的 gradle 构建似乎没有找到它。

以前有人见过这样的东西吗?帮助?

4

1 回答 1

2

它将以下列方式工作 - 每个 maven url 应该在一个单独的maven{}块中指定 - 运行copyToLibs任务来验证:

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'
}

以您指定最后一个获胜的网址的方式(涵盖所有先前定义的)。

于 2015-02-25T09:48:19.100 回答