Add support for generating javadoc with Dackka
PiperOrigin-RevId: 396297834
This commit is contained in:
parent
a951769eaa
commit
76014cf0e9
@ -16,22 +16,27 @@ apply from: "${buildscript.sourceFile.parentFile}/javadoc_util.gradle"
|
|||||||
|
|
||||||
class CombinedJavadocPlugin implements Plugin<Project> {
|
class CombinedJavadocPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
static final String TASK_NAME = "generateCombinedJavadoc"
|
static final String JAVADOC_TASK_NAME = "generateCombinedJavadoc"
|
||||||
|
static final String DACKKA_TASK_NAME = "generateCombinedDackka"
|
||||||
|
|
||||||
|
static final String DACKKA_JAR_URL =
|
||||||
|
"https://androidx.dev/dackka/builds/7709825/artifacts/dackka-0.0.9.jar"
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void apply(Project project) {
|
void apply(Project project) {
|
||||||
project.gradle.projectsEvaluated {
|
project.gradle.projectsEvaluated {
|
||||||
Set<Project> libraryModules = getLibraryModules(project)
|
Set<Project> libraryModules = getLibraryModules(project)
|
||||||
if (!libraryModules.isEmpty()) {
|
if (!libraryModules.isEmpty()) {
|
||||||
project.task(TASK_NAME, type: Javadoc) {
|
def guavaReferenceUrl = "https://guava.dev/releases/$project.ext.guavaVersion/api/docs"
|
||||||
|
|
||||||
|
project.task(JAVADOC_TASK_NAME, type: Javadoc) {
|
||||||
description = "Generates combined Javadoc."
|
description = "Generates combined Javadoc."
|
||||||
title = "ExoPlayer library"
|
title = "ExoPlayer library"
|
||||||
source = libraryModules.generateJavadoc.source
|
source = libraryModules.generateJavadoc.source
|
||||||
classpath = project.files([])
|
classpath = project.files([])
|
||||||
destinationDir = project.file("$project.buildDir/docs/javadoc")
|
destinationDir = project.file("$project.buildDir/docs/javadoc")
|
||||||
options {
|
options {
|
||||||
links "https://developer.android.com/reference",
|
links "https://developer.android.com/reference", guavaReferenceUrl
|
||||||
"https://guava.dev/releases/$project.ext.guavaVersion/api/docs"
|
|
||||||
encoding = "UTF-8"
|
encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
options.addBooleanOption "-no-module-directories", true
|
options.addBooleanOption "-no-module-directories", true
|
||||||
@ -60,6 +65,54 @@ class CombinedJavadocPlugin implements Plugin<Project> {
|
|||||||
project.fixJavadoc()
|
project.fixJavadoc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
project.task(DACKKA_TASK_NAME, type: JavaExec) {
|
||||||
|
doFirst {
|
||||||
|
// Recreate the output directory to remove any leftover files from a previous run.
|
||||||
|
def outputDir = project.file("$project.buildDir/docs/dackka")
|
||||||
|
project.delete outputDir
|
||||||
|
project.mkdir outputDir
|
||||||
|
|
||||||
|
// Download the Dackka JAR.
|
||||||
|
new URL(DACKKA_JAR_URL).withInputStream {
|
||||||
|
i -> classpath.getSingleFile().withOutputStream { it << i }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build lists of source files and dependencies.
|
||||||
|
def sources = []
|
||||||
|
def dependencies = []
|
||||||
|
libraryModules.each { libraryModule ->
|
||||||
|
libraryModule.android.libraryVariants.all { variant ->
|
||||||
|
def name = variant.buildType.name
|
||||||
|
if (name == "release") {
|
||||||
|
def classpathFiles =
|
||||||
|
project.files(variant.javaCompileProvider.get().classpath.files)
|
||||||
|
variant.sourceSets.inject(sources) {
|
||||||
|
acc, val -> acc << val.javaDirectories
|
||||||
|
}
|
||||||
|
dependencies << classpathFiles.filter { f -> !(f.path.contains("/buildout/")) }
|
||||||
|
dependencies << libraryModule.project.android.getBootClasspath()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set command line arguments to Dackka.
|
||||||
|
def guavaPackageListFile = getGuavaPackageListFile(getTemporaryDir())
|
||||||
|
def globalLinksString = "$guavaReferenceUrl^$guavaPackageListFile^^"
|
||||||
|
def sourcesString = project.files(sources.flatten())
|
||||||
|
.filter({ f -> project.file(f).exists() }).join(";")
|
||||||
|
def dependenciesString = project.files(dependencies).asPath.replace(':', ';')
|
||||||
|
args("-moduleName", "",
|
||||||
|
"-outputDir", "$outputDir",
|
||||||
|
"-globalLinks", "$globalLinksString",
|
||||||
|
"-loggingLevel", "WARN",
|
||||||
|
"-sourceSet", "-src $sourcesString -classpath $dependenciesString",
|
||||||
|
"-offlineMode")
|
||||||
|
environment("DEVSITE_TENANT", "androidx")
|
||||||
|
}
|
||||||
|
description = "Generates combined javadoc for developer.android.com."
|
||||||
|
classpath = project.files(new File(getTemporaryDir(), "dackka.jar"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,6 +125,17 @@ class CombinedJavadocPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a file containing the list of packages that should be linked to Guava documentation.
|
||||||
|
private static File getGuavaPackageListFile(File directory) {
|
||||||
|
def packageListFile = new File(directory, "guava")
|
||||||
|
packageListFile.text = ["com.google.common.base", "com.google.common.collect",
|
||||||
|
"com.google.common.io", "com.google.common.math",
|
||||||
|
"com.google.common.net", "com.google.common.primitives",
|
||||||
|
"com.google.common.truth", "com.google.common.util.concurrent"]
|
||||||
|
.join('\n')
|
||||||
|
return packageListFile
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: CombinedJavadocPlugin
|
apply plugin: CombinedJavadocPlugin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user