将依赖项解析限制为自定义存储库

Limiting dependency resolution to custom repository

我有以下自定义存储库 URL 用于我要在我的应用程序中加载的插件:

https://server.com/artifactory/plugins-release-local/abc/pluginXYZ/r181/pluginXYZ-r181.jar

在我的 build.gradle 文件中:

...
repositories {
    mavenLocal()
    maven { url 'https://repo.grails.org/grails/core' }
    //custom Artifactory repository
    maven { url 'https://server.com/artifactory/plugins-release-local' }
}
...
dependencies {
    compile "abc:pluginXYZ:r181"
}

接下来,尝试编译:

me@workstation ~/my_app
$ grails compile
[buildinfo] Not using buildInfo properties file for this build.

BUILD SUCCESSFUL

Total time: 3.906 secs
Error |
Could not resolve all dependencies for configuration ':testRuntime'. Type 'gradle dependencies' for more information

接下来,尝试诊断依赖性问题:

me@workstation ~/my_app
$ ./gradlew dependencies --info | grep missing
Resource missing. [HTTP HEAD: https://repo.grails.org/grails/core/abc/pluginXYZ/r181/wetkit-r181.pom]
Resource missing. [HTTP HEAD: https://repo.grails.org/grails/core/abc/pluginXYZ/r181/wetkit-r181.jar]

在这种情况下,pluginXYX 永远不会在 repo.grails.org 上找到。如何将分辨率限制为我的自定义 Artifactory 存储库?

这是我的解决方案。我基本上重新设计了 Maven 闭包并提供了一个 artifactUrls 属性。

...
repositories {
    mavenLocal()
    maven {
        url "https://repo.grails.org/grails/core"
        artifactUrls "https://server.com/artifactory/plugins-release-local"
    }
}
...
dependencies {
    ...
    compile "abc:pluginXYZ:r181"
}
...

另外:Example 23.30. Adding additional Maven repositories for JAR files