gradle - 无法从Maven回购找到依赖关系 [英] gradle - not able to find dependencies from maven repo

查看:138
本文介绍了gradle - 无法从Maven回购找到依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  apply plugin:'java'
apply插件:'idea'
$ b sourceCompatibility = 1.7
version ='1.0'
$ b存储库{
mavenLocal()
mavenCentral()
}

依赖关系{
编译'org.foo.group:my-artifact:0.0.1-final'
}

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

 : jar最新日期
:汇编最新日期
:compileTestJava最新日期
:processTestResources最新日期
:testClasses最新日期
:测试

失败:生成失败,出现异常。

*出错:
无法解析配置':testRuntime'的所有依赖关系。
>无法找到org.foo.group:my-artifact:0.0.1-final。
要求:
:my-gradle-project:1.0

*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。
tlin-deploy-tool
BUILD FAILED


解决方案

我不确定出了什么问题,但试着检查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#我的神器不可达; 0.0.1决赛:RES = MissingResource:/home/wisent/.m2/repository/org/foo/group/my-artifact/ 0.0.1-final / my-artifact-0.0.1-final.jar



I'm having build error with following 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'
}

group, artifact and version are correct. I've tried it with a maven project and the build was successful, but in gradle project it gives me following error:

: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

解决方案

I'm not sure what went wrong, but try to check if maven and gradle are using the same .m2 repository path. It should be clearly displayed with these options:

  • mvn -X
  • gradle --debug

For gradle, this particular message will be shown when a jar can't be found from MavenLocal; the .m2 repository path will be shown:

23:44:08.152 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Resource not reachable for 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

这篇关于gradle - 无法从Maven回购找到依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆