How to download javadocs and sources for jar using Gradle 2.0?

Gradlebuild.gradle

Gradle Problem Overview


I am using Gradle 2.0. What should I write in build.gradle so that the javadocs and sources are also downloaded along with the jars?

Gradle Solutions


Solution 1 - Gradle

I guess your question is related to a dev workspace, here are links explaining how to add the required configuration in Gradle using the IDEs' plugins:

For Eclipse:

apply plugin: 'java'
apply plugin: 'eclipse'

eclipse {
    classpath {
        downloadJavadoc = true
        downloadSources = true
    }
}

For IntelliJ & Android Studio

apply plugin: 'java'
apply plugin: 'idea'

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

To run these plugins:

gradle cleanEclipse eclipse
gradle cleanIdea idea

Solution 2 - Gradle

In addition to previous question, here is Gradle Kotlin DSL version:

plugins {
    id("idea")
}

idea {
    module {
        isDownloadJavadoc = true
        isDownloadSources = true
    }
}

Solution 3 - Gradle

You can write an ArtifactResolutionQuery that copies all SourcesArtifact and JavadocArtifact for each of your dependencies

See here for an example and here for the gradle source code which does it for the Eclipse/Intellij plugins

Solution 4 - Gradle

Add the javadoc or sources classifies as dependencies:

dependencies {
    compile "commons-codec:commons-codec:1.10:sources"
    compile "commons-codec:commons-codec:1.10:javadoc"
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkhateebView Question on Stackoverflow
Solution 1 - GradlePaul PodgorsekView Answer on Stackoverflow
Solution 2 - GradleAlexander DavliatovView Answer on Stackoverflow
Solution 3 - Gradlelance-javaView Answer on Stackoverflow
Solution 4 - GradlecmcgintyView Answer on Stackoverflow