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

时间:2016-05-10 20:06:41

标签: grails grails-plugin

我正在尝试在我的应用程序中加载插件的以下自定义存储库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存储库?

1 个答案:

答案 0 :(得分:0)

这是我的解决方案。我基本上重写了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