diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 28c5833..949f84f 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,7 +1,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.2 +bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.1 bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.1.0 diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index d8b4782..885e968 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, 2); + version = version(1, 0, 1); javaRelease = 17; @@ -57,26 +57,28 @@ public class CompileKotlinOperationBuild extends Project { publishOperation() .repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2")) - .repository(repository("github")) .info() .groupId("com.uwyn.rife2") .artifactId("bld-kotlin") .description("bld Kotlin Extension") .url("https://github.com/rife2/bld-kotlin") - .developer(new PublishDeveloper() - .id("ethauvin") - .name("Erik C. Thauvin") - .email("erik@thauvin.net") - .url("https://erik.thauvin.net/") + .developer( + new PublishDeveloper() + .id("ethauvin") + .name("Erik C. Thauvin") + .email("erik@thauvin.net") + .url("https://erik.thauvin.net/") ) - .license(new PublishLicense() - .name("The Apache License, Version 2.0") - .url("https://www.apache.org/licenses/LICENSE-2.0.txt") + .license( + new PublishLicense() + .name("The Apache License, Version 2.0") + .url("https://www.apache.org/licenses/LICENSE-2.0.txt") ) - .scm(new PublishScm() - .connection("scm:git:https://github.com/rife2/bld-kotlin.git") - .developerConnection("scm:git:git@github.com:rife2/bld-kotlin.git") - .url("https://github.com/rife2/bld-kotlin") + .scm( + new PublishScm() + .connection("scm:git:https://github.com/rife2/bld-kotlin.git") + .developerConnection("scm:git:git@github.com:rife2/bld-kotlin.git") + .url("https://github.com/rife2/bld-kotlin") ) .signKey(property("sign.key")) .signPassphrase(property("sign.passphrase")); diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 8143f5d..af0bc45 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -284,16 +284,8 @@ public class CompileKotlinOperation extends AbstractOperation classpath, Collection sources, File destination, File friendPaths) throws ExitStatusException { - if (sources.isEmpty()) { - if (!silent() && LOGGER.isLoggable(Level.WARNING)) { - LOGGER.warning("Nothing to compile."); - } + if (sources.isEmpty() || destination == null) { return; - } else if (destination == null) { - if (!silent() && LOGGER.isLoggable(Level.SEVERE)) { - LOGGER.severe("No destination specified."); - } - throw new ExitStatusException(ExitStatusException.EXIT_FAILURE); } var args = new ArrayList(); @@ -302,10 +294,8 @@ 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 #kotlinHome()} to the {@code KOTLIN_HOME} environment variable, if set.
  • + *
  • {@link #workDir()} to the project's directory.
  • *
  • {@link #buildMainDirectory() buildMainDirectory}
  • *
  • {@link #buildTestDirectory() buildTestDirectory}
  • *
  • {@link #compileMainClasspath() compileMainClassPath}
  • *
  • {@link #compileTestClasspath() compilesTestClassPath}
  • - *
  • {@link #mainSourceDirectories() mainSourceDirectories} to the {@code kotlin} directory in - * {@link BaseProject#srcMainDirectory() srcMainDirectory}, if present.
  • + *
  • {@link #mainSourceDirectories()} () mainSourceDirectories} to the {@code kotlin} directory in + * {@link BaseProject#srcMainDirectory() srcMainDirectory}
  • *
  • {@link #testSourceDirectories() testSourceDirectories} to the {@code kotlin} directory in - * {@link BaseProject#srcTestDirectory() srcTestDirectory}, if present.
  • + * {@link BaseProject#srcTestDirectory() srcTestDirectory} *
  • {@link CompileOptions#jdkRelease jdkRelease} to {@link BaseProject#javaRelease() javaRelease}
  • *
  • {@link CompileOptions#noStdLib(boolean) noStdLib} to {@code true}
  • *
@@ -416,17 +406,9 @@ public class CompileKotlinOperation extends AbstractOperation(); for (var f : Objects.requireNonNull(new File("examples/lib/compile").listFiles())) { @@ -185,18 +182,13 @@ class CompileKotlinOperationTest { op.execute(); - try (var softly = new AutoCloseableSoftAssertions()) { - softly.assertThat(tmpDir).as("tmpDir").isNotEmptyDirectory(); - softly.assertThat(mainDir).as("mainDir").isNotEmptyDirectory(); - softly.assertThat(testDir).as("testDir").isNotEmptyDirectory(); - } + assertThat(tmpDir).as("tmpDir").isNotEmptyDirectory(); + assertThat(mainDir).as("mainDir").isNotEmptyDirectory(); + assertThat(testDir).as("testDir").isNotEmptyDirectory(); var mainOut = Path.of(mainDir.getAbsolutePath(), "com", "example").toFile(); - try (var softly = new AutoCloseableSoftAssertions()) { - softly.assertThat(new File(mainOut, "Example.class")).as("Example.class").exists(); - softly.assertThat(new File(mainOut, "Example$Companion.class")) - .as("ExampleCompanion.class").exists(); - } + assertThat(new File(mainOut, "Example.class")).as("Example.class").exists(); + assertThat(new File(mainOut, "Example$Companion.class")).as("ExampleCompanion.class").exists(); var testOut = Path.of(testDir.getAbsolutePath(), "com", "example").toFile(); assertThat(new File(testOut, "ExampleTest.class")).as("ExampleTest.class").exists(); @@ -205,14 +197,6 @@ class CompileKotlinOperationTest { } } - @Test - void testFromProjectNoKotlin() { - var op = new CompileKotlinOperation().fromProject( - new BaseProjectBlueprint(new File("foo"), "org.example", "foo")); - assertThat(op.mainSourceDirectories()).isEmpty(); - assertThat(op.testSourceDirectories()).isEmpty(); - } - @Test void testKotlinHome() { var foo = new File("foo"); @@ -266,13 +250,11 @@ class CompileKotlinOperationTest { op.mainSourceDirectories().clear(); op.mainSourceDirectoriesPaths(List.of(new File(FILE_1).toPath(), new File(FILE_2).toPath())); - assertThat(op.mainSourceDirectories()).as("List(Path...)") - .containsExactly(new File(FILE_1), new File(FILE_2)); + assertThat(op.mainSourceDirectories()).as("List(Path...)").containsExactly(new File(FILE_1), new File(FILE_2)); op.mainSourceDirectories().clear(); op.mainSourceDirectoriesStrings(List.of(FILE_1, FILE_2)); - assertThat(op.mainSourceDirectories()).as("List(String...)") - .containsExactly(new File(FILE_1), new File(FILE_2)); + assertThat(op.mainSourceDirectories()).as("List(String...)").containsExactly(new File(FILE_1), new File(FILE_2)); op.mainSourceDirectories().clear(); } @@ -321,10 +303,8 @@ class CompileKotlinOperationTest { CompilerPlugin.POWER_ASSERT, CompilerPlugin.SAM_WITH_RECEIVER); - try (var softly = new AutoCloseableSoftAssertions()) { - for (var p : op.plugins()) { - softly.assertThat(new File(p)).as(p).exists(); - } + for (var p : op.plugins()) { + assertThat(new File(p)).as(p).exists(); } } diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index 5417115..91ad563 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -16,7 +16,6 @@ package rife.bld.extension.kotlin; -import org.assertj.core.api.AutoCloseableSoftAssertions; import org.junit.jupiter.api.Test; import java.io.File; @@ -103,11 +102,9 @@ class CompileOptionsTest { args.add(options.args()); args.add(options.apiVersion(11).jvmTarget(11).args()); - try (var softly = new AutoCloseableSoftAssertions()) { - for (var a : args) { - IntStream.range(0, a.size()).forEach(i -> softly.assertThat(a.get(i)) - .as(a.get(i) + " == " + matches.get(i)).isEqualTo(matches.get(i))); - } + for (var a : args) { + IntStream.range(0, a.size()).forEach(i -> assertThat(a.get(i)) + .as(a.get(i) + " == " + matches.get(i)).isEqualTo(matches.get(i))); } } @@ -137,24 +134,22 @@ class CompileOptionsTest { op.plugin(p[0], p[1], p[2]); }); - try (var softly = new AutoCloseableSoftAssertions()) { - softly.assertThat(op.advancedOptions()).as("advancedOptions") - .hasSize(advanceOptions.size()).containsAll(advanceOptions); - softly.assertThat(op.argFile()).as("argFile") - .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") - .hasSize(options.size()).containsAll(options); - softly.assertThat(op.plugin()).as("plugin") - .hasSize(plugin.size()).containsAll(plugin); - softly.assertThat(op.scriptTemplates()).as("scriptTemplates") - .hasSize(scriptTemplates.size()).containsAll(scriptTemplates); - } + assertThat(op.advancedOptions()).as("advancedOptions") + .hasSize(advanceOptions.size()).containsAll(advanceOptions); + assertThat(op.argFile()).as("argFile") + .hasSize(argFile.size()).containsAll(argFile); + assertThat(op.classpath()).as("classpath") + .hasSize(classpath.size()).containsAll(classpath); + assertThat(op.jvmOptions()).as("jvmOptions") + .hasSize(jvmOptions.size()).containsAll(jvmOptions); + assertThat(op.optIn()).as("optIn") + .hasSize(optIn.size()).containsAll(optIn); + assertThat(op.options()).as("options") + .hasSize(options.size()).containsAll(options); + assertThat(op.plugin()).as("plugin") + .hasSize(plugin.size()).containsAll(plugin); + assertThat(op.scriptTemplates()).as("scriptTemplates") + .hasSize(scriptTemplates.size()).containsAll(scriptTemplates); var matches = List.of( '@' + localPath("arg1.txt"), '@' + localPath("arg2.txt"), @@ -169,18 +164,16 @@ class CompileOptionsTest { "-P", "plugin:id:name:value", "-P", "plugin:id2:name2:value2"); - try (var softly = new AutoCloseableSoftAssertions()) { - var args = op.args(); - for (var arg : args) { - var found = false; - for (var match : matches) { - if (match.equals(arg)) { - found = true; - break; - } + var args = op.args(); + for (var arg : args) { + var found = false; + for (var match : matches) { + if (match.equals(arg)) { + found = true; + break; } - softly.assertThat(found).as(arg + " not found.").isTrue(); } + assertThat(found).as(arg + " not found.").isTrue(); } } @@ -236,17 +229,15 @@ class CompileOptionsTest { .verbose(true) .wError(true); - try (var softly = new AutoCloseableSoftAssertions()) { - for (var p : args) { - var found = false; - for (var a : params.args()) { - if (a.startsWith(p)) { - found = true; - break; - } + for (var p : args) { + var found = false; + for (var a : params.args()) { + if (a.startsWith(p)) { + found = true; + break; } - softly.assertThat(found).as(p + " not found.").isTrue(); } + assertThat(found).as(p + " not found.").isTrue(); } } @@ -342,32 +333,30 @@ class CompileOptionsTest { .verbose(true) .wError(true); - try (var softly = new AutoCloseableSoftAssertions()) { - softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2"); - softly.assertThat(options.apiVersion()).isEqualTo("11"); - softly.assertThat(options.argFile()).containsExactly(new File("args.txt")); - softly.assertThat(options.classpath()).containsExactly(new File("classpath")); - softly.assertThat(options.expression()).isEqualTo("expression"); - softly.assertThat(options.isIncludeRuntime()).isTrue(); - softly.assertThat(options.isJavaParameters()).isTrue(); - softly.assertThat(options.isNoJdk()).isTrue(); - softly.assertThat(options.isNoReflect()).isTrue(); - softly.assertThat(options.isNoStdLib()).isTrue(); - softly.assertThat(options.isNoWarn()).isTrue(); - softly.assertThat(options.isProgressive()).isTrue(); - softly.assertThat(options.isVerbose()).isTrue(); - softly.assertThat(options.jdkHome()).isEqualTo(new File("jdk-home")); - softly.assertThat(options.jdkRelease()).isEqualTo("22"); - softly.assertThat(options.jvmTarget()).isEqualTo("9"); - softly.assertThat(options.kotlinHome()).isEqualTo(new File("kotlin-home")); - softly.assertThat(options.languageVersion()).isEqualTo("1.0"); - softly.assertThat(options.moduleName()).isEqualTo("module"); - softly.assertThat(options.optIn()).containsExactly("opt1", "opt2"); - softly.assertThat(options.options()).containsExactly("-foo", "-bar"); - softly.assertThat(options.path()).isEqualTo(new File("path")); - softly.assertThat(options.plugin()).containsExactly("id:name:value"); - softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2"); - softly.assertThat(options.isWError()).isTrue(); - } + assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2"); + assertThat(options.apiVersion()).isEqualTo("11"); + assertThat(options.argFile()).containsExactly(new File("args.txt")); + assertThat(options.classpath()).containsExactly(new File("classpath")); + assertThat(options.expression()).isEqualTo("expression"); + assertThat(options.isIncludeRuntime()).isTrue(); + assertThat(options.isJavaParameters()).isTrue(); + assertThat(options.isNoJdk()).isTrue(); + assertThat(options.isNoReflect()).isTrue(); + assertThat(options.isNoStdLib()).isTrue(); + assertThat(options.isNoWarn()).isTrue(); + assertThat(options.isProgressive()).isTrue(); + assertThat(options.isVerbose()).isTrue(); + assertThat(options.jdkHome()).isEqualTo(new File("jdk-home")); + assertThat(options.jdkRelease()).isEqualTo("22"); + assertThat(options.jvmTarget()).isEqualTo("9"); + assertThat(options.kotlinHome()).isEqualTo(new File("kotlin-home")); + assertThat(options.languageVersion()).isEqualTo("1.0"); + assertThat(options.moduleName()).isEqualTo("module"); + assertThat(options.optIn()).containsExactly("opt1", "opt2"); + assertThat(options.options()).containsExactly("-foo", "-bar"); + assertThat(options.path()).isEqualTo(new File("path")); + assertThat(options.plugin()).containsExactly("id:name:value"); + assertThat(options.scriptTemplates()).containsExactly("name", "name2"); + assertThat(options.isWError()).isTrue(); } }