Skip to content

Instantly share code, notes, and snippets.

@kibotu
Last active May 25, 2021 21:10
Show Gist options
  • Save kibotu/994c9cc65fe623b76b76fedfac74b34b to your computer and use it in GitHub Desktop.
Save kibotu/994c9cc65fe623b76b76fedfac74b34b to your computer and use it in GitHub Desktop.
Gradle generate javadoc for Android.
// build a jar with source files
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
@DanielJette
Copy link

Thank you for posting this. It worked perfectly for me after I'd been struggling to write my own without errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment