搜索依赖项时,Gradle会忽略私有的Nexus存储库

时间:2019-08-29 05:11:45

标签: maven gradle nexus

我正在尝试从私有Nexus存储库中提取一些内部依赖项。但是,当我构建项目时,gradle不会在私有存储库中搜索依赖关系,而是在Maven存储库中寻找依赖关系。

我做了一些调查,发现只有一个项目正在发生这种情况。在其他项目中确实会产生依赖关系。我仍然不知道为什么会这样。

这是我添加存储库的方式:

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven { url 'https://jitpack.io' }
    maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda' }
    maven { url 'https://repo.gradle.org/gradle/libs-releases' }

    maven {
        url 'http://private/repository/project'
        credentials {
            username = "user"
            password = "password"
        }
    }
}

依赖性:

implementation 'com.project:project-1'

这是gradle显示的内容:

* What went wrong:
Execution failed for task ':workflows:compileKotlin'.
> Could not resolve all files for configuration ':workflows:compileClasspath'.
   > Could not find project:0.1.
     Searched in the following locations:
       - file:/C:/Users/local/.m2/repository/com/project/directory/0.1-SNAPSHOT/project-1.pom
       - file:/C:/Users/local/.m2/repository/com/project/directory/0.1-SNAPSHOT/project-1.jar
       - https://jcenter.bintray.com/com/project/directory/0.1-SNAPSHOT/project-1.pom
       - https://jcenter.bintray.com/com/project/directory/0.1-SNAPSHOT/project-1.jar
       - https://repo.maven.apache.org/maven2/com/project/directory/0.1-SNAPSHOT/project-1.pom
       - https://repo.maven.apache.org/maven2/com/project/directory/0.1-SNAPSHOT/project-1.jar
       - https://software.r3.com/artifactory/corda/com/project/directory/0.1-SNAPSHOT/project-1.pom
       - https://software.r3.com/artifactory/corda/com/project/directory/0.1-SNAPSHOT/project-1.jar
       - https://jitpack.io/com/project/directory/0.1-SNAPSHOT/project-1.pom
       - https://jitpack.io/com/project/directory/0.1-SNAPSHOT/project-1.jar

它不在私有存储库中搜索。

1 个答案:

答案 0 :(得分:1)

我正在处理的项目有两个gradle文件,repositories.gradlebuild.gradle

我正在将关联URL添加到repositories块中的repositories.gradle文件中。但是没有在URL中搜索依赖项。经过一番探索,我发现build.gradle文件也有一个存储库块:

allProjects {

    . . . . . . . . . . 

    repositories {
        . . . . . . . . . . 
        . . . . . . . . . . 
    }
}

这似乎覆盖了repositories.gradle文件中的存储库块。当我在此处添加nexus URL时,相关性已解决。

希望能帮助遇到类似问题的人:)