Skip to content

Instantly share code, notes, and snippets.

@akhikhl
Created June 20, 2013 16:14
Show Gist options
  • Save akhikhl/5824197 to your computer and use it in GitHub Desktop.
Save akhikhl/5824197 to your computer and use it in GitHub Desktop.
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