When I use "apply from" and dinamic tasks creation there is a missing ArchivePublishArtifact

(Victor Martinez) #1

For somehow there is a missing artifact when I split up a build gradle script in two different scripts:

  • build.gradle

which contains the build logic

  • promote.gradle

which will be used as common phase for different projects. It will iterate through each generated artifact and promote it into another stage environment.


apply plugin: "java"
  apply plugin: "maven"
  apply from: 'promote.gradle'
    //// build process already skipped.....
    task zipKit(type: Zip, dependsOn: copySQLToKit) {
    from('build/tmp/kit').into('XXXX-' + version)
    outputs.upToDateWhen {false}
    artifacts {
 archives zipKit
    uploadArchives {
 repositories {
  mavenDeployer {
   repository(url: 'http://artifactory/ci')
   snapshotRepository(url: 'http://artifactory/ci/')


apply plugin: "maven"
  apply plugin: "java"
    def promoteCommand = ['echo']
  configurations.archives.allArtifacts.each { def targetName ->
     tasks.add(name: "promoteArtefact$targetName", type: Exec) {
         commandLine promoteCommand + ['test', project.group, targetName.name, project.version]
     task promote(dependsOn: tasks.matching { Task task -> task.name.startsWith("promoteArtefact")})
     task mappings << {
    configurations.archives.allArtifacts.each { dep ->
        println " ${dep.getFile()}"

Current console output (just removed some tasks as part of the console output in order to make it more readable)

>gradlew tasks --all --daemon
  Other tasks
promote [jar]
    promoteArtefactArchivePublishArtifact XXXX:jar:jar
start [classes, testClasses]

Current console output for mappings task

>gradlew --daemon mappings

Console ouput for promote task

>gradlew --daemon promote
:promoteArtefactArchivePublishArtifact XXXX:jar:jar:
test com.platform XXXX 0.0.0-dev

My question is, how can I get a complete list of all artifacts which they will be generated during a build and use that as part of another gradle script (apply from:)