diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java index 002a2e5..a108bdf 100644 --- a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java +++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java @@ -60,6 +60,7 @@ public class CompileOptions { private boolean progressive_; private boolean verbose_; private boolean wError_; + private boolean wExtra_; /** * Specify advanced compiler options. @@ -374,11 +375,16 @@ public class CompileOptions { args.add("-verbose"); } - // Werror + // Wwrror if (wError_) { args.add("-Werror"); } + // Wextra + if (wExtra_) { + args.add("-Wextra"); + } + // advanced option (X) if (!advancedOptions_.isEmpty()) { advancedOptions_.forEach(it -> args.add("-X" + it)); @@ -597,6 +603,15 @@ public class CompileOptions { return wError_; } + /** + * Indicates whether additional declaration, expression, and type compiler checks emit warnings. + * + * @return {@code true} or {@code false} + */ + public boolean isWExtra() { + return wExtra_; + } + /** * Generate metadata for Java 1.8 reflection on method parameters. * @@ -1071,4 +1086,15 @@ public class CompileOptions { wError_ = wError; return this; } + + /** + * Enable additional declaration, expression, and type compiler checks that emit warnings if {@code true}. + * + * @param wExtra {@code true} or {@code false} + * @return this operation instance + */ + public CompileOptions wExtra(boolean wExtra) { + wExtra_ = wExtra; + return this; + } } diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java index 129ab44..3bc9e25 100644 --- a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java +++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java @@ -71,7 +71,8 @@ class CompileOptionsTest { .progressive(true) .scriptTemplates("name", "name2") .verbose(true) - .wError(true); + .wError(true) + .wExtra(true); var matches = List.of( "-api-version", "11", @@ -97,7 +98,8 @@ class CompileOptionsTest { "-progressive", "-script-templates", "name,name2", "-verbose", - "-Werror"); + "-Werror", + "-Wextra"); var args = new ArrayList>(); args.add(options.args()); @@ -234,7 +236,8 @@ class CompileOptionsTest { .progressive(true) .scriptTemplates("template") .verbose(true) - .wError(true); + .wError(true) + .wExtra(true); try (var softly = new AutoCloseableSoftAssertions()) { for (var p : args) { @@ -340,7 +343,8 @@ class CompileOptionsTest { .progressive(true) .scriptTemplates("name", "name2") .verbose(true) - .wError(true); + .wError(true) + .wExtra(true); try (var softly = new AutoCloseableSoftAssertions()) { softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2"); @@ -368,6 +372,7 @@ class CompileOptionsTest { softly.assertThat(options.plugin()).containsExactly("id:name:value"); softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2"); softly.assertThat(options.isWError()).isTrue(); + softly.assertThat(options.isWExtra()).isTrue(); } } } diff --git a/src/test/resources/kotlinc-args.txt b/src/test/resources/kotlinc-args.txt index b3c7f27..e764231 100644 --- a/src/test/resources/kotlinc-args.txt +++ b/src/test/resources/kotlinc-args.txt @@ -22,4 +22,5 @@ -script-templates -verbose -Werror +-Wextra -X