Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle artifactory plugin cannot resolve dependency on configuration phase

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()
}
like image 676
fixxer Avatar asked Dec 29 '14 16:12

fixxer


1 Answers

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()
}
like image 75
Paul Podgorsek Avatar answered Oct 24 '22 22:10

Paul Podgorsek