Skip to content

Instantly share code, notes, and snippets.

@pengrad
Created April 15, 2019 04:42
Show Gist options
  • Save pengrad/1e4aaec817ebb73cae5ae30b8960b79c to your computer and use it in GitHub Desktop.
Save pengrad/1e4aaec817ebb73cae5ae30b8960b79c to your computer and use it in GitHub Desktop.
android.libraryVariants.all { variant ->
javadocs.doFirst {
classpath += files(android.bootClasspath)
if (variant.hasProperty('javaCompileProvider')) {
classpath += files(variant.javaCompileProvider.get().classpath.files)
} else if (variant.hasProperty('javaCompiler')) {
classpath += files(variant.javaCompiler.classpath.files)
}
// Process AAR dependencies
def aarDependencies = classpath.filter {
it.name.endsWith('.aar')
}
classpath -= aarDependencies
aarDependencies.each { aar ->
// Extract classes.jar from the AAR dependency and add it to the androidJavadocs classpath
final String outputPath = "${buildDir}/tmp/aarJar/${aar.name.replace('.aar', '.jar')}"
classpath += files(outputPath)
// Use a task so the actual extraction only happens before the androidJavadocs task is run
dependsOn task(name: "extract${aar.name}").doLast {
MavenPushUtils.extractEntry(aar, 'classes.jar', outputPath)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment