diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index d01b562..cb23afa 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: java-version: [17, 21, 24] - kotlin-version: [1.9.25, 2.0.21, 2.1.20] + kotlin-version: [1.9.25, 2.0.21, 2.1.10] steps: - name: Checkout source repository diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 29786b7..1ffe3ff 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,7 +1,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.5-SNAPSHOT +bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.4 bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.2.1 diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index cd44399..c3bf9b0 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -3,8 +3,6 @@ package com.example; import rife.bld.BuildCommand; import rife.bld.Project; import rife.bld.extension.CompileKotlinOperation; -import rife.bld.extension.kotlin.CompileOptions; -import rife.bld.extension.kotlin.JvmOptions; import java.io.File; import java.util.List; @@ -30,7 +28,7 @@ public class ExampleBuild extends Project { repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES); - final var kotlin = version(2, 1, 20); + final var kotlin = version(2, 1, 10); scope(compile) .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) @@ -60,14 +58,12 @@ public class ExampleBuild extends Project { @BuildCommand(summary = "Compiles the Kotlin project") @Override public void compile() throws Exception { - var options = new CompileOptions().verbose(true); - options.jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); // The source code located in src/main/kotlin and src/test/kotlin will be compiled - new CompileKotlinOperation() + var op = new CompileKotlinOperation() // .kotlinHome("path/to/kotlin") // .kotlinc("path/to/kotlinc") - .compileOptions(options) - .fromProject(this) - .execute(); + .fromProject(this); + op.compileOptions().verbose(true); + op.execute(); } } diff --git a/scripts/checkcliargs.sh b/scripts/checkcliargs.sh index 94313ab..30c8537 100755 --- a/scripts/checkcliargs.sh +++ b/scripts/checkcliargs.sh @@ -4,7 +4,7 @@ new=/tmp/checkcliargs-new old=/tmp/checkcliargs-old kotlinc -h 2>$new -~/.sdkman/candidates/kotlin/2.1.10/bin/kotlinc -h 2>$old +~/.sdkman/candidates/kotlin/2.1.0/bin/kotlinc -h 2>$old code --diff --wait $old $new diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index 30f0a4e..19ecbf6 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java @@ -37,7 +37,7 @@ public class CompileOptions { private final Collection advancedOptions_ = new ArrayList<>(); private final Collection argFile_ = new ArrayList<>(); private final Collection classpath_ = new ArrayList<>(); - private final JvmOptions jvmOptions_ = new JvmOptions(); + private final Collection jvmOptions_ = new ArrayList<>(); private final Collection optIn_ = new ArrayList<>(); private final Collection options_ = new ArrayList<>(); private final Collection plugin_ = new ArrayList<>(); @@ -709,12 +709,12 @@ public class CompileOptions { * * @return the JVM options */ - public JvmOptions jvmOptions() { + public Collection jvmOptions() { return jvmOptions_; } /** - * Pass an option directly to the Java Virtual Machine + * Pass an option directly to Java Virtual Machine * * @param jvmOptions the JVM options * @return this operation instance @@ -725,7 +725,7 @@ public class CompileOptions { } /** - * Pass an option directly to the Java Virtual Machine + * Pass an option directly to JVM * * @param jvmOptions one or more JVM option * @return this operation instance diff --git a/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java index f1fd584..03d4382 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java +++ b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java @@ -17,7 +17,6 @@ package rife.bld.extension.kotlin; /** - * @author Erik C. Thauvin * Defines the known Kotlin compiler plugin JARs. * * @author Erik C. Thauvin @@ -26,8 +25,6 @@ package rife.bld.extension.kotlin; public enum CompilerPlugin { ALL_OPEN("allopen-compiler-plugin.jar"), ASSIGNMENT("assignment-compiler-plugin.jar"), - COMPOSE("compose-compiler-plugin.jar"), - KOTLIN_IMPORTS_DUMPER("kotlin-imports-dumper-compiler-plugin.jar"), KOTLINX_SERIALIZATION("kotlinx-serialization-compiler-plugin.jar"), KOTLIN_SERIALIZATION("kotlin-serialization-compiler-plugin.jar"), LOMBOK("lombok-compiler-plugin.jar"), diff --git a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java deleted file mode 100644 index b050b83..0000000 --- a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2023-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rife.bld.extension.kotlin; - -import rife.tools.StringUtils; - -import java.io.Serial; -import java.util.ArrayList; -import java.util.List; - -/** - * Java Virtual Machine options. - * - * @author Erik C. Thauvin - * @since 1.0.5 - */ -@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"; - - /** - * Modules that are permitted to perform restricted native operations. - * The module name can also be {@link #ALL_UNNAMED}. - * - * @return this list of options - */ - public JvmOptions enableNativeAccess(String... modules) { - return enableNativeAccess(List.of(modules)); - } - - /** - * Modules that are permitted to perform restricted native operations. - * The module name can also be {@link #ALL_UNNAMED}. - * - * @return this list of options - */ - public JvmOptions enableNativeAccess(List modules) { - add("--enable-native-access=" + StringUtils.join(modules, ",")); - return this; - } -} diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index 1689525..9fffc25 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -23,7 +23,6 @@ import rife.bld.BaseProject; import rife.bld.blueprints.BaseProjectBlueprint; import rife.bld.extension.kotlin.CompileOptions; import rife.bld.extension.kotlin.CompilerPlugin; -import rife.bld.extension.kotlin.JvmOptions; import rife.tools.FileUtils; import java.io.File; @@ -178,10 +177,9 @@ class CompileKotlinOperationTest { op.compileOptions().verbose(true); op.compileOptions().jdkRelease("17"); - op.compileOptions().jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); var args = op.compileOptions().args(); - var matches = List.of("-Xjdk-release=17", "-J--enable-native-access=ALL-UNNAMED", "-no-stdlib", "-verbose"); + var matches = List.of("-Xjdk-release=17", "-no-stdlib", "-verbose"); assertThat(args).as(args + " == " + matches).isEqualTo(matches); op.execute(); diff --git a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java deleted file mode 100644 index eb2d59a..0000000 --- a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2023-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rife.bld.extension.kotlin; - -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -@SuppressWarnings("PMD.AvoidDuplicateLiterals") -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.args()).as("args()").containsExactly("-J--enable-native-access=ALL-UNNAMED"); - - compileOptions = new CompileOptions().jvmOptions(new JvmOptions().enableNativeAccess("m1", "m2")); - assertThat(compileOptions.jvmOptions()).as("m1,m2").containsExactly("--enable-native-access=m1,m2"); - assertThat(compileOptions.args()).as("args(m1,m2)").containsExactly("-J--enable-native-access=m1,m2"); - } - - @Test - void testEnableNativeAccess() { - 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", "m2"); - assertThat(options).as("m1,m2").containsExactly("--enable-native-access=m1,m2"); - } - - @Test - void testJvmOptions() { - var compileOptions = new CompileOptions().jvmOptions("option1", "option2"); - assertThat(compileOptions.jvmOptions()).as("option1,option2").containsExactly("option1", "option2"); - assertThat(compileOptions.args()).as("args()").containsExactly("-Joption1", "-Joption2"); - - compileOptions = new CompileOptions().jvmOptions(List.of("option1", "option2")); - assertThat(compileOptions.jvmOptions()).as("List.of(option1,option2)").containsExactly("option1", "option2"); - assertThat(compileOptions.args()).as("args(list)").containsExactly("-Joption1", "-Joption2"); - - compileOptions = compileOptions.jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED)); - assertThat(compileOptions.jvmOptions()).as("List.of(option1,option2,ALL_UNNAMED)") - .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"); - } -}