Fix javadoc problems with SoyInfo and subprojects (#1326)

* Fix javadoc problems with SoyInfo and subprojects

The *SoyInfo.java files generated by the soy compiler contain deprecation
warnings with links to files that are not imported.  This causes a javadoc
warning.  Temporarily fix this by replacing the link tags with "LINK".  This
also allows us to remove the exclusion of these files, which is a bit nicer.

Also disable javadoc tasks from subprojects.  These just break because they
don't have access to the legacy javadoc classes in the root.
This commit is contained in:
Michael Muller 2021-09-20 10:35:07 -04:00 committed by GitHub
parent 92b83a9d7a
commit 0afef0fb82
2 changed files with 28 additions and 2 deletions

View file

@ -457,8 +457,6 @@ task javaIncrementalFormatApply {
task javadoc(type: Javadoc) { task javadoc(type: Javadoc) {
source javadocSource source javadocSource
classpath = files(javadocClasspath) classpath = files(javadocClasspath)
// Exclude the misbehaving generated-by-Soy Java files
exclude "**/*SoyInfo.java"
destinationDir = file("${buildDir}/docs/javadoc") destinationDir = file("${buildDir}/docs/javadoc")
options.encoding = "UTF-8" options.encoding = "UTF-8"
// In a lot of places we don't write @return so suppress warnings about that. // In a lot of places we don't write @return so suppress warnings about that.
@ -483,3 +481,15 @@ task coreDev {
} }
javadocDependentTasks.each { tasks.javadoc.dependsOn(it) } javadocDependentTasks.each { tasks.javadoc.dependsOn(it) }
// disable javadoc in subprojects, these will break because they don't have
// the correct classpath (see above).
gradle.taskGraph.whenReady { graph ->
graph.getAllTasks().each { task ->
def subprojectJavadoc = (task.path =~ /:.+:javadoc/)
if (subprojectJavadoc) {
println "Skipping ${task.path} for javadoc (only root javadoc works)"
task.enabled = false
}
}
}

View file

@ -457,6 +457,22 @@ task soyToJava {
"--srcs", "${soyFiles.join(',')}", "--srcs", "${soyFiles.join(',')}",
"--compileTimeGlobalsFile", "${resourcesSourceDir}/google/registry/ui/globals.txt" "--compileTimeGlobalsFile", "${resourcesSourceDir}/google/registry/ui/globals.txt"
} }
// Replace the "@link" tags after the "@deprecated" tags in the generated
// files. The soy compiler doesn't generate imports for these, causing
// us to get warnings when we generate javadocs.
// TODO(b/200296387): To be fair, the deprecations are accurate: we're
// using the old "SoyInfo" classes instead of the new "Templates" files.
// When we convert to the new classes, this hack can go away.
def outputs = fileTree(outputDirectory) {
include '**/*.java'
}
outputs.each { file ->
exec {
commandLine 'sed', '-i', 's/@link/LINK/g', file.getCanonicalPath()
}
}
} }
doLast { doLast {