Paolo Fulgoni Paolo Fulgoni - 1 year ago 111
Java Question

Configure Gradle to publish sources and javadoc

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download