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

Gradle ignores private Nexus repository when searching for dependencies

我正在尝试从私有 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

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

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

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

allProjects {

    . . . . . . . . . . 

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

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

希望对遇到类似问题的人有所帮助:)

我的更新信息和解决方案在 settings.gradle

dependencyResolutionManagement 中还有另一个存储库块。