diff --git a/build.gradle b/build.gradle index 5d5f2e4b1..f93dddda8 100644 --- a/build.gradle +++ b/build.gradle @@ -457,8 +457,6 @@ task javaIncrementalFormatApply { task javadoc(type: Javadoc) { source javadocSource classpath = files(javadocClasspath) - // Exclude the misbehaving generated-by-Soy Java files - exclude "**/*SoyInfo.java" destinationDir = file("${buildDir}/docs/javadoc") options.encoding = "UTF-8" // 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) } + +// 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 + } + } +} diff --git a/core/build.gradle b/core/build.gradle index 979ecbe83..24faf90d2 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -457,6 +457,22 @@ task soyToJava { "--srcs", "${soyFiles.join(',')}", "--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 {