Custom configuration - Generated POM does not include dependencies


(Pranav K Varshney) #1

This is my build file -

configurations {
     artifactory
     jsDep
}
  dependencies {
  jsDep group:'core.lib', name:'vendor', version:'1.0'
}
  task optimize << {
          def depDir = "./deps"
    ant.mkdir(dir: depDir)
    configurations.jsDep.resolvedConfiguration.resolvedArtifacts.each { artifact
->
  project.copy {
        from artifact.file
        into depDir
        rename { "${artifact.name}.${artifact.extension}" }
      }
      }
         javaexec {JavaExecSpec spec ->
  spec.jvmArgs = ['-Xss2048k']
  spec.main = 'org.mozilla.javascript.tools.shell.Main'
  spec.classpath = configurations.rhino
  spec.args = [buildDir + 'r.js', '-o', './build.js']
 }
}
  artifacts {
    artifactory file: file('./build/commonLib.js'), name: 'commonLib', type: 'js'
}
  uploadArtifactory {
 repositories.mavenDeployer {
  repository(url: "http://xx.xx.xx.xx:8080/artifactory/yyyy/") {
   authentication(userName: "****", password: "****")
  }
 }
}

Uploading commonLib.js to artifactory does not generate / upload POM with dependency on vendor.js.


(Szczepan Faber) #2

It’s probably because ‘jsDep’ kind of dependency does not map any of the maven dependency scopes. Take a look at ‘dependency mapping’ section in the user guide - you can configure the mapping between Gradle configurations and maven scopes.

Hope that helps!


(Gururaj R) #3

If I have a configuration like beow

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'maven'
  repositories {
 mavenCentral()
}
  configurations {
 externallib
 compile {
  extendsFrom externallib
 }
}
dependencies {
   externallib 'net.sf.saxon:Saxon-HE:9.4'
}
  uploadArchives {
 repositories {
  mavenDeployer {
    ext.configureAuth = {
      authentication(userName: 'xx', password: 'yy')
    }
    repository(url: "http://maven.hostname.com:8080/archiva/repository/internal", configureAuth)
  }
 }
}

None of the compile time dependencies are written into POM


(Peter Niederwieser) #4

Dependencies of custom configurations extending ‘compile’ don’t count as (Maven) compile dependencies, just as compile dependencies don’t count as runtime dependencies (although runtime extends compile). You can either add the dependencies directly to ‘compile’, or mess around with configuration-to-scope mappings (mentioned above).