I have several jar tasks in one project - each generating a different jar. Is there a way of accessing the jars in a copy task, so that I can copy all jars from a project, no matter how many jar tasks I have?
You should declare your jars as artifacts
task myJar1(type: Jar) { ... }
task myJar2(type: Jar) { ... }
artifacts {
archives myJar1
archives myJar2
}
task printArchives << {
println "Archives: ${configurations.archives.allArtifacts}"
}
This did the trick:
task myJar1(type: Jar) {...}
task myJar2(type: Jar) {...}
artifacts {
archives myJar1
archives myJar2
}
task copyStuff(type: Copy) {
from configurations.archives.allArtifacts.files
// ...
}