By project generates a tgz and a war file (it is also generating a jar file for some reason, but that is another issue)
I’m currently using:
configurations.archives.allArtifacts
which returns only the tgz generated by the build.
I’ve examined other configurations as well. For example, configurations.default and configurations.runtime both give me the jar file generated by my build but not the war. This is confusing because I’m not really sure why the jar file is being generated in the first place. According to the docs for the War plugin, jar archive generation is disabled by the War plugin.
My question is, how can I get a complete list of all artifacts generated during a build?
It seems that adding my custom Tar task obscures or removes the war artifact under the archives configuration. In other words, if I remove the Tar task from my build,
The tarDist.gradle file creates a tar task and created a configuration named “dist”.
If consumers of the tarDist.gradle applies the war plugin first and the tarDist.gradle second, no problems occur and there are two artifacts in configurations.archives.allArtifacts.
If the order is reversed and the tarDist.gradle is applied before the war plugin, then configurations.archives.allArtifacts contains only the tgz generated from the tarDist.gradle file.
The tarDist.gradle file:
configurations {
dist
}
task tarDist (type: Tar) {
visible = true
// ensure this task always runs
outputs.upToDateWhen { false }
compression=Compression.GZIP
// include everything under src/dist
from ("${project.projectDir}/src/dist/") {
include ("**/*")
into( "" )
}
// include everything under build/dist/* if it exists
from ("${project.buildDir}/dist/"){
include ("**/*")
into( "" )
}
//make sure files under the bin dir are executable
eachFile { fileCopyDetails ->
logger.debug("Archiving file: ${fileCopyDetails.path}")
if( fileCopyDetails.name.matches(".*[.](sh|bat|exe)") )
fileMode = 0755
else if( fileCopyDetails.path.matches("^scripts/.*") )
fileMode = 0755
else
fileMode = 0644
}
}
artifacts {
dist tarDist
}
And a sample file that might use the tarDist.gradle
Simply changing the order of the two apply statements will cause the behavior described above where the war file doesn’t show up in the configurations.archives.allArtifacts set.