diff --git a/.idea/misc.xml b/.idea/misc.xml index 593e427..ea8d1e3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -9,8 +9,6 @@ - - diff --git a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java index 926c6e7..4c46989 100644 --- a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java @@ -31,19 +31,18 @@ import java.util.List; */ @SuppressWarnings("PMD.LooseCoupling") public class JvmOptions extends ArrayList { + @Serial + private static final long serialVersionUID = 1L; + /** * Keyword to enable native access for all code on the class path. */ public final static String ALL_UNNAMED = "ALL-UNNAMED"; - @Serial - private static final long serialVersionUID = 1L; - /** * Modules that are permitted to perform restricted native operations. * The module name can also be {@link #ALL_UNNAMED}. * - * @param modules the module names * @return this list of options */ public JvmOptions enableNativeAccess(String... modules) { @@ -54,37 +53,10 @@ public class JvmOptions extends ArrayList { * Modules that are permitted to perform restricted native operations. * The module name can also be {@link #ALL_UNNAMED}. * - * @param modules the module names * @return this list of options */ public JvmOptions enableNativeAccess(Collection modules) { add("--enable-native-access=" + StringUtils.join(modules, ",")); return this; } - - /** - * Controls what action the Java runtime takes when native access is not enabled for a module. - * - * @param access the access mode - * @return this list of options - */ - public JvmOptions illegalNativeAccess(NativeAccess access) { - add("--illegal-native-access=" + access.mode); - return this; - } - - /** - * Illegal native access modes. - */ - public enum NativeAccess { - ALLOW("allow"), - DENY("deny"), - WARN("warn"); - - public final String mode; - - NativeAccess(String mode) { - this.mode = mode; - } - } } diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index 2c9032d..1689525 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -104,10 +104,9 @@ class CompileKotlinOperationTest { .testSourceFiles(List.of(new File("tfile3"), new File("tfile4"))) .testSourceFiles(new File("tfile5"), new File("tfile6")) .plugins("plugin1", "plugin2") - .plugins(CompilerPlugin.KOTLIN_SERIALIZATION, CompilerPlugin.ASSIGNMENT, CompilerPlugin.COMPOSE) + .plugins(CompilerPlugin.KOTLIN_SERIALIZATION, CompilerPlugin.ASSIGNMENT) .plugins(new File("lib/compile"), CompilerPlugin.LOMBOK, CompilerPlugin.POWER_ASSERT) - .plugins(Path.of("lib/compile"), CompilerPlugin.NOARG, CompilerPlugin.ALL_OPEN, - CompilerPlugin.KOTLIN_IMPORTS_DUMPER) + .plugins(Path.of("lib/compile"), CompilerPlugin.NOARG, CompilerPlugin.ALL_OPEN) .plugins("lib/compile", CompilerPlugin.KOTLINX_SERIALIZATION, CompilerPlugin.SAM_WITH_RECEIVER) .plugins(List.of("plugin3", "plugin4")); @@ -135,12 +134,10 @@ class CompileKotlinOperationTest { softly.assertThat(op.plugins()).as("plugins").contains("plugin1", "plugin2", "plugin3", "plugin4", "/kotlin_home/lib/kotlin-serialization-compiler-plugin.jar", "/kotlin_home/lib/assignment-compiler-plugin.jar", - "/kotlin_home/lib/compose-compiler-plugin.jar", new File("lib/compile", "lombok-compiler-plugin.jar").getAbsolutePath(), new File("lib/compile", "power-assert-compiler-plugin.jar").getAbsolutePath(), new File("lib/compile", "noarg-compiler-plugin.jar").getAbsolutePath(), new File("lib/compile", "allopen-compiler-plugin.jar").getAbsolutePath(), - new File("lib/compile", "kotlin-imports-dumper-compiler-plugin.jar").getAbsolutePath(), new File("lib/compile", "kotlinx-serialization-compiler-plugin.jar").getAbsolutePath(), new File("lib/compile", "sam-with-receiver-compiler-plugin.jar").getAbsolutePath()); } @@ -318,8 +315,6 @@ class CompileKotlinOperationTest { .fromProject(new BaseProject()) .plugins(CompilerPlugin.ALL_OPEN, CompilerPlugin.ASSIGNMENT, - CompilerPlugin.COMPOSE, - CompilerPlugin.KOTLIN_IMPORTS_DUMPER, CompilerPlugin.KOTLINX_SERIALIZATION, CompilerPlugin.KOTLIN_SERIALIZATION, CompilerPlugin.LOMBOK, diff --git a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java index 0dcfbef..eb2d59a 100644 --- a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java @@ -27,8 +27,7 @@ class JvmOptionsTest { @Test void testCompileOptions() { var compileOptions = new CompileOptions().jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED)); - assertThat(compileOptions.jvmOptions()).as(JvmOptions.ALL_UNNAMED) - .containsExactly("--enable-native-access=ALL-UNNAMED"); + assertThat(compileOptions.jvmOptions()).as(JvmOptions.ALL_UNNAMED).containsExactly("--enable-native-access=ALL-UNNAMED"); assertThat(compileOptions.args()).as("args()").containsExactly("-J--enable-native-access=ALL-UNNAMED"); compileOptions = new CompileOptions().jvmOptions(new JvmOptions().enableNativeAccess("m1", "m2")); @@ -41,25 +40,10 @@ class JvmOptionsTest { var options = new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); assertThat(options).as(JvmOptions.ALL_UNNAMED).containsExactly("--enable-native-access=ALL-UNNAMED"); - options = new JvmOptions().enableNativeAccess("m1"); - assertThat(options).as("m1").containsExactly("--enable-native-access=m1"); - options = new JvmOptions().enableNativeAccess("m1", "m2"); assertThat(options).as("m1,m2").containsExactly("--enable-native-access=m1,m2"); } - @Test - void testIllegalNativeAccess() { - var options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW); - assertThat(options).as("ALLOW").containsExactly("--illegal-native-access=allow"); - - options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.DENY); - assertThat(options).as("DENY").containsExactly("--illegal-native-access=deny"); - - options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.WARN); - assertThat(options).as("WARN").containsExactly("--illegal-native-access=warn"); - } - @Test void testJvmOptions() { var compileOptions = new CompileOptions().jvmOptions("option1", "option2"); @@ -75,13 +59,5 @@ class JvmOptionsTest { .containsExactly("option1", "option2", "--enable-native-access=ALL-UNNAMED"); assertThat(compileOptions.args()).as("args(option1,option2,ALL_UNNAMED)") .containsExactly("-Joption1", "-Joption2", "-J--enable-native-access=ALL-UNNAMED"); - - compileOptions = compileOptions.jvmOptions(new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW)); - assertThat(compileOptions.jvmOptions()).as("allow") - .containsExactly("option1", "option2", "--enable-native-access=ALL-UNNAMED", - "--illegal-native-access=allow"); - assertThat(compileOptions.args()).as("args(option1,option2,ALL_UNNAMED,allow)") - .containsExactly("-Joption1", "-Joption2", "-J--enable-native-access=ALL-UNNAMED", - "-J--illegal-native-access=allow"); } }