diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 0066bc3..1e1725c 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -83,9 +83,8 @@ public class CompileKotlinOperation extends AbstractOperation - new File(dir_abs, file)).toList(); + return FileUtils.getFileList(directory, KOTLIN_FILE_PATTERN, null).stream().map((file) -> + new File(directory, file)).toList(); } } @@ -427,6 +426,20 @@ public class CompileKotlinOperation extends AbstractOperation sources(Collection files, Collection directories) { var sources = new ArrayList<>(files); diff --git a/src/main/java/rife/bld/extension/CompileKotlinPlugin.java b/src/main/java/rife/bld/extension/CompileKotlinPlugin.java new file mode 100644 index 0000000..4936655 --- /dev/null +++ b/src/main/java/rife/bld/extension/CompileKotlinPlugin.java @@ -0,0 +1,34 @@ +/* + * Copyright 2023 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; + +public enum CompileKotlinPlugin { + ALL_OPEN("^allopen-compiler-plugin-.*$"), + ASSIGNMENT("^assignment-compiler-plugin-.*$"), + KOTLIN_IMPORTS_DUMPER("^kotlin-imports-dumper-compiler-plugin-.*$"), + KOTLIN_SERIALIZATION("^kotlin-serialization-compiler-plugin-.*$"), + KOTLINX_SERIALIZATION("^kotlinx-serialization-compiler-plugin-.*$"), + LOMBOK("^lombok-compiler-plugin-.*$"), + NOARG("^noarg-compiler-plugin-.*$"), + SAM_WITH_RECEIVER("^sam-with-receiver-compiler-plugin-.*$"); + + public final String label; + + CompileKotlinPlugin(String label) { + this.label = label; + } +} diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index ecdd291..77e95e6 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -68,6 +68,7 @@ class CompileKotlinOperationTest { testJars.add(f.getAbsolutePath()); } + var op = new CompileKotlinOperation() .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example")) @@ -77,9 +78,7 @@ class CompileKotlinOperationTest { .compileMainClasspath(compileJars) .compileTestClasspath(testJars) .compileTestClasspath(compileJars) - .compileTestClasspath(mainDir.getAbsolutePath()) - .mainSourceFiles(CompileKotlinOperation.getKotlinFileList(new File("examples/src/main/kotlin"))) - .testSourceFiles(CompileKotlinOperation.getKotlinFileList(new File("examples/src/test/kotlin"))); + .compileTestClasspath(mainDir.getAbsolutePath()); op.execute(); @@ -87,8 +86,12 @@ class CompileKotlinOperationTest { assertThat(mainDir).isNotEmptyDirectory(); assertThat(testDir).isNotEmptyDirectory(); - var exampleClass = Path.of(mainDir.getAbsolutePath(), "com", "example", "Example.class").toFile(); - assertThat(exampleClass).exists(); + var mainOut = Path.of(mainDir.getAbsolutePath(), "com", "example").toFile(); + assertThat(new File(mainOut, "Example.class")).exists(); + assertThat(new File(mainOut, "Example$Companion.class")).exists(); + + var testOut = Path.of(testDir.getAbsolutePath(), "com", "example").toFile(); + assertThat(new File(testOut, "ExampleTest.class")).exists(); } finally { FileUtils.deleteDirectory(tmpDir); }