Compare commits

..

No commits in common. "54228e314920426fbc8e800e4f6d723a557c5b9d" and "779e6d4b791ed4d87045ef9e4d1cf21f8036957c" have entirely different histories.

4 changed files with 6 additions and 65 deletions

2
.idea/misc.xml generated
View file

@ -9,8 +9,6 @@
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin NOARG" />
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin POWER_ASSERT" />
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin SAM_WITH_RECEIVER" />
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin COMPOSE" />
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin KOTLIN_IMPORTS_DUMPER" />
</entry_points>
<pattern value="rife.bld.extension.CompileKotlinOperationBuild" method="pmd" />
<pattern value="rife.bld.extension.kotlin.CompilerPlugin" />

View file

@ -31,19 +31,18 @@ import java.util.List;
*/
@SuppressWarnings("PMD.LooseCoupling")
public class JvmOptions extends ArrayList<String> {
@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<String> {
* 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<String> 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;
}
}
}

View file

@ -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,

View file

@ -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");
}
}