From 454ca225369606fccdd73e4e7a70c90eddba688b Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 28 Dec 2024 18:01:31 -0800 Subject: [PATCH 01/56] Bumped JUnit to version 5.11.4 --- examples/src/bld/java/com/example/ExampleBuild.java | 4 ++-- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index 83948b0..ab3fd8f 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -33,8 +33,8 @@ public class ExampleBuild extends Project { .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin)) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 3))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 3))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))); // Include the Kotlin source directory when creating or publishing sources Java Archives jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin")); diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 157d16e..ce12a4c 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -45,9 +45,9 @@ public class CompileKotlinOperationBuild extends Project { scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(2, 1, 0))); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 3))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 3))) .include(dependency("org.assertj", "assertj-core", version(3, 26, 3))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))) javadocOperation() .javadocOptions() From 0572b64aed88b240efe152a4129e6c52375bc093 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 28 Dec 2024 18:02:00 -0800 Subject: [PATCH 02/56] Bumped AssertJ to version 3.27.0 --- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index ce12a4c..ff46d6f 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -45,9 +45,9 @@ public class CompileKotlinOperationBuild extends Project { scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(2, 1, 0))); scope(test) - .include(dependency("org.assertj", "assertj-core", version(3, 26, 3))); .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))) + .include(dependency("org.assertj", "assertj-core", version(3, 27, 0))); javadocOperation() .javadocOptions() From 86d7351feca078c274ec7c6a170f9276216385ed Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 28 Dec 2024 18:02:20 -0800 Subject: [PATCH 03/56] Bumped PMD extension to version 1.1.9 --- lib/bld/bld-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index dde03d2..2dbabd0 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -4,7 +4,7 @@ bld.downloadLocation= bld.javaOptions= bld.javacOptions= bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.3 -bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.7 +bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.9 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.1.0 From 325599575c1db47d04bb20003298f6a29e3507e4 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 13 Jan 2025 08:20:00 -0800 Subject: [PATCH 04/56] Bumped AssertJ to version 3.27.2 --- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index ff46d6f..9f220d2 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -47,7 +47,7 @@ public class CompileKotlinOperationBuild extends Project { scope(test) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))) - .include(dependency("org.assertj", "assertj-core", version(3, 27, 0))); + .include(dependency("org.assertj", "assertj-core", version(3, 27, 2))); javadocOperation() .javadocOptions() From 0f6d190cc64d5175bcbd5f3c1cb3d106017036cb Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 13 Jan 2025 08:20:59 -0800 Subject: [PATCH 05/56] Bumped bld to version 2.2.0 --- .idea/libraries/bld.xml | 4 ++-- .vscode/settings.json | 2 +- README.md | 2 +- examples/.idea/libraries/bld.xml | 4 ++-- examples/.vscode/settings.json | 2 +- examples/lib/bld/bld-wrapper.jar | Bin 30440 -> 30440 bytes examples/lib/bld/bld-wrapper.properties | 2 +- lib/bld/bld-wrapper.jar | Bin 30440 -> 30440 bytes lib/bld/bld-wrapper.properties | 4 ++-- .../CompileKotlinOperationBuild.java | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml index 1d0172b..defcfad 100644 --- a/.idea/libraries/bld.xml +++ b/.idea/libraries/bld.xml @@ -2,12 +2,12 @@ - + - + diff --git a/.vscode/settings.json b/.vscode/settings.json index 4c33beb..a3f4fd0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,7 @@ ], "java.configuration.updateBuildConfiguration": "automatic", "java.project.referencedLibraries": [ - "${HOME}/.bld/dist/bld-2.1.0.jar", + "${HOME}/.bld/dist/bld-2.2.0.jar", "lib/**/*.jar" ] } diff --git a/README.md b/README.md index 51c5c98..72c9d31 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) [![Kotlin](https://img.shields.io/badge/kotlin-1.9.24%2B-7f52ff.svg)](https://kotlinlang.org) -[![bld](https://img.shields.io/badge/2.1.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) +[![bld](https://img.shields.io/badge/2.2.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) [![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-kotlin) [![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-kotlin) [![GitHub CI](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml) diff --git a/examples/.idea/libraries/bld.xml b/examples/.idea/libraries/bld.xml index 5c4010c..553c281 100644 --- a/examples/.idea/libraries/bld.xml +++ b/examples/.idea/libraries/bld.xml @@ -2,12 +2,12 @@ - + - + diff --git a/examples/.vscode/settings.json b/examples/.vscode/settings.json index 4c33beb..a3f4fd0 100644 --- a/examples/.vscode/settings.json +++ b/examples/.vscode/settings.json @@ -9,7 +9,7 @@ ], "java.configuration.updateBuildConfiguration": "automatic", "java.project.referencedLibraries": [ - "${HOME}/.bld/dist/bld-2.1.0.jar", + "${HOME}/.bld/dist/bld-2.2.0.jar", "lib/**/*.jar" ] } diff --git a/examples/lib/bld/bld-wrapper.jar b/examples/lib/bld/bld-wrapper.jar index 7d4c21542b4404a4f4284a4ea2bdb7039f17c0ac..dc7bcbd47d2f37074c90cbd27c8ac0d9309be233 100644 GIT binary patch delta 203 zcmaFymhr_~M!o=VW)=|!4h{~6?-RA7Ci2y?fas0=CN^NkqnshM0T=HiJZzMV+Mu*Z+4E3GxFi=3=9mcKpf!B$Rxsmuy1l+ qi4(-0EhQdc#-!3qnshM0T=HiJZzMV+Mu*Z+4E3GxFi=3=9mcKpf!B$Rxsmuy1l+ qi4(-0EhQdc#-!3 Date: Mon, 13 Jan 2025 08:22:01 -0800 Subject: [PATCH 06/56] Updated copyright for 2025 --- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 2 +- src/main/java/rife/bld/extension/CompileKotlinOperation.java | 2 +- src/main/java/rife/bld/extension/kotlin/CompileOptions.java | 2 +- src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java | 2 +- .../java/rife/bld/extension/CompileKotlinOperationTest.java | 2 +- src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 830524b..bf423e2 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * 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. diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index f2c0ecb..570ff14 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * 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. diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index a108bdf..19ecbf6 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * 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. diff --git a/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java index bbf3304..03d4382 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java +++ b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * 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. diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index efea216..f382ea5 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * 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. diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index 3bc9e25..df78097 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 the original author or authors. + * 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. From 316390264e1d539b4facfa3da6f09398c8e1d38c Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 13 Jan 2025 21:28:24 -0800 Subject: [PATCH 07/56] Fixed BaseProjectBlueprint initialization in tests --- .../rife/bld/extension/CompileKotlinOperationTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index f382ea5..9fffc25 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -86,7 +86,7 @@ class CompileKotlinOperationTest { @Test void testCollections() { var op = new CompileKotlinOperation() - .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example")) + .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example", "Example")) .kotlinHome("/kotlin_home") .kotlinc("kotlinc") .workDir("work_dir") @@ -167,8 +167,7 @@ class CompileKotlinOperationTest { } var op = new CompileKotlinOperation() - .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", - "Example")) + .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example", "Example")) .buildMainDirectory(mainDir) .buildTestDirectory(testDir) .compileMainClasspath(compileJars) @@ -208,7 +207,7 @@ class CompileKotlinOperationTest { @Test void testFromProjectNoKotlin() { var op = new CompileKotlinOperation().fromProject( - new BaseProjectBlueprint(new File("foo"), "org.example", "foo")); + new BaseProjectBlueprint(new File("foo"), "org.example", "foo", "foo")); assertThat(op.mainSourceDirectories()).isEmpty(); assertThat(op.testSourceDirectories()).isEmpty(); } From 5d66266fa9125d0558c2361160a0ee6068c7ac72 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 13 Jan 2025 21:41:44 -0800 Subject: [PATCH 08/56] Bumped bld-exec extension to version 1.0.4 --- lib/bld/bld-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 4912d7d..a6d0455 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -3,7 +3,7 @@ bld.downloadExtensionSources=true bld.downloadLocation= bld.javaOptions= bld.javacOptions= -bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.3 +bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.4 bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.10 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= From e1eb3950121faf05361319f658bf3ab1c07dec49 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 14 Jan 2025 11:49:10 -0800 Subject: [PATCH 09/56] Version 1.0.4 --- .idea/icon.svg | 13 +++++++++++++ examples/lib/bld/bld-wrapper.properties | 2 +- .../bld/extension/CompileKotlinOperationBuild.java | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .idea/icon.svg diff --git a/.idea/icon.svg b/.idea/icon.svg new file mode 100644 index 0000000..81220b4 --- /dev/null +++ b/.idea/icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 93fff81..f24155c 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.3 +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.0 diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index bf423e2..e12baeb 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); + version = version(1, 0, 4); javaRelease = 17; From 21744cf2c8d52acfd521a09989ca326167e45b78 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 27 Jan 2025 12:01:14 -0800 Subject: [PATCH 10/56] Bumped artifacts actions to latest versions --- .github/workflows/pages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 1e9f25d..e864e62 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -47,11 +47,11 @@ jobs: uses: actions/configure-pages@v3 - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v3 with: # Upload generated Javadocs repository path: "build/javadoc/" - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 + uses: actions/deploy-pages@v4 From b59f53ba8a1f5a7def02c0dd6a5f283253d0c8eb Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 27 Jan 2025 12:02:27 -0800 Subject: [PATCH 11/56] Bumped AssertJ to version 3.27.3 --- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index e12baeb..3d342b7 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -47,7 +47,7 @@ public class CompileKotlinOperationBuild extends Project { scope(test) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))) - .include(dependency("org.assertj", "assertj-core", version(3, 27, 2))); + .include(dependency("org.assertj", "assertj-core", version(3, 27, 3))); javadocOperation() .javadocOptions() From 00299f685c87cc6794657cfd794020ce2b6265f2 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 27 Jan 2025 12:04:42 -0800 Subject: [PATCH 12/56] Bumped Kotlin to version 2.1.10 --- examples/src/bld/java/com/example/ExampleBuild.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index ab3fd8f..c9c08f6 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, 1, 0); + final var kotlin = version(2, 1, 10); scope(compile) .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) From 8dda26e7efff7a873ddbf1812180ff99bc472ed7 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 27 Jan 2025 13:16:50 -0800 Subject: [PATCH 13/56] Version 1.0.5-SNAPSHOT --- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 3d342b7..917c77e 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, 4); + version = version(1, 0, 5, "SNAPSHOT"); javaRelease = 17; From 3a1ad6ae66156cfe0ae1b24afffd7519163d8dcb Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 27 Jan 2025 13:17:17 -0800 Subject: [PATCH 14/56] Bumped minimum Kotlin version to 1.9.25 --- .github/workflows/bld.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 436605a..1e33ed8 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, 2.1.0] + kotlin-version: [1.9.25, 2.0.21, 2.1.10] steps: - name: Checkout source repository diff --git a/README.md b/README.md index 72c9d31..eb19559 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) -[![Kotlin](https://img.shields.io/badge/kotlin-1.9.24%2B-7f52ff.svg)](https://kotlinlang.org) +[![Kotlin](https://img.shields.io/badge/kotlin-1.9.25%2B-7f52ff.svg)](https://kotlinlang.org) [![bld](https://img.shields.io/badge/2.2.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) [![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-kotlin) [![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-kotlin) @@ -66,7 +66,7 @@ public void compile() throws Exception { } ``` -While older version of Kotlin are likely working with the extension, only version 1.9.24 or higher are officially +While older version of Kotlin are likely working with the extension, only version 1.9.25 or higher are officially supported. ## Template Project From 80f00b41edc770beff87de3bd799b4951b958059 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 25 Feb 2025 09:41:47 -0800 Subject: [PATCH 15/56] Bump JUnit to version 5.12.0 --- examples/src/bld/java/com/example/ExampleBuild.java | 4 ++-- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index c9c08f6..a1abaeb 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -33,8 +33,8 @@ public class ExampleBuild extends Project { .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin)) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 0))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 0))); // Include the Kotlin source directory when creating or publishing sources Java Archives jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin")); diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 917c77e..f083e49 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -45,8 +45,8 @@ public class CompileKotlinOperationBuild extends Project { scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 0))); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 4))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 4))) + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 0))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 0))) .include(dependency("org.assertj", "assertj-core", version(3, 27, 3))); javadocOperation() From 048efcb810e77ab3b2a520be94bee412ae9a82fa Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 25 Feb 2025 09:43:06 -0800 Subject: [PATCH 16/56] Bump bld to version 2.2.1 --- .idea/libraries/bld.xml | 4 ++-- .vscode/settings.json | 2 +- README.md | 2 +- examples/.idea/libraries/bld.xml | 4 ++-- examples/.vscode/settings.json | 2 +- examples/lib/bld/bld-wrapper.jar | Bin 30440 -> 30440 bytes examples/lib/bld/bld-wrapper.properties | 2 +- lib/bld/bld-wrapper.jar | Bin 30440 -> 30440 bytes lib/bld/bld-wrapper.properties | 4 ++-- .../CompileKotlinOperationBuild.java | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml index defcfad..f9b1d1d 100644 --- a/.idea/libraries/bld.xml +++ b/.idea/libraries/bld.xml @@ -2,12 +2,12 @@ - + - + diff --git a/.vscode/settings.json b/.vscode/settings.json index a3f4fd0..ba429d0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,7 @@ ], "java.configuration.updateBuildConfiguration": "automatic", "java.project.referencedLibraries": [ - "${HOME}/.bld/dist/bld-2.2.0.jar", + "${HOME}/.bld/dist/bld-2.2.1.jar", "lib/**/*.jar" ] } diff --git a/README.md b/README.md index eb19559..4a6c681 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) [![Kotlin](https://img.shields.io/badge/kotlin-1.9.25%2B-7f52ff.svg)](https://kotlinlang.org) -[![bld](https://img.shields.io/badge/2.2.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) +[![bld](https://img.shields.io/badge/2.2.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) [![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-kotlin) [![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-kotlin) [![GitHub CI](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml) diff --git a/examples/.idea/libraries/bld.xml b/examples/.idea/libraries/bld.xml index 553c281..153a060 100644 --- a/examples/.idea/libraries/bld.xml +++ b/examples/.idea/libraries/bld.xml @@ -2,12 +2,12 @@ - + - + diff --git a/examples/.vscode/settings.json b/examples/.vscode/settings.json index a3f4fd0..ba429d0 100644 --- a/examples/.vscode/settings.json +++ b/examples/.vscode/settings.json @@ -9,7 +9,7 @@ ], "java.configuration.updateBuildConfiguration": "automatic", "java.project.referencedLibraries": [ - "${HOME}/.bld/dist/bld-2.2.0.jar", + "${HOME}/.bld/dist/bld-2.2.1.jar", "lib/**/*.jar" ] } diff --git a/examples/lib/bld/bld-wrapper.jar b/examples/lib/bld/bld-wrapper.jar index dc7bcbd47d2f37074c90cbd27c8ac0d9309be233..06cf59e526710cd47bd3596385585ca3bc7895c0 100644 GIT binary patch delta 187 zcmaFymhr_~M&1B#W)=|!4h{|m#mx~DdFz;g)W$wj8xTFY*Isk;dz;xzAkOAq`)&wB z+KF8cETUR)o)OIWUT6rGnyg)-sK~+);LXk<_eVm3oq>UY6^H}88JR>F;I>T8EpY}L ozq!N{O#d$l0n=fn5PEH?E13VaG!7zO=Fb6iK@`Z$$!p830a^+>!2kdN delta 187 zcmaFymhr_~M&1B#W)=|!4h{~6?-R8r^42i}sf~T6HXwR(uf68x_cpVcK%C9J_T3PM zv=h4?SVXnpJR_L#z0eRWHCekvQIUZmz?+?;A60|0+jMI8VD diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index f24155c..1ffe3ff 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -4,4 +4,4 @@ bld.downloadLocation= 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.0 +bld.version=2.2.1 diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar index 21f7c760951d8a51d201868ff605dbca595b6ecf..d7879ebf9d9b9d960f5306cc3bc01ca1754f375d 100644 GIT binary patch delta 187 zcmaFymhr_~M&1B#W)=|!4h{|mh0PHYdFz;g)W$wj8xTFY*Isk;dz;xzAkOAq`)&wB z+KF8cETUR)o)OIWUT6rGnyg)-sK~+);LXk<_eVm3oq>UY6^H}88JR>F;I>T8EpY}L ozq!N{O#d$l0n=fn5PEH?E13VaG!7zO=Fb6iK@`Z$$!p830aSK7u>b%7 delta 187 zcmaFymhr_~M&1B#W)=|!4h{~6ZxgjA^42i}sf~T6HXwR(uf68x_cpVcK%C9J_T3PM zv=h4?SVXnpJR_L#z0eRWHCekvQIUZmz?+?;A60|0r!MGXJ| diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index a6d0455..2c9a12b 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -4,7 +4,7 @@ bld.downloadLocation= bld.javaOptions= bld.javacOptions= bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.4 -bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.10 +bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.0 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= -bld.version=2.2.0 +bld.version=2.2.1 diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index f083e49..2a8112f 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -43,7 +43,7 @@ public class CompileKotlinOperationBuild extends Project { repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS); scope(compile) - .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 0))); + .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1))); scope(test) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 0))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 0))) From 323f96b54bec189f867764857dcfeae4291188f9 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 18 Mar 2025 04:17:48 -0700 Subject: [PATCH 17/56] Bump PMD extension to version 1.2.1 --- lib/bld/bld-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 2c9a12b..b23895b 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -4,7 +4,7 @@ bld.downloadLocation= bld.javaOptions= bld.javacOptions= bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.4 -bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.0 +bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.1 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.2.1 From 0f6385e3f3a34dfcd831be272e9fd3cebf9fe127 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 18 Mar 2025 04:18:20 -0700 Subject: [PATCH 18/56] Bump JUnit to version 5.12.1 --- examples/src/bld/java/com/example/ExampleBuild.java | 5 +++-- .../java/rife/bld/extension/CompileKotlinOperationBuild.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index a1abaeb..c3bf9b0 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -33,8 +33,9 @@ public class ExampleBuild extends Project { .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin)) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 0))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 0))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1))) + .include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 1))); // Include the Kotlin source directory when creating or publishing sources Java Archives jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin")); diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 2a8112f..749beb1 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -45,8 +45,8 @@ public class CompileKotlinOperationBuild extends Project { scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1))); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 0))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 0))) + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1))) .include(dependency("org.assertj", "assertj-core", version(3, 27, 3))); javadocOperation() From d8c10499909f25eb9eaf0204a3c01dbc0d979f8d Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 18 Mar 2025 12:30:20 -0700 Subject: [PATCH 19/56] Add generic installation instructions --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4a6c681..d0d0ff9 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,17 @@ [![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-kotlin/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-kotlin) [![GitHub CI](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml) -To install, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) -and [support](https://github.com/rife2/bld/wiki/Kotlin-Support) -documentation. +To install the latest version, add the following to the `lib/bld/bld-wrapper.properties` file: + +```properties +bld.extension-kotlin=com.uwyn.rife2:bld-kotlin +``` + +For more information, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) and [support](https://github.com/rife2/bld/wiki/Kotlin-Support) documentation. ## Compile Kotlin Source Code -To compile the source code located in `src/main/kotlin` and `src/test/kotlin` from the current project: +To compile the source code located in `src/main/kotlin` and `src/test/kotlin` from the current project add the following to the build file: ```java From 31e4208d7ff35098dc92fe1db822e4a2f479db45 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 18 Mar 2025 23:37:48 -0700 Subject: [PATCH 20/56] JDK 24 --- .github/workflows/bld.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 1e33ed8..cb23afa 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - java-version: [17, 21, 23] + java-version: [17, 21, 24] kotlin-version: [1.9.25, 2.0.21, 2.1.10] steps: From 48c896f0dfdcabb4f03571ecc6403faf919ac2f5 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 18 Mar 2025 23:37:48 -0700 Subject: [PATCH 21/56] Bump Kotlin to version 2.1.20 --- .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 cb23afa..d01b562 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.10] + kotlin-version: [1.9.25, 2.0.21, 2.1.20] 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 c3bf9b0..556678a 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, 1, 10); + final var kotlin = version(2, 1, 20); scope(compile) .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) diff --git a/scripts/checkcliargs.sh b/scripts/checkcliargs.sh index 30c8537..94313ab 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.0/bin/kotlinc -h 2>$old +~/.sdkman/candidates/kotlin/2.1.10/bin/kotlinc -h 2>$old code --diff --wait $old $new From 832447771dd41397a01e2cb3d7d61e92f012dc91 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 00:47:42 -0700 Subject: [PATCH 22/56] Add Compose and Imports Dumper compiler plugins --- src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java index 03d4382..f1fd584 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java +++ b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java @@ -17,6 +17,7 @@ package rife.bld.extension.kotlin; /** + * @author Erik C. Thauvin * Defines the known Kotlin compiler plugin JARs. * * @author Erik C. Thauvin @@ -25,6 +26,8 @@ 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"), From 3c5b1fde8f2b39c721effa9a00a98160ef6fa45e Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 00:58:41 -0700 Subject: [PATCH 23/56] Implement JvmOptions class --- examples/lib/bld/bld-wrapper.properties | 2 +- .../bld/java/com/example/ExampleBuild.java | 12 ++-- .../bld/extension/kotlin/CompileOptions.java | 8 +-- .../rife/bld/extension/kotlin/JvmOptions.java | 61 ++++++++++++++++++ .../extension/CompileKotlinOperationTest.java | 4 +- .../bld/extension/kotlin/JvmOptionsTest.java | 63 +++++++++++++++++++ 6 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 src/main/java/rife/bld/extension/kotlin/JvmOptions.java create mode 100644 src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 1ffe3ff..29786b7 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.4 +bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.5-SNAPSHOT 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 556678a..cd44399 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -3,6 +3,8 @@ 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; @@ -58,12 +60,14 @@ 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 - var op = new CompileKotlinOperation() + new CompileKotlinOperation() // .kotlinHome("path/to/kotlin") // .kotlinc("path/to/kotlinc") - .fromProject(this); - op.compileOptions().verbose(true); - op.execute(); + .compileOptions(options) + .fromProject(this) + .execute(); } } diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index 19ecbf6..30f0a4e 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 Collection jvmOptions_ = new ArrayList<>(); + private final JvmOptions jvmOptions_ = new JvmOptions(); 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 Collection jvmOptions() { + public JvmOptions jvmOptions() { return jvmOptions_; } /** - * Pass an option directly to Java Virtual Machine + * Pass an option directly to the Java Virtual Machine * * @param jvmOptions the JVM options * @return this operation instance @@ -725,7 +725,7 @@ public class CompileOptions { } /** - * Pass an option directly to JVM + * Pass an option directly to the Java Virtual Machine * * @param jvmOptions one or more JVM option * @return this operation instance diff --git a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java new file mode 100644 index 0000000..b050b83 --- /dev/null +++ b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java @@ -0,0 +1,61 @@ +/* + * 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 9fffc25..1689525 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -23,6 +23,7 @@ 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; @@ -177,9 +178,10 @@ 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", "-no-stdlib", "-verbose"); + var matches = List.of("-Xjdk-release=17", "-J--enable-native-access=ALL-UNNAMED", "-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 new file mode 100644 index 0000000..eb2d59a --- /dev/null +++ b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java @@ -0,0 +1,63 @@ +/* + * 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"); + } +} From 779e6d4b791ed4d87045ef9e4d1cf21f8036957c Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 01:32:03 -0700 Subject: [PATCH 24/56] Change List to Collection --- src/main/java/rife/bld/extension/kotlin/JvmOptions.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java index b050b83..4c46989 100644 --- a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java @@ -20,6 +20,7 @@ import rife.tools.StringUtils; import java.io.Serial; import java.util.ArrayList; +import java.util.Collection; import java.util.List; /** @@ -54,7 +55,7 @@ public class JvmOptions extends ArrayList { * * @return this list of options */ - public JvmOptions enableNativeAccess(List modules) { + public JvmOptions enableNativeAccess(Collection modules) { add("--enable-native-access=" + StringUtils.join(modules, ",")); return this; } From 5ca06f4d819b69a5b15e97b19153b2fcbe6e9103 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 11:29:44 -0700 Subject: [PATCH 25/56] Add support for illegal native access modes --- .../rife/bld/extension/kotlin/JvmOptions.java | 34 +++++++++++++++++-- .../bld/extension/kotlin/JvmOptionsTest.java | 26 +++++++++++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java index 4c46989..926c6e7 100644 --- a/src/main/java/rife/bld/extension/kotlin/JvmOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/JvmOptions.java @@ -31,18 +31,19 @@ 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) { @@ -53,10 +54,37 @@ 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/kotlin/JvmOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java index eb2d59a..0dcfbef 100644 --- a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java @@ -27,7 +27,8 @@ 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")); @@ -40,10 +41,25 @@ 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"); @@ -59,5 +75,13 @@ 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"); } } From 54228e314920426fbc8e800e4f6d723a557c5b9d Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 11:35:12 -0700 Subject: [PATCH 26/56] Add tests for new compiler plugins --- .idea/misc.xml | 2 ++ .../rife/bld/extension/CompileKotlinOperationTest.java | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index ea8d1e3..593e427 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -9,6 +9,8 @@ + + diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index 1689525..2c9032d 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -104,9 +104,10 @@ 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) + .plugins(CompilerPlugin.KOTLIN_SERIALIZATION, CompilerPlugin.ASSIGNMENT, CompilerPlugin.COMPOSE) .plugins(new File("lib/compile"), CompilerPlugin.LOMBOK, CompilerPlugin.POWER_ASSERT) - .plugins(Path.of("lib/compile"), CompilerPlugin.NOARG, CompilerPlugin.ALL_OPEN) + .plugins(Path.of("lib/compile"), CompilerPlugin.NOARG, CompilerPlugin.ALL_OPEN, + CompilerPlugin.KOTLIN_IMPORTS_DUMPER) .plugins("lib/compile", CompilerPlugin.KOTLINX_SERIALIZATION, CompilerPlugin.SAM_WITH_RECEIVER) .plugins(List.of("plugin3", "plugin4")); @@ -134,10 +135,12 @@ 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()); } @@ -315,6 +318,8 @@ 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, From 9fcc5cc3628a448f092da3454e3fdca0d03a0f50 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 13:22:16 -0700 Subject: [PATCH 27/56] Add test for fromProject() using the examples project --- .idea/runConfigurations/Run Tests.xml | 9 --------- .../rife/bld/extension/CompileKotlinOperationTest.java | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 .idea/runConfigurations/Run Tests.xml diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml deleted file mode 100644 index 057a90e..0000000 --- a/.idea/runConfigurations/Run Tests.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index 2c9032d..337b3a7 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -209,6 +209,15 @@ class CompileKotlinOperationTest { } } + @Test + void testFromProject() { + var examples = new File("examples"); + var op = new CompileKotlinOperation().fromProject( + new BaseProjectBlueprint(examples, "com.example", "examples", "examples")); + assertThat(op.mainSourceDirectories()).contains(new File(examples, "src/main/kotlin")); + assertThat(op.testSourceDirectories()).contains(new File(examples, "src/test/kotlin")); + } + @Test void testFromProjectNoKotlin() { var op = new CompileKotlinOperation().fromProject( From a57ae52a1c6b696304e3985ceb9f3c6a0e41cf07 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 21:08:13 -0700 Subject: [PATCH 28/56] Add method to locate the Kotlin compiler in common locations --- README.md | 8 + .../bld/extension/CompileKotlinOperation.java | 185 +++++++++++++++--- .../extension/CompileKotlinOperationTest.java | 21 ++ .../extension/kotlin/CompileOptionsTest.java | 1 - 4 files changed, 189 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d0d0ff9..06ce2cb 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,14 @@ for all available configuration options. Please make sure the Kotlin compiler is [installed](https://kotlinlang.org/docs/command-line.html#install-the-compiler). +The plugin will look in common locations such as: +- `KOTLIN_HOME` +- `PATH` +- SDKMAN! +- Homebrew +- JetBrains Toolbox (IntelliJ IDEA, Android Studio) +- etc. + You can also manually configure the Kotlin home location as follows: ```java diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 570ff14..f1c912b 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -26,9 +26,7 @@ import rife.tools.FileUtils; import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -40,6 +38,9 @@ import java.util.logging.Logger; */ public class CompileKotlinOperation extends AbstractOperation { private static final Logger LOGGER = Logger.getLogger(CompileKotlinOperation.class.getName()); + private static final String OS_NAME = + System.getProperty("os.name") != null ? System.getProperty("os.name").toLowerCase(Locale.US) : null; + private static final String KOTLINC_EXECUTABLE = "kotlinc" + (isWindows() ? ".bat" : ""); private final Collection compileMainClasspath_ = new ArrayList<>(); private final Collection compileTestClasspath_ = new ArrayList<>(); private final Collection mainSourceDirectories_ = new ArrayList<>(); @@ -55,6 +56,145 @@ public class CompileKotlinOperation extends AbstractOperation commonPaths = new ArrayList<>(); + + if (isLinux()) { + commonPaths.add("/usr/bin"); + commonPaths.add("/usr/local/bin"); + commonPaths.add("/usr/local/kotlin/bin"); + commonPaths.add("/opt/kotlin/bin"); + var userHome = System.getProperty("user.home"); + if (userHome != null) { + commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN! + commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/plugins/Kotlin/bin"); // Toolbox IDEA Ultimate + commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/bin"); // Toolbox IDEA CE + commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/android-studio/plugins/Kotlin/bin"); // Toolbox Android Studio + } + } else if (isWindows()) { + var localAppData = System.getenv("LOCALAPPDATA"); + if (localAppData != null) { + commonPaths.add(localAppData + "\\Programs\\IntelliJ IDEA Ultimate\\plugins\\Kotlin\\kotlinc\\bin"); // Toolbox IDEA Ultimate + commonPaths.add(localAppData + "\\Programs\\IntelliJ IDEA Community Edition\\plugins\\Kotlin\\kotlinc\\bin"); // Toolbox IDEA CE + commonPaths.add(localAppData + "\\Programs\\Android Studio\\plugins\\Kotlin\\kotlinc\\bin"); // Toolbox Android Studio + } + var programFiles = System.getenv("ProgramFiles"); + if (programFiles != null) { + commonPaths.add(programFiles + File.separator + "Kotlin"); + } + } else if (isMacOS()) { + commonPaths.add("/usr/local/bin"); // Homebrew + commonPaths.add("/opt/homebrew/bin"); // Homebrew + var userHome = System.getProperty("user.home"); + if (userHome != null) { + commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN! + } + commonPaths.add("/Applications/IntelliJ IDEA Ultimate.app/Contents/plugins/Kotlin/bin"); //IntelliJ IDEA Ultimate + commonPaths.add("/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/bin"); //IntelliJ IDEA + commonPaths.add("/Applications/Android Studio.app/Contents/plugins/Kotlin/bin"); //Android Studio + } + + for (var location : commonPaths) { + kotlincPath = findKotlincInDir(location); + if (kotlincPath != null) { + return kotlincPath; + } + } + + // Try 'which' or 'where' commands (less reliable but sometimes works) + try { + Process process; + if (isWindows()) { + process = Runtime.getRuntime().exec("where kotlinc"); + } else { + process = Runtime.getRuntime().exec("which kotlinc"); + } + + try (var scanner = new Scanner(process.getInputStream())) { + if (scanner.hasNextLine()) { + kotlincPath = scanner.nextLine().trim(); + if (isExecutable(new File(kotlincPath))) { + return kotlincPath; + } + } + } + } catch (Exception ignored) { + // Ignore exceptions from which/where, as they might not be available + } + + return KOTLINC_EXECUTABLE; + } + + private static boolean isExecutable(File file) { + return file != null && file.exists() && file.isFile() && file.canExecute(); + } + + /** + * Determines if the operating system is Linux. + * + * @return true if the operating system is Linux, false otherwise. + */ + public static boolean isLinux() { + return OS_NAME != null && (OS_NAME.contains("linux") || OS_NAME.contains("unix")); // Consider Unix-like systems as well. + } + + /** + * Determines if the current operating system is macOS. + * + * @return true if the OS is macOS, false otherwise. + */ + public static boolean isMacOS() { + return OS_NAME != null && (OS_NAME.contains("mac") || OS_NAME.contains("darwin")); + } + /** * Determines if the given string is not blank. * @@ -65,6 +205,15 @@ public class CompileKotlinOperation extends AbstractOperation(); // kotlinc - args.add(kotlinCompiler()); + if (kotlinc_ != null) { + args.add(kotlinc_.getAbsolutePath()); + } else if (kotlinHome_ != null) { + args.add(Objects.requireNonNullElseGet(findKotlincInDir(kotlinHome_.getAbsolutePath()), + CompileKotlinOperation::findKotlincPath)); + } else { + args.add(findKotlincPath()); + } // classpath if (classpath != null && !classpath.isEmpty()) { @@ -386,7 +542,6 @@ public class CompileKotlinOperation extends AbstractOperation * Sets the following from the project: *
    - *
  • {@link #kotlinHome() kotlinHome} to the {@code KOTLIN_HOME} environment variable, if set.
  • *
  • {@link #workDir() workDir} to the project's directory.
  • *
  • {@link #buildMainDirectory() buildMainDirectory}
  • *
  • {@link #buildTestDirectory() buildTestDirectory}
  • @@ -405,14 +560,6 @@ public class CompileKotlinOperation extends AbstractOperation Date: Fri, 21 Mar 2025 21:24:44 -0700 Subject: [PATCH 29/56] Reorder the common kotlin compiler potential locations --- README.md | 15 ++++++++------- .../bld/extension/CompileKotlinOperation.java | 16 ++++++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 06ce2cb..0c15334 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,14 @@ for all available configuration options. Please make sure the Kotlin compiler is [installed](https://kotlinlang.org/docs/command-line.html#install-the-compiler). -The plugin will look in common locations such as: -- `KOTLIN_HOME` -- `PATH` -- SDKMAN! -- Homebrew -- JetBrains Toolbox (IntelliJ IDEA, Android Studio) -- etc. +The extension will look in common locations such as: + + - `KOTLIN_HOME` + - `PATH` + - [SDKMAN!](https://sdkman.io/) + - [Homebrew](https://brew.sh/) + - [JetBrains Toolbox](https://www.jetbrains.com/toolbox-app/) (IntelliJ IDEA, Android Studio) + - etc. You can also manually configure the Kotlin home location as follows: diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index f1c912b..2fd3e31 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -79,6 +79,7 @@ public class CompileKotlinOperation extends AbstractOperation commonPaths = new ArrayList<>(); if (isLinux()) { - commonPaths.add("/usr/bin"); - commonPaths.add("/usr/local/bin"); - commonPaths.add("/usr/local/kotlin/bin"); - commonPaths.add("/opt/kotlin/bin"); var userHome = System.getProperty("user.home"); if (userHome != null) { commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN! @@ -119,6 +116,10 @@ public class CompileKotlinOperation extends AbstractOperation Date: Fri, 21 Mar 2025 21:29:04 -0700 Subject: [PATCH 30/56] 1.1.0-SNAPSHOT --- examples/lib/bld/bld-wrapper.properties | 2 +- .../rife/bld/extension/CompileKotlinOperationBuild.java | 2 +- .../java/rife/bld/extension/CompileKotlinOperation.java | 8 ++++---- src/main/java/rife/bld/extension/kotlin/JvmOptions.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 29786b7..1f1009d 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.1.0-SNAPSHOT bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.2.1 diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 749beb1..a3adce1 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, 5, "SNAPSHOT"); + version = version(1, 1, 0, "SNAPSHOT"); javaRelease = 17; diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 2fd3e31..e754164 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -79,7 +79,7 @@ public class CompileKotlinOperation extends AbstractOperationErik C. Thauvin - * @since 1.0.5 + * @since 1.1.0 */ @SuppressWarnings("PMD.LooseCoupling") public class JvmOptions extends ArrayList { From a21938f7b5c1ab5a0febc4ba306d23b79087237d Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Mar 2025 23:15:20 -0700 Subject: [PATCH 31/56] Log the Kotlin compiler location when found --- .../bld/extension/CompileKotlinOperation.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index e754164..121923d 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -82,6 +82,17 @@ public class CompileKotlinOperation extends AbstractOperation Date: Sat, 22 Mar 2025 10:16:18 -0700 Subject: [PATCH 32/56] Cleanup Kotlin common paths --- .../rife/bld/extension/CompileKotlinOperation.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 121923d..64aabff 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -123,13 +123,14 @@ public class CompileKotlinOperation extends AbstractOperation Date: Sun, 23 Mar 2025 02:18:31 -0700 Subject: [PATCH 33/56] Move jvmOptions to main compile operation --- .../bld/java/com/example/ExampleBuild.java | 15 +++++--- .../bld/extension/CompileKotlinOperation.java | 36 ++++++++++++++++++ .../bld/extension/kotlin/CompileOptions.java | 36 ------------------ .../extension/CompileKotlinOperationTest.java | 8 +++- .../extension/kotlin/CompileOptionsTest.java | 5 --- .../bld/extension/kotlin/JvmOptionsTest.java | 37 +++++++------------ 6 files changed, 65 insertions(+), 72 deletions(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index cd44399..87cc83a 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -60,14 +60,17 @@ 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(); + .compileOptions(new CompileOptions().verbose(true)) + .fromProject(this); + + if (!CompileKotlinOperation.isWindows()) { + op.jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); + } + + op.execute(); } } diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 64aabff..c093bdd 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -19,6 +19,7 @@ package rife.bld.extension; import rife.bld.BaseProject; import rife.bld.extension.kotlin.CompileOptions; import rife.bld.extension.kotlin.CompilerPlugin; +import rife.bld.extension.kotlin.JvmOptions; import rife.bld.operations.AbstractOperation; import rife.bld.operations.exceptions.ExitStatusException; import rife.tools.FileUtils; @@ -43,6 +44,7 @@ public class CompileKotlinOperation extends AbstractOperation compileMainClasspath_ = new ArrayList<>(); private final Collection compileTestClasspath_ = new ArrayList<>(); + private final JvmOptions jvmOptions_ = new JvmOptions(); private final Collection mainSourceDirectories_ = new ArrayList<>(); private final Collection mainSourceFiles_ = new ArrayList<>(); private final Collection plugins_ = new ArrayList<>(); @@ -479,6 +481,10 @@ public class CompileKotlinOperation extends AbstractOperation command.add("-J" + s)); + } // classpath if (classpath != null && !classpath.isEmpty()) { @@ -607,6 +613,36 @@ public class CompileKotlinOperation extends AbstractOperation jvmOptions) { + jvmOptions_.addAll(jvmOptions); + return this; + } + + /** + * Pass an option directly to the Java Virtual Machine + * + * @param jvmOptions one or more JVM option + * @return this operation instance + */ + public CompileKotlinOperation jvmOptions(String... jvmOptions) { + return jvmOptions(List.of(jvmOptions)); + } + /** * Provides the Kotlin home directory, if it differs from the default {@code KOTLIN_HOME}. * diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index 30f0a4e..6c9382c 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java @@ -37,7 +37,6 @@ 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 optIn_ = new ArrayList<>(); private final Collection options_ = new ArrayList<>(); private final Collection plugin_ = new ArrayList<>(); @@ -293,11 +292,6 @@ public class CompileOptions { args.add("-Xjdk-release=" + jdkRelease_); } - // JVM options - if (!jvmOptions_.isEmpty()) { - jvmOptions_.forEach(s -> args.add("-J" + s)); - } - // kotlin-home if (kotlinHome_ != null) { args.add("-kotlin-home"); @@ -704,36 +698,6 @@ public class CompileOptions { return jdkRelease(String.valueOf(version)); } - /** - * Retrieves the Java Virtual Machine options. - * - * @return the JVM options - */ - public JvmOptions jvmOptions() { - return jvmOptions_; - } - - /** - * Pass an option directly to the Java Virtual Machine - * - * @param jvmOptions the JVM options - * @return this operation instance - */ - public CompileOptions jvmOptions(Collection jvmOptions) { - jvmOptions_.addAll(jvmOptions); - return this; - } - - /** - * Pass an option directly to the Java Virtual Machine - * - * @param jvmOptions one or more JVM option - * @return this operation instance - */ - public CompileOptions jvmOptions(String... jvmOptions) { - return jvmOptions(List.of(jvmOptions)); - } - /** * Specify the target version of the generated JVM bytecode. * diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index 0c33df0..e077341 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -182,10 +182,14 @@ class CompileKotlinOperationTest { op.compileOptions().verbose(true); op.compileOptions().jdkRelease("17"); - op.compileOptions().jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); + + if (!CompileKotlinOperation.isWindows()) { + op.jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); + assertThat(op.jvmOptions()).containsExactly("--enable-native-access=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/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index cdabf36..eaf2f44 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -117,7 +117,6 @@ class CompileOptionsTest { var advanceOptions = List.of("Xoption1", "Xoption2"); var argFile = List.of(new File("arg1.txt"), new File("arg2.txt")); var classpath = List.of(new File("path1"), new File("path2")); - var jvmOptions = List.of("option1", "option2"); var optIn = List.of("opt1", "opt2"); var options = List.of("-foo", "-bar"); var plugin = List.of("id:name:value", "id2:name2:value2"); @@ -127,7 +126,6 @@ class CompileOptionsTest { .advancedOptions(advanceOptions) .argFile(argFile) .classpath(classpath) - .jvmOptions(jvmOptions) .noStdLib(false) .optIn(optIn) .options(options) @@ -145,8 +143,6 @@ class CompileOptionsTest { .hasSize(argFile.size()).containsAll(argFile); softly.assertThat(op.classpath()).as("classpath") .hasSize(classpath.size()).containsAll(classpath); - softly.assertThat(op.jvmOptions()).as("jvmOptions") - .hasSize(jvmOptions.size()).containsAll(jvmOptions); softly.assertThat(op.optIn()).as("optIn") .hasSize(optIn.size()).containsAll(optIn); softly.assertThat(op.options()).as("options") @@ -216,7 +212,6 @@ class CompileOptionsTest { .argFile("file") .classpath("classpath") .expression("expression") - .jvmOptions("option") .includeRuntime(true) .javaParameters(true) .jdkHome("jdkhome") diff --git a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java index 0dcfbef..6f8474f 100644 --- a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java @@ -17,6 +17,7 @@ package rife.bld.extension.kotlin; import org.junit.jupiter.api.Test; +import rife.bld.extension.CompileKotlinOperation; import java.util.List; @@ -25,15 +26,12 @@ 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"); + void testop() { + var op = new CompileKotlinOperation().jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED)); + assertThat(op.jvmOptions()).as(JvmOptions.ALL_UNNAMED).containsExactly("--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"); + op = new CompileKotlinOperation().jvmOptions(new JvmOptions().enableNativeAccess("m1", "m2")); + assertThat(op.jvmOptions()).as("m1,m2").containsExactly("--enable-native-access=m1,m2"); } @Test @@ -62,26 +60,19 @@ class JvmOptionsTest { @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"); + var op = new CompileKotlinOperation().jvmOptions("option1", "option2"); + assertThat(op.jvmOptions()).as("option1,option2").containsExactly("option1", "option2"); - 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"); + op = new CompileKotlinOperation().jvmOptions(List.of("option1", "option2")); + assertThat(op.jvmOptions()).as("List.of(option1,option2)").containsExactly("option1", "option2"); - compileOptions = compileOptions.jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED)); - assertThat(compileOptions.jvmOptions()).as("List.of(option1,option2,ALL_UNNAMED)") + op = op.jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED)); + assertThat(op.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"); - compileOptions = compileOptions.jvmOptions(new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW)); - assertThat(compileOptions.jvmOptions()).as("allow") + op = op.jvmOptions(new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW)); + assertThat(op.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"); } } From b0d6a3ac3b63c769c4bd9be1036302056306ccaf Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 02:30:17 -0700 Subject: [PATCH 34/56] Pass arguments to kotlinc via @argfile --- .../bld/extension/CompileKotlinOperation.java | 73 ++++++++++++++----- .../bld/extension/kotlin/CompileOptions.java | 8 -- .../extension/CompileKotlinOperationTest.java | 4 +- .../extension/kotlin/CompileOptionsTest.java | 7 +- 4 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index c093bdd..8f7372e 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -26,6 +26,7 @@ import rife.tools.FileUtils; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.util.logging.Level; @@ -319,6 +320,17 @@ public class CompileKotlinOperation extends AbstractOperation classpath, Collection sources, File destination, File friendPaths) throws ExitStatusException { + + var cp = new ArrayList(); + if (classpath != null && !classpath.isEmpty()) { + cp.addAll(classpath); + } + if (sources.isEmpty()) { if (!silent() && LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Nothing to compile."); @@ -470,60 +488,75 @@ public class CompileKotlinOperation extends AbstractOperation(); var args = new ArrayList(); // kotlinc if (kotlinc_ != null) { - args.add(kotlinc_.getAbsolutePath()); + command.add(kotlinc_.getAbsolutePath()); } else if (kotlinHome_ != null) { - args.add(Objects.requireNonNullElseGet(findKotlincInDir(kotlinHome_.getAbsolutePath()), + command.add(Objects.requireNonNullElseGet(findKotlincInDir(kotlinHome_.getAbsolutePath()), CompileKotlinOperation::findKotlincPath)); } else { - args.add(findKotlincPath(silent())); + command.add(findKotlincPath(silent())); } + // JVM options if (!jvmOptions_.isEmpty()) { jvmOptions_.forEach(s -> command.add("-J" + s)); } + // compiler options + if (compileOptions_ != null) { + args.addAll(compileOptions_.args()); + cp.addAll(compileOptions_.classpath().stream().map(this::cleanPath).toList()); + } + // classpath - if (classpath != null && !classpath.isEmpty()) { + if (!cp.isEmpty()) { args.add("-cp"); - args.add(FileUtils.joinPaths(classpath.stream().toList())); + args.add('"' + FileUtils.joinPaths(cp.stream().map(this::cleanPath).toList()) + '"'); } // destination args.add("-d"); - args.add(destination.getAbsolutePath()); + args.add('"' + cleanPath(destination) + '"'); // friend-path if (friendPaths != null && friendPaths.exists()) { - args.add("-Xfriend-paths=" + friendPaths.getAbsolutePath()); - } - - // options - if (compileOptions_ != null) { - args.addAll(compileOptions_.args()); + args.add("-Xfriend-paths=\"" + cleanPath(friendPaths) + '"'); } // plugins if (!plugins_.isEmpty()) { - plugins_.forEach(p -> args.add("-Xplugin=" + p)); + plugins_.forEach(p -> args.add("-Xplugin=\"" + cleanPath(p) + '"')); } // sources - sources.forEach(f -> args.add(f.getAbsolutePath())); + sources.forEach(f -> args.add('"' + cleanPath(f) + '"')); + var argsLine = String.join(" ", args); + + // log the command line if (LOGGER.isLoggable(Level.FINE) && !silent()) { - LOGGER.fine(String.join(" ", args)); + LOGGER.fine(String.join(" ", command) + " " + argsLine); } - var pb = new ProcessBuilder(); - pb.inheritIO(); - pb.command(args); - pb.directory(workDir_); - try { + // create and write the @argfile + var argsFile = File.createTempFile("bld-kotlinc-", ".args"); + argsFile.deleteOnExit(); + + Files.write(argsFile.toPath(), argsLine.getBytes()); + + command.add("@" + argsFile.getAbsolutePath()); + + // run the command + var pb = new ProcessBuilder(); + pb.inheritIO(); + pb.command(command); + pb.directory(workDir_); + var proc = pb.start(); proc.waitFor(); ExitStatusException.throwOnFailure(proc.exitValue()); diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index 6c9382c..3e0e8bf 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java @@ -23,7 +23,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import static rife.bld.extension.CompileKotlinOperation.isNotBlank; @@ -111,7 +110,6 @@ public class CompileOptions { return this; } - /** * Allow using declarations only from the specified version of Kotlin bundled libraries. * @@ -253,12 +251,6 @@ public class CompileOptions { argFile_.forEach(f -> args.add("@" + f.getAbsolutePath())); } - // classpath - if (!classpath_.isEmpty()) { - args.add("-classpath"); - args.add(classpath_.stream().map(File::getAbsolutePath).collect(Collectors.joining(File.pathSeparator))); - } - // expression if (isNotBlank(expression_)) { args.add("-expression"); diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index e077341..fc8aab2 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -224,8 +224,8 @@ class CompileKotlinOperationTest { var examples = new File("examples"); var op = new CompileKotlinOperation().fromProject( new BaseProjectBlueprint(examples, "com.example", "examples", "examples")); - assertThat(op.mainSourceDirectories()).contains(new File(examples, "src/main/kotlin")); - assertThat(op.testSourceDirectories()).contains(new File(examples, "src/test/kotlin")); + assertThat(op.mainSourceDirectories()).containsExactly(new File(examples, "src/main/kotlin")); + assertThat(op.testSourceDirectories()).containsExactly(new File(examples, "src/test/kotlin")); } @Test diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index eaf2f44..02f9a59 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -51,7 +51,6 @@ class CompileOptionsTest { var options = new CompileOptions() .apiVersion("11") .argFile(new File("file.txt"), new File("file2.txt")) - .classpath(new File("path1"), new File("path2")) .javaParameters(true) .jvmTarget("11") .includeRuntime(true) @@ -76,7 +75,6 @@ class CompileOptionsTest { var matches = List.of( "-api-version", "11", "@" + localPath("file.txt"), "@" + localPath("file2.txt"), - "-classpath", localPath("path1", "path2"), "-java-parameters", "-jvm-target", "11", "-include-runtime", @@ -210,7 +208,6 @@ class CompileOptionsTest { .advancedOptions("Xoption") .apiVersion("11") .argFile("file") - .classpath("classpath") .expression("expression") .includeRuntime(true) .javaParameters(true) @@ -233,6 +230,10 @@ class CompileOptionsTest { .wError(true) .wExtra(true); + var skipArgs = List.of("-J", "-classpath"); + assertThat(args).as(skipArgs + " not found.").containsAll(skipArgs); + args.removeAll(skipArgs); + try (var softly = new AutoCloseableSoftAssertions()) { for (var p : args) { var found = false; From a2a5f284b646aecf2ac93cacae4b72cbc757e5f7 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 03:00:00 -0700 Subject: [PATCH 35/56] Add workflow for testing the examples on Windows --- .github/workflows/bld.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index d01b562..c4a5206 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -6,7 +6,7 @@ env: KOTLIN_HOME: /usr/share/kotlinc jobs: - build-bld-project: + build-bld-linux: runs-on: ubuntu-latest strategy: @@ -39,3 +39,26 @@ jobs: - name: Run tests run: ./bld compile test + + build-bld-windows: + runs-on: windows-latest + + steps: + - name: Checkout source repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: 17 + + - name: Download dependencies [examples] + working-directory: examples + run: ./bld download + + - name: Run tests [examples] + working-directory: examples + run: ./bld compile test \ No newline at end of file From bef5aed2e39342e1bb98518e34eb05df180ec2a8 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 03:14:35 -0700 Subject: [PATCH 36/56] Move compile options to a var --- examples/src/bld/java/com/example/ExampleBuild.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index 87cc83a..91d5762 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -61,10 +61,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 + var options = new CompileOptions().verbose(true); var op = new CompileKotlinOperation() // .kotlinHome("path/to/kotlin") // .kotlinc("path/to/kotlinc") - .compileOptions(new CompileOptions().verbose(true)) + .compileOptions(options) .fromProject(this); if (!CompileKotlinOperation.isWindows()) { From 8251473b055ef8e337b8710c1943c35264603f2e Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 03:15:41 -0700 Subject: [PATCH 37/56] Run all matrices under Windows --- .github/workflows/bld.yml | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index c4a5206..6e64623 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -6,8 +6,10 @@ env: KOTLIN_HOME: /usr/share/kotlinc jobs: - build-bld-linux: - runs-on: ubuntu-latest + build-bld-project: + runs-on: + - ubuntu-latest + - windows-latest strategy: matrix: @@ -38,27 +40,4 @@ jobs: run: ./bld download - name: Run tests - run: ./bld compile test - - build-bld-windows: - runs-on: windows-latest - - steps: - - name: Checkout source repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: "zulu" - java-version: 17 - - - name: Download dependencies [examples] - working-directory: examples - run: ./bld download - - - name: Run tests [examples] - working-directory: examples run: ./bld compile test \ No newline at end of file From f4ff095297dc8a637e8fdd2ca9558f0ec29e33e2 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 03:21:27 -0700 Subject: [PATCH 38/56] Use an OS matrix to run on --- .github/workflows/bld.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 6e64623..456eef8 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -7,14 +7,13 @@ env: jobs: build-bld-project: - runs-on: - - ubuntu-latest - - windows-latest - strategy: matrix: java-version: [17, 21, 24] kotlin-version: [1.9.25, 2.0.21, 2.1.20] + os: [ ubuntu-latest, windows-latest ] + + runs-on: ${{ matrix.os }} steps: - name: Checkout source repository From a7a9b10f97537403315b41583edfa4ab96ea6c44 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 03:28:03 -0700 Subject: [PATCH 39/56] Split project and examples jobs --- .github/workflows/bld.yml | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 456eef8..c3593a3 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -2,11 +2,34 @@ name: bld-ci on: [push, pull_request, workflow_dispatch] -env: - KOTLIN_HOME: /usr/share/kotlinc - jobs: build-bld-project: + strategy: + matrix: + java-version: [17, 21, 24] + kotlin-version: [1.9.25, 2.0.21, 2.1.20] + + runs-on: ubuntu-latest + + steps: + - name: Checkout source repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: ${{ matrix.java-version }} + + - name: Download dependencies + run: ./bld download + + - name: Run tests + run: ./bld compile test + + build-bld-examples: strategy: matrix: java-version: [17, 21, 24] @@ -33,10 +56,4 @@ jobs: - name: Run tests [examples] working-directory: examples - run: ./bld compile test - - - name: Download dependencies - run: ./bld download - - - name: Run tests run: ./bld compile test \ No newline at end of file From 96b8139b972ee98c0a33232c196c06387996ef4d Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 03:33:48 -0700 Subject: [PATCH 40/56] Add /usr/share common kotlinc paths --- src/main/java/rife/bld/extension/CompileKotlinOperation.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 8f7372e..0ee06d8 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -131,11 +131,13 @@ public class CompileKotlinOperation extends AbstractOperation Date: Sun, 23 Mar 2025 03:39:19 -0700 Subject: [PATCH 41/56] Download dependency for the examples in project workflow as needed for testing --- .github/workflows/bld.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index c3593a3..f741adc 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -23,6 +23,10 @@ jobs: distribution: "zulu" java-version: ${{ matrix.java-version }} + - name: Download dependencies [examples] + working-directory: examples + run: ./bld download + - name: Download dependencies run: ./bld download From 5d78963f1dfbc9e547e5f90ff9e1327ca823317f Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 03:51:54 -0700 Subject: [PATCH 42/56] Add macos-latest to examples OS matrix --- .github/workflows/bld.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index f741adc..58ed9da 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -38,7 +38,7 @@ jobs: matrix: java-version: [17, 21, 24] kotlin-version: [1.9.25, 2.0.21, 2.1.20] - os: [ ubuntu-latest, windows-latest ] + os: [ ubuntu-latest, windows-latest, macos-latest ] runs-on: ${{ matrix.os }} From dc5b81e36674e32b2b6f94ac75247ee2bf18c5e3 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 15:14:23 -0700 Subject: [PATCH 43/56] Add isMinGW() and isCygwin() methods --- .../bld/extension/CompileKotlinOperation.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 0ee06d8..0a77227 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -42,7 +42,7 @@ public class CompileKotlinOperation extends AbstractOperation compileMainClasspath_ = new ArrayList<>(); private final Collection compileTestClasspath_ = new ArrayList<>(); private final JvmOptions jvmOptions_ = new JvmOptions(); @@ -191,6 +191,17 @@ public class CompileKotlinOperation extends AbstractOperation Date: Sun, 23 Mar 2025 15:16:27 -0700 Subject: [PATCH 44/56] Only check kotlinc arguments on Linux --- .../bld/extension/CompileKotlinOperationBuild.java | 12 ++++++++---- .../rife/bld/extension/CompileKotlinOperation.java | 2 +- .../bld/extension/kotlin/CompileOptionsTest.java | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index a3adce1..d4830fd 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -23,6 +23,7 @@ import rife.bld.publish.PublishLicense; import rife.bld.publish.PublishScm; import java.util.List; +import java.util.Locale; import static rife.bld.dependencies.Repository.*; import static rife.bld.dependencies.Scope.compile; @@ -97,10 +98,13 @@ public class CompileKotlinOperationBuild extends Project { @Override public void test() throws Exception { - new ExecOperation() - .fromProject(this) - .command("scripts/cliargs.sh") - .execute(); + var os = System.getProperty("os.name"); + if (os != null && os.toLowerCase(Locale.US).contains("linux")) { + new ExecOperation() + .fromProject(this) + .command("scripts/cliargs.sh") + .execute(); + } super.test(); } } diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 0a77227..26437a8 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -223,7 +223,7 @@ public class CompileKotlinOperation extends AbstractOperation Date: Sun, 23 Mar 2025 15:23:12 -0700 Subject: [PATCH 45/56] Combine project and examples jobs --- .github/workflows/bld.yml | 42 +++++++++------------------------------ 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 58ed9da..cfed82f 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -1,43 +1,13 @@ name: bld-ci -on: [push, pull_request, workflow_dispatch] +on: [ push, pull_request, workflow_dispatch ] jobs: build-bld-project: strategy: matrix: - java-version: [17, 21, 24] - kotlin-version: [1.9.25, 2.0.21, 2.1.20] - - runs-on: ubuntu-latest - - steps: - - name: Checkout source repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v4 - with: - distribution: "zulu" - java-version: ${{ matrix.java-version }} - - - name: Download dependencies [examples] - working-directory: examples - run: ./bld download - - - name: Download dependencies - run: ./bld download - - - name: Run tests - run: ./bld compile test - - build-bld-examples: - strategy: - matrix: - java-version: [17, 21, 24] - kotlin-version: [1.9.25, 2.0.21, 2.1.20] + java-version: [ 17, 21, 24 ] + kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ] os: [ ubuntu-latest, windows-latest, macos-latest ] runs-on: ${{ matrix.os }} @@ -60,4 +30,10 @@ jobs: - name: Run tests [examples] working-directory: examples + run: ./bld compile test + + - name: Download dependencies + run: ./bld download + + - name: Run tests run: ./bld compile test \ No newline at end of file From b5b6b4056487329135148e1def6aca7750198a74 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 16:31:45 -0700 Subject: [PATCH 46/56] Fix plugins paths for Windows/MacOS --- .../rife/bld/extension/CompileKotlinOperationTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index fc8aab2..eeaf75e 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -110,7 +110,6 @@ class CompileKotlinOperationTest { .plugins(Path.of("lib/compile"), CompilerPlugin.NOARG, CompilerPlugin.ALL_OPEN, CompilerPlugin.KOTLIN_IMPORTS_DUMPER) .plugins("lib/compile", CompilerPlugin.KOTLINX_SERIALIZATION, CompilerPlugin.SAM_WITH_RECEIVER) - .plugins(List.of("plugin3", "plugin4")); try (var softly = new AutoCloseableSoftAssertions()) { @@ -134,9 +133,9 @@ class CompileKotlinOperationTest { new File("tfile1"), new File("tfile2"), new File("tfile3"), new File("tfile4"), new File("tfile5"), new File("tfile6")); 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("/kotlin_home/lib/kotlin-serialization-compiler-plugin.jar").getAbsolutePath(), + new File("/kotlin_home/lib/assignment-compiler-plugin.jar").getAbsolutePath(), + new File("/kotlin_home/lib/compose-compiler-plugin.jar").getAbsolutePath(), 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(), From b0ad8ad05665a90ccf01ecb80f5b6162d9acc77a Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Mar 2025 18:35:56 -0700 Subject: [PATCH 47/56] Read @argfile manually --- .../bld/extension/CompileKotlinOperation.java | 4 +-- .../bld/extension/kotlin/CompileOptions.java | 29 ++++++++++++++++++- .../extension/CompileKotlinOperationTest.java | 5 ++-- .../extension/kotlin/CompileOptionsTest.java | 5 +--- src/test/resources/argfile.txt | 3 ++ src/test/resources/argfile2.txt | 1 + 6 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 src/test/resources/argfile.txt create mode 100644 src/test/resources/argfile2.txt diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 26437a8..1aeb930 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -616,10 +616,10 @@ public class CompileKotlinOperation extends AbstractOperation advancedOptions_ = new ArrayList<>(); private final Collection argFile_ = new ArrayList<>(); private final Collection classpath_ = new ArrayList<>(); @@ -248,7 +255,27 @@ public class CompileOptions { // @argfile if (!argFile_.isEmpty()) { - argFile_.forEach(f -> args.add("@" + f.getAbsolutePath())); + argFile_.forEach(f -> { + if (f.exists()) { + try { + try (var reader = Files.newBufferedReader(f.toPath(), Charset.defaultCharset())) { + var tokenizer = new AbstractToolProviderOperation.CommandLineTokenizer(reader); + String token; + while ((token = tokenizer.nextToken()) != null) { + args.add(token); + } + } + } catch (IOException e) { + if (LOGGER.isLoggable(Level.WARNING)) { + LOGGER.log(Level.WARNING, "Could not read: " + f.getAbsolutePath(), e); + } + } + } else { + if (LOGGER.isLoggable(Level.WARNING)) { + LOGGER.warning("File not found: " + f.getAbsolutePath()); + } + } + }); } // expression diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index eeaf75e..4e0182e 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -180,7 +180,7 @@ class CompileKotlinOperationTest { .compileTestClasspath(mainDir.getAbsolutePath()); op.compileOptions().verbose(true); - op.compileOptions().jdkRelease("17"); + op.compileOptions().argFile("src/test/resources/argfile.txt", "src/test/resources/argfile2.txt"); if (!CompileKotlinOperation.isWindows()) { op.jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); @@ -188,7 +188,8 @@ class CompileKotlinOperationTest { } var args = op.compileOptions().args(); - var matches = List.of("-Xjdk-release=17", "-no-stdlib", "-verbose"); + var matches = List.of("-Xjdk-release=17", "-no-reflect", "-progressive", "-include-runtime", "-no-stdlib", + "-verbose"); assertThat(args).as(args + " == " + matches).isEqualTo(matches); op.execute(); diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index 83d29fc..0f498a2 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -52,7 +52,6 @@ class CompileOptionsTest { void testArgs() { var options = new CompileOptions() .apiVersion("11") - .argFile(new File("file.txt"), new File("file2.txt")) .javaParameters(true) .jvmTarget("11") .includeRuntime(true) @@ -76,7 +75,6 @@ class CompileOptionsTest { var matches = List.of( "-api-version", "11", - "@" + localPath("file.txt"), "@" + localPath("file2.txt"), "-java-parameters", "-jvm-target", "11", "-include-runtime", @@ -210,7 +208,6 @@ class CompileOptionsTest { var params = new CompileOptions() .advancedOptions("Xoption") .apiVersion("11") - .argFile("file") .expression("expression") .includeRuntime(true) .javaParameters(true) @@ -233,7 +230,7 @@ class CompileOptionsTest { .wError(true) .wExtra(true); - var skipArgs = List.of("-J", "-classpath"); + var skipArgs = List.of("-J", "-classpath", "@"); assertThat(args).as(skipArgs + " not found.").containsAll(skipArgs); args.removeAll(skipArgs); diff --git a/src/test/resources/argfile.txt b/src/test/resources/argfile.txt new file mode 100644 index 0000000..d128d62 --- /dev/null +++ b/src/test/resources/argfile.txt @@ -0,0 +1,3 @@ +-Xjdk-release=17 -no-reflect + +-progressive diff --git a/src/test/resources/argfile2.txt b/src/test/resources/argfile2.txt new file mode 100644 index 0000000..93f9181 --- /dev/null +++ b/src/test/resources/argfile2.txt @@ -0,0 +1 @@ +-include-runtime \ No newline at end of file From bf82ea19200351fd8eddfd389078a42c9b67a2b9 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 24 Mar 2025 21:29:33 -0700 Subject: [PATCH 48/56] Remove unnecessary isMinGW and isCygwin methods --- .../bld/extension/CompileKotlinOperation.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 1aeb930..d62b328 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -42,7 +42,7 @@ public class CompileKotlinOperation extends AbstractOperation compileMainClasspath_ = new ArrayList<>(); private final Collection compileTestClasspath_ = new ArrayList<>(); private final JvmOptions jvmOptions_ = new JvmOptions(); @@ -191,17 +191,6 @@ public class CompileKotlinOperation extends AbstractOperation Date: Mon, 24 Mar 2025 21:29:54 -0700 Subject: [PATCH 49/56] Minor cleanups --- .../bld/java/com/example/ExampleBuild.java | 14 +++------- .../bld/extension/CompileKotlinOperation.java | 12 +++++---- .../extension/kotlin/CompileOptionsTest.java | 26 ++++++++++++++++--- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index 91d5762..aa12e0d 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -61,17 +61,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 - var options = new CompileOptions().verbose(true); - var op = new CompileKotlinOperation() + new CompileKotlinOperation() // .kotlinHome("path/to/kotlin") // .kotlinc("path/to/kotlinc") - .compileOptions(options) - .fromProject(this); - - if (!CompileKotlinOperation.isWindows()) { - op.jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED); - } - - op.execute(); + .compileOptions(new CompileOptions().verbose(true)) + .fromProject(this) + .execute(); } } diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index d62b328..bb6f209 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -508,18 +508,20 @@ public class CompileKotlinOperation extends AbstractOperation command.add("-J" + s)); } - // compiler options - if (compileOptions_ != null) { - args.addAll(compileOptions_.args()); + // classpath + if (compileOptions_ != null && !compileOptions_.classpath().isEmpty()) { cp.addAll(compileOptions_.classpath().stream().map(this::cleanPath).toList()); } - - // classpath if (!cp.isEmpty()) { args.add("-cp"); args.add('"' + FileUtils.joinPaths(cp.stream().map(this::cleanPath).toList()) + '"'); } + // compile options + if (compileOptions_ != null && !compileOptions_.args().isEmpty()) { + args.addAll(compileOptions_.args()); + } + // destination args.add("-d"); args.add('"' + cleanPath(destination) + '"'); diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index 0f498a2..5b36483 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -185,17 +185,23 @@ class CompileOptionsTest { var bar = new File("bar.txt"); var options = new CompileOptions(); + options = options.argFile(foo); + assertThat(options.argFile()).contains(foo); + options.argFile().clear(); + assertThat(options.argFile()).isEmpty(); + options.argFile(foo, bar); assertThat(options.argFile()).contains(foo, bar); options.argFile().clear(); + assertThat(options.argFile()).isEmpty(); options = options.argFile(foo.toPath(), bar.toPath()); assertThat(options.argFile()).contains(foo, bar); options.argFile().clear(); + assertThat(options.argFile()).isEmpty(); - options.argFile(foo.getAbsolutePath(), bar.getAbsolutePath()); + options = options.argFile(foo.getAbsolutePath(), bar.getAbsolutePath()); assertThat(options.argFile()).contains(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath())); - options.argFile().clear(); } @Test @@ -254,31 +260,45 @@ class CompileOptionsTest { var bar = new File("bar.txt"); var options = new CompileOptions(); + options = options.classpath(foo); + assertThat(options.classpath()).as("File").containsExactly(foo); + options.classpath().clear(); + assertThat(options.argFile()).isEmpty(); + + options.classpath(foo, bar); assertThat(options.classpath()).as("File...").containsExactly(foo, bar); options.classpath().clear(); + assertThat(options.argFile()).isEmpty(); + options.classpath(List.of(foo, bar)); assertThat(options.classpath()).as("List(File...)").containsExactly(foo, bar); options.classpath().clear(); + assertThat(options.argFile()).isEmpty(); + options = options.classpath(foo.toPath(), bar.toPath()); assertThat(options.classpath()).as("Path...").containsExactly(foo, bar); options.classpath().clear(); + assertThat(options.argFile()).isEmpty(); + options = options.classpathPaths(List.of(foo.toPath(), bar.toPath())); assertThat(options.classpath()).as("List(Path...)").containsExactly(foo, bar); options.classpath().clear(); + assertThat(options.argFile()).isEmpty(); + options.classpath(foo.getAbsolutePath(), bar.getAbsolutePath()); assertThat(options.classpath()).as("String...") .containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath())); options.classpath().clear(); + assertThat(options.argFile()).isEmpty(); options.classpathStrings(List.of(foo.getAbsolutePath(), bar.getAbsolutePath())); assertThat(options.classpath()).as("List(String...)") .containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath())); - options.classpath().clear(); } @Test From 852e24bc18f08f4079a7b51a1981d2bff963dc98 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 26 Mar 2025 21:52:12 -0700 Subject: [PATCH 50/56] Log where the kotlin compiler was found from/at --- .../bld/extension/CompileKotlinOperation.java | 88 ++++++++++++------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index bb6f209..a45ef0c 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -103,7 +103,8 @@ public class CompileKotlinOperation extends AbstractOperation commonPaths = new ArrayList<>(); + var commonPaths = new HashMap(); //NOPMD no concurrent access if (isLinux()) { var userHome = System.getProperty("user.home"); if (userHome != null) { - commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN! - commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/plugins/Kotlin/kotlinc/bin"); // Toolbox IDEA Ultimate - commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/kotlinc/bin"); // Toolbox IDEA CE - commonPaths.add(userHome + "/.local/share/JetBrains/Toolbox/apps/android-studio/plugins/Kotlin/kotlinc/bin"); // Toolbox Android Studio + commonPaths.put(userHome + "/.sdkman/candidates/kotlin/current/bin", "SDKMAN"); + commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/plugins/Kotlin/kotlinc/bin", + "IntelliJ IDEA Ultimate"); + commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/kotlinc/bin", + "IntelliJ IDEA Community Edition"); + commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/android-studio/plugins/Kotlin/kotlinc/bin", + "Android Studio"); } - commonPaths.add("/usr/bin"); - commonPaths.add("/usr/share"); - commonPaths.add("/usr/local/bin"); - commonPaths.add("/usr/local/kotlin/bin"); - commonPaths.add("/usr/share/kotlin/bin/"); - commonPaths.add("/opt/kotlin/bin"); + commonPaths.put("/usr/bin", null); + commonPaths.put("/usr/share", null); + commonPaths.put("/usr/local/bin", null); + commonPaths.put("/usr/local/kotlin/bin", null); + commonPaths.put("/usr/share/kotlin/bin/", null); + commonPaths.put("/opt/kotlin/bin", null); } else if (isWindows()) { - commonPaths.add("C:\\tools\\kotlinc"); + commonPaths.put("C:\\tools\\kotlinc", null); var localAppData = System.getenv("LOCALAPPDATA"); if (localAppData != null) { - commonPaths.add(localAppData + "\\Programs\\IntelliJ IDEA Ultimate\\plugins\\Kotlin\\kotlinc\\bin"); // Toolbox IDEA Ultimate - commonPaths.add(localAppData + "\\Programs\\IntelliJ IDEA Community Edition\\plugins\\Kotlin\\kotlinc\\bin"); // Toolbox IDEA CE - commonPaths.add(localAppData + "\\Programs\\Android Studio\\plugins\\Kotlin\\kotlinc\\bin"); // Toolbox Android Studio + commonPaths.put(localAppData + "\\Programs\\IntelliJ IDEA Ultimate\\plugins\\Kotlin\\kotlinc\\bin", + "IntelliJ IDEA Ultimate"); + commonPaths.put(localAppData + "\\Programs\\IntelliJ IDEA Community Edition\\plugins\\Kotlin\\kotlinc\\bin", + "IntelliJ IDEA Community Edition"); + commonPaths.put(localAppData + "\\Programs\\Android Studio\\plugins\\Kotlin\\kotlinc\\bin", + "Android Studio"); } var programFiles = System.getenv("ProgramFiles"); if (programFiles != null) { - commonPaths.add(programFiles + File.separator + "Kotlin"); + commonPaths.put(programFiles + File.separator + "Kotlin", "null"); } } else if (isMacOS()) { var userHome = System.getProperty("user.home"); if (userHome != null) { - commonPaths.add(userHome + "/.sdkman/candidates/kotlin/current/bin"); // SDKMAN! + commonPaths.put(userHome + "/.sdkman/candidates/kotlin/current/bin", "SDKMAN!"); } - commonPaths.add("/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/kotlinc/bin/"); // IDEA Ultimate - commonPaths.add("/Applications/IntelliJ IDEA Community Edition.app/Contents/plugins/Kotlin/kotlinc/bin/"); //IDEA CE - commonPaths.add("/Applications/Android Studio.app/Contents/plugins/Kotlin/kotlinc/bin"); //Android Studio - commonPaths.add("/usr/local/bin"); // Homebrew - commonPaths.add("/opt/homebrew/bin"); // Homebrew + commonPaths.put("/Applications/IntelliJ IDEA.app/Contents/plugins/Kotlin/kotlinc/bin/", + "IntelliJ IDEA"); + commonPaths.put("/Applications/IntelliJ IDEA Community Edition.app/Contents/plugins/Kotlin/kotlinc/bin/", + "IntelliJ IDEA Community Edition"); + commonPaths.put("/Applications/Android Studio.app/Contents/plugins/Kotlin/kotlinc/bin", + "Android Studio"); + commonPaths.put("/usr/local/bin", null); + commonPaths.put("/opt/homebrew/bin", "Homebrew"); } - for (var location : commonPaths) { - kotlincPath = findKotlincInDir(location); + for (var path : commonPaths.keySet()) { + kotlincPath = findKotlincInDir(path); if (kotlincPath != null) { - return logKotlincPath(kotlincPath, isSilent); + logKotlincPath(kotlincPath, isSilent, commonPaths.get(path)); + return kotlincPath; } } + commonPaths.forEach((path, where) -> { + + }); // Try 'which' or 'where' commands (less reliable but sometimes works) try { @@ -180,7 +195,8 @@ public class CompileKotlinOperation extends AbstractOperation Date: Fri, 28 Mar 2025 07:53:08 -0700 Subject: [PATCH 51/56] Update extensions dependencies Bump Exec from 1.0.4 to 1.0.5 Bump PMD from 1.2.1 to 1.2.2 --- lib/bld/bld-wrapper.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index b23895b..d29a55f 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -3,8 +3,8 @@ bld.downloadExtensionSources=true bld.downloadLocation= bld.javaOptions= bld.javacOptions= -bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.4 -bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.1 +bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5 +bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.2 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.2.1 From 2a406feb15782c0079c56b157a9e67fac1d06284 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 28 Mar 2025 15:44:49 -0700 Subject: [PATCH 52/56] Add snap locations to common paths --- .../bld/extension/CompileKotlinOperation.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index a45ef0c..f54e68b 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -122,12 +122,21 @@ public class CompileKotlinOperation extends AbstractOperation(); //NOPMD no concurrent access + var commonPaths = new LinkedHashMap(); //NOPMD no concurrent access if (isLinux()) { var userHome = System.getProperty("user.home"); if (userHome != null) { - commonPaths.put(userHome + "/.sdkman/candidates/kotlin/current/bin", "SDKMAN"); + commonPaths.put(userHome + "/.sdkman/candidates/kotlin/current/bin", "SDKMAN!"); + } + commonPaths.put("/snap/bin", "Kotlin (Snap)"); + commonPaths.put("/usr/bin", null); + commonPaths.put("/usr/share", null); + commonPaths.put("/usr/local/bin", null); + commonPaths.put("/usr/local/kotlin/bin", null); + commonPaths.put("/usr/share/kotlin/bin/", null); + commonPaths.put("/opt/kotlin/bin", null); + if (userHome != null) { commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/plugins/Kotlin/kotlinc/bin", "IntelliJ IDEA Ultimate"); commonPaths.put(userHome + "/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/plugins/Kotlin/kotlinc/bin", @@ -135,14 +144,14 @@ public class CompileKotlinOperation extends AbstractOperation { - - }); // Try 'which' or 'where' commands (less reliable but sometimes works) try { From 23a97601db3784677c8043a7a02ea513d4047e9d Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 31 Mar 2025 10:32:23 -0700 Subject: [PATCH 53/56] Find compiler in Kotlin home, if specified --- .../rife/bld/extension/CompileKotlinOperation.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index f54e68b..05cfe63 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -122,7 +122,7 @@ public class CompileKotlinOperation extends AbstractOperation(); //NOPMD no concurrent access + var commonPaths = new LinkedHashMap(); if (isLinux()) { var userHome = System.getProperty("user.home"); @@ -266,7 +266,7 @@ public class CompileKotlinOperation extends AbstractOperation Date: Tue, 1 Apr 2025 11:07:08 -0700 Subject: [PATCH 54/56] Add method to find the Kotlin home --- .../bld/extension/CompileKotlinOperation.java | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 05cfe63..5932298 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -68,7 +68,7 @@ public class CompileKotlinOperation extends AbstractOperation @@ -1022,15 +1045,17 @@ public class CompileKotlinOperation extends AbstractOperation Date: Sat, 12 Apr 2025 18:48:12 -0700 Subject: [PATCH 55/56] Bump JUnit to version 5.12.2 --- examples/src/bld/java/com/example/ExampleBuild.java | 6 +++--- .../rife/bld/extension/CompileKotlinOperationBuild.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index aa12e0d..170c5b5 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -35,9 +35,9 @@ public class ExampleBuild extends Project { .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); scope(test) .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin)) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1))) - .include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 1))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2))) + .include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 2))); // Include the Kotlin source directory when creating or publishing sources Java Archives jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin")); diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index d4830fd..53e84c7 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -46,8 +46,8 @@ public class CompileKotlinOperationBuild extends Project { scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1))); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1))) + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2))) .include(dependency("org.assertj", "assertj-core", version(3, 27, 3))); javadocOperation() From 574205d5483c11bf43c3c1e20bc0001eacf26efc Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 15 Apr 2025 10:51:10 -0700 Subject: [PATCH 56/56] Advance options should start with -X --- .../bld/extension/kotlin/CompileOptions.java | 18 +++++++++++------- .../extension/kotlin/CompileOptionsTest.java | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index 64f46e3..e43adc8 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java @@ -388,7 +388,7 @@ public class CompileOptions { args.add("-verbose"); } - // Wwrror + // Werror if (wError_) { args.add("-Werror"); } @@ -398,9 +398,15 @@ public class CompileOptions { args.add("-Wextra"); } - // advanced option (X) + // advanced options (X) if (!advancedOptions_.isEmpty()) { - advancedOptions_.forEach(it -> args.add("-X" + it)); + advancedOptions_.forEach(it -> { + if (it.startsWith("-X")) { + args.add(it); + } else { + args.add("-X" + it); + } + }); } return args; @@ -691,7 +697,7 @@ public class CompileOptions { * Limit the API of the JDK in the classpath to the specified Java version. Automatically sets * {@link #jvmTarget(String) JVM target} version. *

    - * Possible values are 1.8, 9, 10, ..., 22. The default value is 1.8. + * Possible values are 1.8, 9, 10, ..., 23. The default value is 1.8. * * @param version the target version * @return this operation instance @@ -706,8 +712,6 @@ public class CompileOptions { *

    * Limit the API of the JDK in the classpath to the specified Java version. Automatically sets * {@link #jvmTarget(String) JVM target} version. - *

    - * Possible values are 1.8, 9, 10, ..., 22. The default value is 1.8. * * @param version the target version * @return this operation instance @@ -731,7 +735,7 @@ public class CompileOptions { /** * Specify the target version of the generated JVM bytecode. *

    - * Possible values are 1.8, 9, 10, ..., 22. The default value is 1.8. + * Possible values are 1.8, 9, 10, ..., 23. The default value is 1.8. * * @param target the target version * @return this operation instance diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index 5b36483..c6e6965 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -112,7 +112,7 @@ class CompileOptionsTest { @Test void testArgsCollections() { - var advanceOptions = List.of("Xoption1", "Xoption2"); + var advanceOptions = List.of("-Xoption1", "option=2"); var argFile = List.of(new File("arg1.txt"), new File("arg2.txt")); var classpath = List.of(new File("path1"), new File("path2")); var optIn = List.of("opt1", "opt2"); @@ -160,7 +160,7 @@ class CompileOptionsTest { "-foo", "-bar", "-script-templates", "temp1,temp2", - "-XXoption1", "-XXoption2", + "-Xoption1", "-Xoption=2", "-P", "plugin:id:name:value", "-P", "plugin:id2:name2:value2");