I've got a gradle build with source and javadoc jars and I'd like these tasks to be executed before distZip and distTar, is there a dependency that captures both of those for use with shouldRunAfter.
Right now I've got:
task javadocJar(type: Jar) {
classifier 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allSource
}
tasks.distZip.shouldRunAfter tasks.javadocJar
tasks.distTar.shouldRunAfter tasks.javadocJar
tasks.distZip.shouldRunAfter tasks.sourcesJar
tasks.distTar.shouldRunAfter tasks.sourcesJar
I'd like to condense down those four shouldRunAfter to two which captures both distZip and distTar.
You can execute multiple tasks from a single build file. Gradle can handle the build file using gradle command. This command will compile each task in such an order that they are listed and execute each task along with the dependencies using different options.
You can use groovy syntax to make this shorter
[distZip, distTar]*.shouldRunAfter javadocJar, sourcesJar
Probably you also want dependsOn
instead of shouldRunAfter
so that the jars are built whenever one of the dist tasks is enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With