From 28ad500a12f67c4ebcf0a5c4ff911e96ddfc5efa Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 15 Nov 2023 11:02:26 -0800 Subject: [PATCH] Made compile options modifiable --- README.md | 1 - examples/.idea/misc.xml | 16 +------- .../bld/java/com/example/ExampleBuild.java | 10 ++--- .../bld/extension/CompileKotlinOperation.java | 41 ++++++++++++++++--- .../bld/extension/CompileKotlinOptions.java | 13 +++++- .../bld/extension/dokka/AnalysisPlatform.java | 2 +- .../rife/bld/extension/dokka/SourceSet.java | 4 +- .../extension/CompileKotlinOperationTest.java | 2 +- .../extension/CompileKotlinOptionsTest.java | 2 +- 9 files changed, 57 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 51268a8..07903eb 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ To compile the source code located in `src/main/kotlin` and `src/test/kotlin` fr public void compile() throws IOException { new CompileKotlinOperation() .fromProject(this) - .compileOptions(new CompileKotlinOptions().verbose(true)) .execute(); } ``` diff --git a/examples/.idea/misc.xml b/examples/.idea/misc.xml index bdb2fea..e2bbc73 100644 --- a/examples/.idea/misc.xml +++ b/examples/.idea/misc.xml @@ -1,3 +1,4 @@ + @@ -6,20 +7,7 @@ - - - - \ No newline at end of file + diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index 211b13f..5447f0a 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -3,7 +3,6 @@ package com.example; import rife.bld.BuildCommand; import rife.bld.Project; import rife.bld.extension.CompileKotlinOperation; -import rife.bld.extension.CompileKotlinOptions; import rife.bld.extension.dokka.DokkaOperation; import rife.bld.extension.dokka.LoggingLevel; import rife.bld.extension.dokka.OutputFormat; @@ -64,12 +63,11 @@ public class ExampleBuild extends Project { // The source code located in src/main/kotlin and src/test/kotlin will be compiled new CompileKotlinOperation() .fromProject(this) - .compileOptions( - new CompileKotlinOptions() - .jdkRelease(javaRelease) - .verbose(true) - ) .execute(); + +// var op = new CompileKotlinOperation().fromProject(this); +// op.compileOptions().verbose(true); +// op.execute(); } @BuildCommand(value = "dokka-gfm", summary = "Generates documentation in GitHub flavored markdown format") diff --git a/src/main/java/rife/bld/extension/CompileKotlinOperation.java b/src/main/java/rife/bld/extension/CompileKotlinOperation.java index 1e1725c..1f531c7 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOperation.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOperation.java @@ -46,7 +46,7 @@ public class CompileKotlinOperation extends AbstractOperation testSourceFiles_ = new ArrayList<>(); private File buildMainDirectory_; private File buildTestDirectory_; - private CompileKotlinOptions compileOptions_; + private CompileKotlinOptions compileOptions_ = new CompileKotlinOptions(); private BaseProject project_; /** @@ -159,6 +159,13 @@ public class CompileKotlinOperation extends AbstractOperation{@link #buildTestDirectory() buildTestDirectory} *
  • {@link #compileMainClasspath() compileMainClassPath}
  • *
  • {@link #compileTestClasspath() compilesTestClassPath}
  • - *
  • {@link #mainSourceFiles() mainSourceFiles}
  • - *
  • {@link #testSourceFiles() testSourceFile}
  • - *
  • {@link CompileKotlinOptions#jdkRelease jdkRelease}
  • + *
  • {@link #mainSourceFiles() mainSourceFiles} to the {@code kotlin} directory in + * {@link BaseProject#srcMainDirectory() srcMainDirectory}
  • + *
  • {@link #testSourceFiles() testSourceFile} to the {@code kotlin} directory in + * {@link BaseProject#srcTestDirectory() srcTestDirectory}
  • + *
  • {@link CompileKotlinOptions#jdkRelease jdkRelease} to {@link BaseProject#javaRelease() javaRelease}
  • * * * @param project the project to configure the compile operation from @@ -335,8 +344,8 @@ public class CompileKotlinOperation extends AbstractOperation jars, CompileKotlinPlugin... plugins) { + jars.forEach(jar -> { + for (var plugin : plugins) { + if (jar.getName().matches(plugin.label)) { + plugins_.add(jar.getAbsolutePath()); + break; + } + } + }); + + return this; + } + // Combine Kotlin sources private Collection sources(Collection files, Collection directories) { var sources = new ArrayList<>(files); diff --git a/src/main/java/rife/bld/extension/CompileKotlinOptions.java b/src/main/java/rife/bld/extension/CompileKotlinOptions.java index 80a7435..ca63632 100644 --- a/src/main/java/rife/bld/extension/CompileKotlinOptions.java +++ b/src/main/java/rife/bld/extension/CompileKotlinOptions.java @@ -265,6 +265,15 @@ public class CompileKotlinOptions { return this; } + /** + * Indicates whether the {@link #jdkRelease(String) jdkRelease} was set. + * + * @return {@code true} if the release was set; or {@code false} otherwise + */ + public boolean hasRelease() { + return jdkRelease_ != null; + } + /** * Include the Kotlin runtime into the resulting JAR file. Makes the resulting archive runnable on any Java-enabled * environment. @@ -317,7 +326,7 @@ public class CompileKotlinOptions { * Specify the target version of the generated JVM bytecode. * * @param version the target version - * @return this class insance + * @return this class instance * @see #jdkRelease(String) */ public CompileKotlinOptions jdkRelease(int version) { @@ -557,7 +566,7 @@ public class CompileKotlinOptions { * @param wError {@code true} or {@code false} * @return this class instance */ - public CompileKotlinOptions wErrpr(boolean wError) { + public CompileKotlinOptions wError(boolean wError) { wError_ = wError; return this; } diff --git a/src/main/java/rife/bld/extension/dokka/AnalysisPlatform.java b/src/main/java/rife/bld/extension/dokka/AnalysisPlatform.java index e74b888..eb996b7 100644 --- a/src/main/java/rife/bld/extension/dokka/AnalysisPlatform.java +++ b/src/main/java/rife/bld/extension/dokka/AnalysisPlatform.java @@ -17,7 +17,7 @@ package rife.bld.extension.dokka; /** - * Dokka analysis platforms. + * Dokka's analysis platforms. * * @author Erik C. Thauvin * @since 1.0 diff --git a/src/main/java/rife/bld/extension/dokka/SourceSet.java b/src/main/java/rife/bld/extension/dokka/SourceSet.java index 4e7b7fe..ba78a35 100644 --- a/src/main/java/rife/bld/extension/dokka/SourceSet.java +++ b/src/main/java/rife/bld/extension/dokka/SourceSet.java @@ -52,7 +52,7 @@ public class SourceSet { /** * Sets the platform used for setting up analysis. Default is {@link AnalysisPlatform#JVM} * - * @param analysisPlatform the analysis platfrom + * @param analysisPlatform the analysis platform * @return this operation instance */ public SourceSet analysisPlatform(AnalysisPlatform analysisPlatform) { @@ -424,7 +424,7 @@ public class SourceSet { } /** - * Sets Wwether to report undocumented declarations. + * Sets whether to report undocumented declarations. * * @param reportUndocumented {@code true} or {@code false} * @return this operation instance diff --git a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java index 77e95e6..54de25f 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOperationTest.java @@ -72,7 +72,6 @@ class CompileKotlinOperationTest { var op = new CompileKotlinOperation() .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example")) - .compileOptions(new CompileKotlinOptions().verbose(true)) .buildMainDirectory(mainDir) .buildTestDirectory(testDir) .compileMainClasspath(compileJars) @@ -80,6 +79,7 @@ class CompileKotlinOperationTest { .compileTestClasspath(compileJars) .compileTestClasspath(mainDir.getAbsolutePath()); + op.compileOptions().verbose(true); op.execute(); assertThat(tmpDir).isNotEmptyDirectory(); diff --git a/src/test/java/rife/bld/extension/CompileKotlinOptionsTest.java b/src/test/java/rife/bld/extension/CompileKotlinOptionsTest.java index f549b1e..d34c4d1 100644 --- a/src/test/java/rife/bld/extension/CompileKotlinOptionsTest.java +++ b/src/test/java/rife/bld/extension/CompileKotlinOptionsTest.java @@ -76,7 +76,7 @@ class CompileKotlinOptionsTest { .progressive(true) .scriptTemplates("name", "name2") .verbose(true) - .wErrpr(true) + .wError(true) .args(); var matches = List.of(