Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2013 16:14
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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