Gradle artifactory plugin cannot resolve dependency on configuration phase

偶尔善良 提交于 2019-12-09 12:53:57

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/27692607/gradle-artifactory-plugin-cannot-resolve-dependency-on-configuration-phase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!