From 04f032e226e28942b4ddc1c91ff58e53d46589b0 Mon Sep 17 00:00:00 2001 From: Lai Jiang Date: Wed, 29 Jul 2020 13:41:02 -0400 Subject: [PATCH] Move the documentation package to its own subproject (#722) This makes it easier to later migrate the package to Java 11. If we move and migrate in a single PR, because of the portion of the contents that s changed, git will have trouble recognizing that some files are renamed *and* modified and treat them as distinct files, making code review difficult. --- core/build.gradle | 21 --------- .../documentation/generate_javadoc.sh | 38 ---------------- docs/build.gradle | 44 +++++++++++++++++++ .../documentation/DocumentationGenerator.java | 0 .../documentation/FlowDocumentation.java | 0 .../documentation/FlowDocumentationTool.java | 0 .../documentation/JavadocWrapper.java | 0 .../MarkdownDocumentationFormatter.java | 0 .../registry/documentation/FlowContext.java | 0 .../documentation/FlowDocumentationTest.java | 2 +- .../documentation/FlowExceptionsTest.java | 0 .../MarkdownDocumentationFormatterTest.java | 2 +- settings.gradle | 1 + 13 files changed, 47 insertions(+), 61 deletions(-) delete mode 100755 core/src/main/java/google/registry/documentation/generate_javadoc.sh create mode 100644 docs/build.gradle rename {core => docs}/src/main/java/google/registry/documentation/DocumentationGenerator.java (100%) rename {core => docs}/src/main/java/google/registry/documentation/FlowDocumentation.java (100%) rename {core => docs}/src/main/java/google/registry/documentation/FlowDocumentationTool.java (100%) rename {core => docs}/src/main/java/google/registry/documentation/JavadocWrapper.java (100%) rename {core => docs}/src/main/java/google/registry/documentation/MarkdownDocumentationFormatter.java (100%) rename {core => docs}/src/test/java/google/registry/documentation/FlowContext.java (100%) rename {core => docs}/src/test/java/google/registry/documentation/FlowDocumentationTest.java (97%) rename {core => docs}/src/test/java/google/registry/documentation/FlowExceptionsTest.java (100%) rename {core => docs}/src/test/java/google/registry/documentation/MarkdownDocumentationFormatterTest.java (98%) diff --git a/core/build.gradle b/core/build.gradle index 5b70bb773..518607b4c 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -82,11 +82,6 @@ sourceSets { main { java { srcDirs += generatedDir - // Javadoc API is deprecated in Java 11 and removed in Java 12. - // TODO(jianglai): re-enable after migrating to the new Javadoc API - if ((JavaVersion.current().majorVersion as Integer) >= 11) { - exclude 'google/registry/documentation/**' - } } resources { exclude '**/*.xjb' @@ -853,22 +848,6 @@ task generateGoldenImages(type: FilteringTest) { } generateGoldenImages.finalizedBy(findGoldenImages) -task flowDocsTool(type: JavaExec) { - systemProperty 'test.projectRoot', rootProject.projectRootDir - systemProperty 'test.resourcesDir', resourcesDir - - classpath = sourceSets.main.runtimeClasspath - main = 'google.registry.documentation.FlowDocumentationTool' - - def arguments = [] - if (rootProject.flowDocsFile) { - arguments << "--output_file=${rootProject.flowDocsFile}" - } else { - arguments << "--output_file=${rootProject.projectRootDir}/docs/flows.md" - } - args arguments -} - task standardTest(type: FilteringTest) { includeAllTests() exclude fragileTestPatterns diff --git a/core/src/main/java/google/registry/documentation/generate_javadoc.sh b/core/src/main/java/google/registry/documentation/generate_javadoc.sh deleted file mode 100755 index 47691b1bb..000000000 --- a/core/src/main/java/google/registry/documentation/generate_javadoc.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Copyright 2017 The Nomulus Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# Generate javadoc for the project - -if (( $# != 3 )); then - echo "Usage: $0 JAVADOC ZIP OUT" 1>&2 - exit 1 -fi - -JAVADOC_BINARY="$1" -ZIP_BINARY="$2" -TARGETFILE="$3" -TMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/generate_javadoc.XXXXXXXX")" -PWDDIR="$(pwd)" - -"${JAVADOC_BINARY}" -d "${TMPDIR}" \ - $(find java -name \*.java) \ - -tag error:t:'EPP Errors' \ - -subpackages google.registry \ - -exclude google.registry.dns:google.registry.proxy:google.registry.monitoring.blackbox -cd "${TMPDIR}" -"${PWDDIR}/${ZIP_BINARY}" -rXoq "${PWDDIR}/${TARGETFILE}" . -cd - -rm -rf "${TMPDIR}" diff --git a/docs/build.gradle b/docs/build.gradle new file mode 100644 index 000000000..08f594aea --- /dev/null +++ b/docs/build.gradle @@ -0,0 +1,44 @@ +// Copyright 2020 The Nomulus Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +dependencies { + def deps = rootProject.dependencyMap + + compile deps['com.beust:jcommander'] + compile deps['com.google.code.findbugs:jsr305'] + compile deps['com.google.flogger:flogger'] + compile deps['com.google.guava:guava'] + compile deps['com.google.re2j:re2j'] + compile project(':core') + compile project(':util') + + testCompile deps['com.google.truth:truth'] + testCompile deps['com.thoughtworks.qdox:qdox'] + testCompile deps['org.junit.jupiter:junit-jupiter-api'] + testCompile deps['org.junit.jupiter:junit-jupiter-engine'] +} + +task flowDocsTool(type: JavaExec) { + systemProperty 'test.projectRoot', rootProject.projectRootDir + classpath = sourceSets.main.runtimeClasspath + main = 'google.registry.documentation.FlowDocumentationTool' + + def arguments = [] + if (rootProject.flowDocsFile) { + arguments << "--output_file=${rootProject.flowDocsFile}" + } else { + arguments << "--output_file=${rootProject.projectRootDir}/docs/flows.md" + } + args arguments +} diff --git a/core/src/main/java/google/registry/documentation/DocumentationGenerator.java b/docs/src/main/java/google/registry/documentation/DocumentationGenerator.java similarity index 100% rename from core/src/main/java/google/registry/documentation/DocumentationGenerator.java rename to docs/src/main/java/google/registry/documentation/DocumentationGenerator.java diff --git a/core/src/main/java/google/registry/documentation/FlowDocumentation.java b/docs/src/main/java/google/registry/documentation/FlowDocumentation.java similarity index 100% rename from core/src/main/java/google/registry/documentation/FlowDocumentation.java rename to docs/src/main/java/google/registry/documentation/FlowDocumentation.java diff --git a/core/src/main/java/google/registry/documentation/FlowDocumentationTool.java b/docs/src/main/java/google/registry/documentation/FlowDocumentationTool.java similarity index 100% rename from core/src/main/java/google/registry/documentation/FlowDocumentationTool.java rename to docs/src/main/java/google/registry/documentation/FlowDocumentationTool.java diff --git a/core/src/main/java/google/registry/documentation/JavadocWrapper.java b/docs/src/main/java/google/registry/documentation/JavadocWrapper.java similarity index 100% rename from core/src/main/java/google/registry/documentation/JavadocWrapper.java rename to docs/src/main/java/google/registry/documentation/JavadocWrapper.java diff --git a/core/src/main/java/google/registry/documentation/MarkdownDocumentationFormatter.java b/docs/src/main/java/google/registry/documentation/MarkdownDocumentationFormatter.java similarity index 100% rename from core/src/main/java/google/registry/documentation/MarkdownDocumentationFormatter.java rename to docs/src/main/java/google/registry/documentation/MarkdownDocumentationFormatter.java diff --git a/core/src/test/java/google/registry/documentation/FlowContext.java b/docs/src/test/java/google/registry/documentation/FlowContext.java similarity index 100% rename from core/src/test/java/google/registry/documentation/FlowContext.java rename to docs/src/test/java/google/registry/documentation/FlowContext.java diff --git a/core/src/test/java/google/registry/documentation/FlowDocumentationTest.java b/docs/src/test/java/google/registry/documentation/FlowDocumentationTest.java similarity index 97% rename from core/src/test/java/google/registry/documentation/FlowDocumentationTest.java rename to docs/src/test/java/google/registry/documentation/FlowDocumentationTest.java index ed80b9fce..02a67b8c7 100644 --- a/core/src/test/java/google/registry/documentation/FlowDocumentationTest.java +++ b/docs/src/test/java/google/registry/documentation/FlowDocumentationTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; class FlowDocumentationTest { private static final Path GOLDEN_MARKDOWN_FILEPATH = getProjectRoot().resolve("docs/flows.md"); - private static final String UPDATE_COMMAND = "./gradlew :core:flowDocsTool"; + private static final String UPDATE_COMMAND = "./gradlew :docs:flowDocsTool"; private static final String UPDATE_INSTRUCTIONS = Joiner.on('\n') .join( diff --git a/core/src/test/java/google/registry/documentation/FlowExceptionsTest.java b/docs/src/test/java/google/registry/documentation/FlowExceptionsTest.java similarity index 100% rename from core/src/test/java/google/registry/documentation/FlowExceptionsTest.java rename to docs/src/test/java/google/registry/documentation/FlowExceptionsTest.java diff --git a/core/src/test/java/google/registry/documentation/MarkdownDocumentationFormatterTest.java b/docs/src/test/java/google/registry/documentation/MarkdownDocumentationFormatterTest.java similarity index 98% rename from core/src/test/java/google/registry/documentation/MarkdownDocumentationFormatterTest.java rename to docs/src/test/java/google/registry/documentation/MarkdownDocumentationFormatterTest.java index 58b0cdd46..49e070242 100644 --- a/core/src/test/java/google/registry/documentation/MarkdownDocumentationFormatterTest.java +++ b/docs/src/test/java/google/registry/documentation/MarkdownDocumentationFormatterTest.java @@ -15,7 +15,7 @@ package google.registry.documentation; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Arrays; import org.junit.jupiter.api.Test; diff --git a/settings.gradle b/settings.gradle index d7f54a579..58f8afffe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -30,6 +30,7 @@ rootProject.name = 'nomulus' include 'common' include 'core' include 'db' +include 'docs' include 'integration' include 'networking' include 'processor'