From 6305dd3de49b4cfa44f1a660c13a01773aa9a9af Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 27 Nov 2024 19:27:49 -0800 Subject: [PATCH 1/5] Bumped Kotlin to version 2.1.0 --- .github/workflows/bld.yml | 2 +- examples/src/bld/java/com/example/ExampleBuild.java | 2 +- scripts/checkcliargs.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 8fafac9..436605a 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: java-version: [17, 21, 23] - kotlin-version: [1.9.24, 2.0.21] + kotlin-version: [1.9.24, 2.0.21, 2.1.0] steps: - name: Checkout source repository diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index 993767b..c220c55 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -28,7 +28,7 @@ public class ExampleBuild extends Project { repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES); - final var kotlin = version(2, 0, 21); + final var kotlin = version(2, 1, 0); scope(compile) .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) diff --git a/scripts/checkcliargs.sh b/scripts/checkcliargs.sh index ef320da..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.0.0/bin/kotlinc -h 2>$old +~/.sdkman/candidates/kotlin/2.1.0/bin/kotlinc -h 2>$old code --diff --wait $old $new From 53df02fa71d3c34e9855160bc5bb402dcdd24c7f Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Thu, 28 Nov 2024 10:43:55 -0800 Subject: [PATCH 2/5] Don't use $KOTLIN_HOME if already manually set --- .../java/rife/bld/extension/CompileKotlinOperation.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 8143f5d..f2c0ecb 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -406,9 +406,11 @@ public class CompileKotlinOperation extends AbstractOperation Date: Thu, 28 Nov 2024 10:44:45 -0800 Subject: [PATCH 3/5] Added support for the -Wextra cli parameter --- .../bld/extension/kotlin/CompileOptions.java | 28 ++++++++++++++++++- .../extension/kotlin/CompileOptionsTest.java | 13 ++++++--- src/test/resources/kotlinc-args.txt | 1 + 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index 002a2e5..a108bdf 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java @@ -60,6 +60,7 @@ public class CompileOptions { private boolean progressive_; private boolean verbose_; private boolean wError_; + private boolean wExtra_; /** * Specify advanced compiler options. @@ -374,11 +375,16 @@ public class CompileOptions { args.add("-verbose"); } - // Werror + // Wwrror if (wError_) { args.add("-Werror"); } + // Wextra + if (wExtra_) { + args.add("-Wextra"); + } + // advanced option (X) if (!advancedOptions_.isEmpty()) { advancedOptions_.forEach(it -> args.add("-X" + it)); @@ -597,6 +603,15 @@ public class CompileOptions { return wError_; } + /** + * Indicates whether additional declaration, expression, and type compiler checks emit warnings. + * + * @return {@code true} or {@code false} + */ + public boolean isWExtra() { + return wExtra_; + } + /** * Generate metadata for Java 1.8 reflection on method parameters. * @@ -1071,4 +1086,15 @@ public class CompileOptions { wError_ = wError; return this; } + + /** + * Enable additional declaration, expression, and type compiler checks that emit warnings if {@code true}. + * + * @param wExtra {@code true} or {@code false} + * @return this operation instance + */ + public CompileOptions wExtra(boolean wExtra) { + wExtra_ = wExtra; + return this; + } } diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index 129ab44..3bc9e25 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -71,7 +71,8 @@ class CompileOptionsTest { .progressive(true) .scriptTemplates("name", "name2") .verbose(true) - .wError(true); + .wError(true) + .wExtra(true); var matches = List.of( "-api-version", "11", @@ -97,7 +98,8 @@ class CompileOptionsTest { "-progressive", "-script-templates", "name,name2", "-verbose", - "-Werror"); + "-Werror", + "-Wextra"); var args = new ArrayList>(); args.add(options.args()); @@ -234,7 +236,8 @@ class CompileOptionsTest { .progressive(true) .scriptTemplates("template") .verbose(true) - .wError(true); + .wError(true) + .wExtra(true); try (var softly = new AutoCloseableSoftAssertions()) { for (var p : args) { @@ -340,7 +343,8 @@ class CompileOptionsTest { .progressive(true) .scriptTemplates("name", "name2") .verbose(true) - .wError(true); + .wError(true) + .wExtra(true); try (var softly = new AutoCloseableSoftAssertions()) { softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2"); @@ -368,6 +372,7 @@ class CompileOptionsTest { softly.assertThat(options.plugin()).containsExactly("id:name:value"); softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2"); softly.assertThat(options.isWError()).isTrue(); + softly.assertThat(options.isWExtra()).isTrue(); } } } diff --git a/src/test/resources/kotlinc-args.txt b/src/test/resources/kotlinc-args.txt index b3c7f27..e764231 100644 --- a/src/test/resources/kotlinc-args.txt +++ b/src/test/resources/kotlinc-args.txt @@ -22,4 +22,5 @@ -script-templates -verbose -Werror +-Wextra -X From d658bcf0c46f7f843cc69a2947f58964571d53c6 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Thu, 28 Nov 2024 10:46:10 -0800 Subject: [PATCH 4/5] Enabled verbose compiling --- examples/src/bld/java/com/example/ExampleBuild.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index c220c55..83948b0 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -58,14 +58,11 @@ public class ExampleBuild extends Project { @Override public void compile() throws Exception { // The source code located in src/main/kotlin and src/test/kotlin will be compiled - new CompileKotlinOperation() - .fromProject(this) + var op = new CompileKotlinOperation() // .kotlinHome("path/to/kotlin") // .kotlinc("path/to/kotlinc") - .execute(); - -// var op = new CompileKotlinOperation().fromProject(this); -// op.compileOptions().verbose(true); -// op.execute(); + .fromProject(this); + op.compileOptions().verbose(true); + op.execute(); } } From fb793e254a7d4bc32919ded9a8072c896005bf1b Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Thu, 28 Nov 2024 10:58:51 -0800 Subject: [PATCH 5/5] Version 1.0.3 --- examples/lib/bld/bld-wrapper.properties | 2 +- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 28c5833..686fe3c 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.2 +bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.3 bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.1.0 diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 6a84505..157d16e 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -33,7 +33,7 @@ public class CompileKotlinOperationBuild extends Project { public CompileKotlinOperationBuild() { pkg = "rife.bld.extension"; name = "bld-kotlin"; - version = version(1, 0, 3, "SNAPSHOT"); + version = version(1, 0, 3); javaRelease = 17;