gradle - 无法从maven repo中找到依赖项

时间:2013-07-04 15:25:00

标签: maven dependencies gradle

我在build.gradle之后遇到了构建错误。

apply plugin: 'java'
apply plugin: 'idea'

sourceCompatibility = 1.7
version = '1.0'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compile 'org.foo.group:my-artifact:0.0.1-final'
}

组,工件和版本都是正确的。我已经尝试了maven项目并且构建成功,但在gradle项目中它给了我以下错误:

:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':testRuntime'.
> Could not find org.foo.group:my-artifact:0.0.1-final.
  Required by:
      :my-gradle-project:1.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
tlin-deploy-tool
BUILD FAILED

1 个答案:

答案 0 :(得分:9)

我不确定出了什么问题,但请尝试检查maven和gradle是否使用相同的.m2存储库路径。应该用以下选项清楚地显示:

  • mvn -X
  • gradle --debug

对于gradle,当无法从MavenLocal找到jar时,将显示此特定消息;将显示.m2存储库路径:

  

23:44:08.152 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] org.foo.group无法访问资源#my-artifact; 0.0.1-final:res = MissingResource:/home/wisent/.m2/repository/org/foo/group/my-artifact/0.0.1-final/my-artifact-0.0.1-final.jar