Slackbot
06/20/2023, 7:43 AMAdam
06/20/2023, 7:59 AMjoschi
06/20/2023, 8:35 AMZip and Copy tasks now:
val distCopySpec = copySpec {
val jar = tasks.getByName<Jar>("jar")
from(jar)
from(configurations.runtimeClasspath)
}
tasks.register<Copy>("distTest") {
with(distCopySpec)
into(distsDirectoryTest)
}
tasks.register<Zip>("distZip") {
with(distCopySpec)
}Adam
06/20/2023, 8:37 AMjoschi
06/20/2023, 8:37 AMAdam
06/20/2023, 8:38 AMjoschi
06/20/2023, 8:38 AMCopySpec.Adam
06/20/2023, 8:39 AMjoschi
06/20/2023, 8:39 AMAdam
06/20/2023, 8:41 AMjoschi
06/20/2023, 8:50 AMval distsDirectoryTest = project.distsDirectory.dir("test")
tasks.register<Zip>("distZip") {
val jar = tasks.getByName<Jar>("jar")
from(jar)
from(configurations.runtimeClasspath)
}
tasks.register<Sync>("distTest") {
from(zipTree(tasks.named<Zip>("distZip").map { it.archiveFile }))
into(distsDirectoryTest)
}Adam
06/20/2023, 9:00 AMAdam
06/20/2023, 9:03 AMval distZipTask = tasks.register<Zip>("distZip") {
val jar = tasks.getByName<Jar>("jar")
from(jar)
from(configurations.runtimeClasspath)
}
tasks.register<Sync>("distTest") {
from(zipTree(distZipTask.map { it.archiveFile }))
into(distsDirectoryTest)
}
Or even use a delegated property, so the task will use the name of the variable
val distZip by tasks.registering(Zip::class) {
val jar = tasks.getByName<Jar>("jar")
from(jar)
from(configurations.runtimeClasspath)
}
tasks.register<Sync>("distTest") {
from(zipTree(distZip.map { it.archiveFile }))
into(distsDirectoryTest)
}Vampire
06/20/2023, 9:33 AMdistribution plugin.
The distribution plugin is the one providing the distZip, distTar and installDist tasks.
The application plugin and also the java-library-distribution plugin just apply the distribution plugin and then configure the main distribution, e.g. defining that the dependencies are copied to libs.
So while you of course can just write own tasks, you could also apply the distribution plugin and configure the main distribution however you need it. Or if one of the other plugins is also applied that configure the main distribution, you could then also simply create another distribution that you configure how you need it and automatically get the according tasks created.joschi
06/21/2023, 4:00 PMdistTar task is being registered by the Distribution plugin?
I don't need the tar archive and it feels "wasteful" to have that task automatically being executed when assemble is being executed.Vampire
06/21/2023, 4:48 PMjoschi
06/21/2023, 8:45 PM