Gradle artifactory插件无法解析配置阶段的依赖性 [英] Gradle artifactory plugin cannot resolve dependency on configuration phase
问题描述
apply plugin:'java'
apply plugin:'com.jfrog.artifactory'
artifactory {
contextUrl =$ {artifactory_contextUrl}
...
解析{
repository {
repoKey ='repo'
username =$ {artifactory_user}
password =$ {artifactory_password}
maven = true
}
}
}
依赖关系{
编译'commons-lang:commons-lang:+'
}
任务testCustomResolve {
logger.quiet configurations.getByName('compile')。singleFile.absolutePath
}
它给了我
无法解析配置':compile'的所有依赖关系。
无法解析外部依赖项commons-lang:commons-lang:+因为没有定义存储库。
它可以作为魅力在执行阶段
任务testCustomResolve<< {
logger.quiet configurations.getByName('compile')。singleFile.absolutePath
}
或者当我使用mavenCentral()时b
存储库{
mavenCentral()
}
如果您不需要发布到Artifactory,我注意到,如果不使用 artifactory {}
语法,它会更好。请尝试使用:
插件{
idcom.jfrog.artifactoryversion4.4.10
$ b存储库{
mavenLocal()
maven {
url$ {artifactory_contextUrl} / $ {artifactory_repo}
credentials {
username =$ {artifactory_user}
password =$ {artifactory_password}
}
}
mavenCentral()
}
I am trying to resolve dependency in configuration phase with artifactory gradle plugin.
apply plugin: 'java'
apply plugin: 'com.jfrog.artifactory'
artifactory {
contextUrl = "${artifactory_contextUrl}"
...
resolve {
repository {
repoKey = 'repo'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
dependencies {
compile 'commons-lang:commons-lang:+'
}
task testCustomResolve {
logger.quiet configurations.getByName('compile').singleFile.absolutePath
}
And it gives me
Could not resolve all dependencies for configuration ':compile'. Cannot resolve external dependency commons-lang:commons-lang:+ because no repositories are defined.
It works as a charm in execution phase
task testCustomResolve << {
logger.quiet configurations.getByName('compile').singleFile.absolutePath
}
or when I use mavenCentral()
repositories {
mavenCentral()
}
In case you don't need to publish to Artifactory, I noticed that it works better if you don't use the artifactory {}
syntax. Instead, try using:
plugins {
id "com.jfrog.artifactory" version "4.4.10"
}
repositories {
mavenLocal()
maven {
url "${artifactory_contextUrl}/${artifactory_repo}"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
mavenCentral()
}
这篇关于Gradle artifactory插件无法解析配置阶段的依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!