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

fix*_*xer 5 artifactory gradle

我正在尝试使用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
}
Run Code Online (Sandbox Code Playgroud)

它给了我

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

它在执行阶段充当魅力

task testCustomResolve << {
  logger.quiet configurations.getByName('compile').singleFile.absolutePath
}
Run Code Online (Sandbox Code Playgroud)

或者当我使用mavenCentral()时

repositories {
  mavenCentral()
}
Run Code Online (Sandbox Code Playgroud)

Pau*_*sek 2

如果您不需要发布到 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()
}
Run Code Online (Sandbox Code Playgroud)

  • 将 IntelliJ IDEA 升级到 2019.2 后,“artifactory {}”语法停止工作,可能是由于新引入的错误。但是`maven {}`语法仍然有效,所以我迁移了我的build.gradle以使用maven语法。 (2认同)