From 546d7b41e99feb44136ec648182596c6fc5d0b87 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 23 Aug 2022 10:45:12 -0700 Subject: [PATCH] Polish 'Add JVM options to prevent warnings with asciidoctor' See gh-32123 --- .../boot/build/AsciidoctorConventions.java | 10 ++++++++++ .../spring-boot-actuator-autoconfigure/build.gradle | 6 ------ spring-boot-project/spring-boot-docs/build.gradle | 9 --------- .../spring-boot-gradle-plugin/build.gradle | 6 ------ .../spring-boot-maven-plugin/build.gradle | 6 ------ 5 files changed, 10 insertions(+), 27 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java b/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java index ba08484469..20b82cda15 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java @@ -26,6 +26,7 @@ import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask; import org.asciidoctor.gradle.jvm.AsciidoctorJExtension; import org.asciidoctor.gradle.jvm.AsciidoctorJPlugin; import org.asciidoctor.gradle.jvm.AsciidoctorTask; +import org.gradle.api.JavaVersion; import org.gradle.api.Project; import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.Sync; @@ -118,6 +119,7 @@ class AsciidoctorConventions { asciidoctorTask.configurations(EXTENSIONS_CONFIGURATION_NAME); configureCommonAttributes(project, asciidoctorTask); configureOptions(asciidoctorTask); + configureForkOptions(asciidoctorTask); asciidoctorTask.baseDirFollowsSourceDir(); createSyncDocumentationSourceTask(project, asciidoctorTask); if (asciidoctorTask instanceof AsciidoctorTask) { @@ -136,6 +138,14 @@ class AsciidoctorConventions { asciidoctorTask.attributes(attributes); } + // See https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/597 + private void configureForkOptions(AbstractAsciidoctorTask asciidoctorTask) { + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16)) { + asciidoctorTask.forkOptions((options) -> options.jvmArgs("--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", + "--add-opens", "java.base/java.io=ALL-UNNAMED")); + } + } + private String determineGitHubTag(Project project) { String version = "v" + project.getVersion(); return (version.endsWith("-SNAPSHOT")) ? "2.6.x" : version; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index a79e83eab5..5a025c7fd3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -222,18 +222,12 @@ asciidoctor { sources { include "index.adoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } task asciidoctorPdf(type: org.asciidoctor.gradle.jvm.AsciidoctorTask) { sources { include "index.adoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } task zip(type: Zip) { diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index 3f7554938e..6b00503159 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -332,27 +332,18 @@ asciidoctor { sources { include "*.singleadoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } task asciidoctorPdf(type: org.asciidoctor.gradle.jvm.AsciidoctorTask) { sources { include "*.singleadoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } task asciidoctorMultipage(type: org.asciidoctor.gradle.jvm.AsciidoctorTask) { sources { include "*.adoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } syncDocumentationSourceForAsciidoctor { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle index efaf56ffff..bd1796d7ff 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle @@ -79,18 +79,12 @@ asciidoctor { sources { include "index.adoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } task asciidoctorPdf(type: org.asciidoctor.gradle.jvm.AsciidoctorTask) { sources { include "index.adoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } javadoc { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle index 3d6b240cf1..3e08143728 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle @@ -94,18 +94,12 @@ asciidoctor { sources { include "index.adoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } task asciidoctorPdf(type: org.asciidoctor.gradle.jvm.AsciidoctorTask) { sources { include "index.adoc" } - forkOptions { - jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED" - } } syncDocumentationSourceForAsciidoctorPdf {