Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gradle snippet: sources and javadoc jars for every subproject
/* Add this to the parent "build.gradle" to enable xyz-sources.jar and xyz-javadoc.jar generation
* for every java and groovy subproject of the given parent project.
* The script tolerates non-java subprojects.
*/
subprojects {
afterEvaluate {
if(tasks.findByName("classes")) {
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
}
if(tasks.findByName("javadoc")) {
task javadocJar(type: Jar) {
dependsOn javadoc
classifier = 'javadoc'
from javadoc.destinationDir
if(tasks.findByName("groovydoc")) {
dependsOn groovydoc
from groovydoc.destinationDir
}
}
artifacts {
archives javadocJar
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.