Polish 'Add JVM options to prevent warnings with asciidoctor'
See gh-32123
This commit is contained in:
		
							parent
							
								
									7b4db4cafc
								
							
						
					
					
						commit
						546d7b41e9
					
				| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue