Paolo Fulgoni Paolo Fulgoni - 1 month ago 10
Java Question

Configure Gradle to publish sources and javadoc

How do I configure Gradle to publish sources and javadoc jars to a repository?

Answer

Add the following code to the build script:

task packageJavadoc(type: Jar, dependsOn: 'javadoc') {
    from javadoc.destinationDir
    classifier = 'javadoc'
}
task packageSources(type: Jar, dependsOn: 'classes') {
    from sourceSets.main.allSource
    classifier = 'sources'
}
artifacts {
    archives packageJavadoc
    archives packageSources
}

Tested with Gradle 1.10

Comments