Jar renaming issue


(melkild) #1

If I have one project where I have updated the name of the jar like this:

jar {
  baseName='newName'
}

and then attempt to use it to build another larger jar in a different project (call it project 2) like this:

def projects = rootProject.subprojects.minus(project).collect {it}
  projects.each {
    project.dependencies.add("compile", it)
}
  jar {
         from projects.collect{
        it.configurations.runtime.allArtifacts.files.collect {
            zipTree(it)
         }
     }
  }

Then the renamed jar appears to not be found. If I use the default name, no issues… everything works as expected.

Here is the interesting part… If I run the following in project 2 the list is incorrect (shows the default jar name) after configuration evaluation, but shows the correct name during execution. This isn’t what I expected. Is this a bug?

task dumpJarList << {
       println "Execution"
   println projects.collect{
        it.configurations.runtime.allArtifacts.files.collect {
            zipTree(it)
         }
     }
  }
  project.afterEvaluate {println projects.collect{
        it.configurations.runtime.allArtifacts.files.collect {
            zipTree(it)
         }
     }
}