Gradle artifactory插件无法解析对配置阶段的依赖性

时间:2014-12-29 16:38:49

标签: gradle artifactory

我正在尝试使用artifactory gradle插件解决配置阶段的依赖关系。

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
}

它给了我

  

无法解析配置的所有依赖关系':compile'。   无法解析外部依赖项commons-lang:commons-lang:+因为没有定义存储库。

它在执行阶段充当魅力

task testCustomResolve << {
  logger.quiet configurations.getByName('compile').singleFile.absolutePath
}

或当我使用mavenCentral()

repositories {
  mavenCentral()
}

1 个答案:

答案 0 :(得分:0)

如果您不需要发布到Artifactory,我注意到如果您不使用artifactory {}语法,效果会更好。相反,请尝试使用:

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()
}