@@ -30,40 +30,24 @@ dependencies {
3030 annotationProcessor ' org.derive4j:derive4j'
3131}
3232
33- def exports = [
34- ' jdk.compiler/com.sun.tools.javac.file' ,
35- ' jdk.compiler/com.sun.tools.javac.main' ,
36- ' jdk.compiler/com.sun.tools.javac.parser' ,
37- ' jdk.compiler/com.sun.tools.javac.tree' ,
38- ' jdk.compiler/com.sun.tools.javac.util' ,
39- ' jdk.compiler/com.sun.tools.javac.code' ,
40- ' jdk.compiler/com.sun.tools.javac.api'
41- ]
42-
43- def jvmArgList = exports. collect { value -> " --add-exports=${ value} =ALL-UNNAMED" . toString() }
44-
45- tasks. withType(JavaCompile ). configureEach {
46- options. errorprone. disable ' StrictUnusedVariable'
47-
48- // Allow access to internal javac apis
49- options. compilerArgs + = jvmArgList
50-
51- if (JavaVersion . current() < JavaVersion . VERSION_14 ) {
52- excludes = [' **/Java14InputAstVisitor.java' ]
53- }
54- }
55-
56- tasks. withType(Test ). configureEach {
57- jvmArgs = jvmArgList
58- }
59-
60- tasks. withType(Javadoc ). configureEach {
61- // Allow access to internal javac apis
62- options. optionFiles << file(' ../gradle/javadoc.options' )
63-
64- if (JavaVersion . current() < JavaVersion . VERSION_14 ) {
65- exclude ' **/Java14InputAstVisitor.java'
66- }
33+ moduleJvmArgs {
34+ exports(). addAll(
35+ ' jdk.compiler/com.sun.tools.javac.file' ,
36+ ' jdk.compiler/com.sun.tools.javac.main' ,
37+ ' jdk.compiler/com.sun.tools.javac.parser' ,
38+ ' jdk.compiler/com.sun.tools.javac.tree' ,
39+ ' jdk.compiler/com.sun.tools.javac.util' ,
40+ ' jdk.compiler/com.sun.tools.javac.code' ,
41+ ' jdk.compiler/com.sun.tools.javac.api' )
42+ }
43+
44+ tasks. withType(JavaCompile ). named(' compileJava' ) {
45+ // By setting the source and target compatibility to 11, while still using a higher level
46+ // JDK for compilation, we can compile against the AST classes we need to support >11 source
47+ // features but still run on 11 JDKs (with the addition of checking the java version at runtime
48+ // and dynamically loading the correct formatter implementation)
49+ sourceCompatibility = JavaVersion . VERSION_11
50+ targetCompatibility = JavaVersion . VERSION_11
6751}
6852
6953// false positives due to org.junit.runners.* in the test cases
@@ -76,16 +60,3 @@ tasks.named("test") {
7660 // https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution
7761 systemProperty ' junit.jupiter.execution.parallel.mode.default' , ' concurrent'
7862}
79-
80- // necessary to compile Java14InputAstVisitor
81- idea {
82- module. languageLevel = new org.gradle.plugins.ide.idea.model.IdeaLanguageLevel (14 )
83- }
84-
85- // This block may be replaced by BaselineExportsExtension exports
86- // once https://github.com/gradle/gradle/issues/18824 is resolved.
87- tasks. named(" jar" , Jar ) {
88- manifest {
89- attributes(' Add-Exports' : exports. join(' ' ))
90- }
91- }
0 commit comments