Compare commits

...

5 commits

9 changed files with 51 additions and 20 deletions

View file

@ -12,7 +12,7 @@ jobs:
strategy: strategy:
matrix: matrix:
java-version: [17, 21, 23] java-version: [17, 21, 23]
kotlin-version: [1.9.24, 2.0.21] kotlin-version: [1.9.24, 2.0.21, 2.1.0]
steps: steps:
- name: Checkout source repository - name: Checkout source repository

View file

@ -1,7 +1,7 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.downloadLocation= bld.downloadLocation=
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.2 bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.3
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=
bld.version=2.1.0 bld.version=2.1.0

View file

@ -28,7 +28,7 @@ public class ExampleBuild extends Project {
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES); repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
final var kotlin = version(2, 0, 21); final var kotlin = version(2, 1, 0);
scope(compile) scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin));
scope(test) scope(test)
@ -58,14 +58,11 @@ public class ExampleBuild extends Project {
@Override @Override
public void compile() throws Exception { public void compile() throws Exception {
// The source code located in src/main/kotlin and src/test/kotlin will be compiled // The source code located in src/main/kotlin and src/test/kotlin will be compiled
new CompileKotlinOperation() var op = new CompileKotlinOperation()
.fromProject(this)
// .kotlinHome("path/to/kotlin") // .kotlinHome("path/to/kotlin")
// .kotlinc("path/to/kotlinc") // .kotlinc("path/to/kotlinc")
.execute(); .fromProject(this);
op.compileOptions().verbose(true);
// var op = new CompileKotlinOperation().fromProject(this); op.execute();
// op.compileOptions().verbose(true);
// op.execute();
} }
} }

View file

@ -4,7 +4,7 @@ new=/tmp/checkcliargs-new
old=/tmp/checkcliargs-old old=/tmp/checkcliargs-old
kotlinc -h 2>$new kotlinc -h 2>$new
~/.sdkman/candidates/kotlin/2.0.0/bin/kotlinc -h 2>$old ~/.sdkman/candidates/kotlin/2.1.0/bin/kotlinc -h 2>$old
code --diff --wait $old $new code --diff --wait $old $new

View file

@ -33,7 +33,7 @@ public class CompileKotlinOperationBuild extends Project {
public CompileKotlinOperationBuild() { public CompileKotlinOperationBuild() {
pkg = "rife.bld.extension"; pkg = "rife.bld.extension";
name = "bld-kotlin"; name = "bld-kotlin";
version = version(1, 0, 3, "SNAPSHOT"); version = version(1, 0, 3);
javaRelease = 17; javaRelease = 17;

View file

@ -406,9 +406,11 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
public CompileKotlinOperation fromProject(BaseProject project) { public CompileKotlinOperation fromProject(BaseProject project) {
project_ = project; project_ = project;
var env = System.getenv("KOTLIN_HOME"); if (kotlinHome_ == null) {
if (env != null) { var env = System.getenv("KOTLIN_HOME");
kotlinHome_ = new File(env); if (env != null) {
kotlinHome_ = new File(env);
}
} }
workDir_ = new File(project.workDirectory().getAbsolutePath()); workDir_ = new File(project.workDirectory().getAbsolutePath());

View file

@ -60,6 +60,7 @@ public class CompileOptions {
private boolean progressive_; private boolean progressive_;
private boolean verbose_; private boolean verbose_;
private boolean wError_; private boolean wError_;
private boolean wExtra_;
/** /**
* Specify advanced compiler options. * Specify advanced compiler options.
@ -374,11 +375,16 @@ public class CompileOptions {
args.add("-verbose"); args.add("-verbose");
} }
// Werror // Wwrror
if (wError_) { if (wError_) {
args.add("-Werror"); args.add("-Werror");
} }
// Wextra
if (wExtra_) {
args.add("-Wextra");
}
// advanced option (X) // advanced option (X)
if (!advancedOptions_.isEmpty()) { if (!advancedOptions_.isEmpty()) {
advancedOptions_.forEach(it -> args.add("-X" + it)); advancedOptions_.forEach(it -> args.add("-X" + it));
@ -597,6 +603,15 @@ public class CompileOptions {
return wError_; 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. * Generate metadata for Java 1.8 reflection on method parameters.
* *
@ -1071,4 +1086,15 @@ public class CompileOptions {
wError_ = wError; wError_ = wError;
return this; 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;
}
} }

View file

@ -71,7 +71,8 @@ class CompileOptionsTest {
.progressive(true) .progressive(true)
.scriptTemplates("name", "name2") .scriptTemplates("name", "name2")
.verbose(true) .verbose(true)
.wError(true); .wError(true)
.wExtra(true);
var matches = List.of( var matches = List.of(
"-api-version", "11", "-api-version", "11",
@ -97,7 +98,8 @@ class CompileOptionsTest {
"-progressive", "-progressive",
"-script-templates", "name,name2", "-script-templates", "name,name2",
"-verbose", "-verbose",
"-Werror"); "-Werror",
"-Wextra");
var args = new ArrayList<List<String>>(); var args = new ArrayList<List<String>>();
args.add(options.args()); args.add(options.args());
@ -234,7 +236,8 @@ class CompileOptionsTest {
.progressive(true) .progressive(true)
.scriptTemplates("template") .scriptTemplates("template")
.verbose(true) .verbose(true)
.wError(true); .wError(true)
.wExtra(true);
try (var softly = new AutoCloseableSoftAssertions()) { try (var softly = new AutoCloseableSoftAssertions()) {
for (var p : args) { for (var p : args) {
@ -340,7 +343,8 @@ class CompileOptionsTest {
.progressive(true) .progressive(true)
.scriptTemplates("name", "name2") .scriptTemplates("name", "name2")
.verbose(true) .verbose(true)
.wError(true); .wError(true)
.wExtra(true);
try (var softly = new AutoCloseableSoftAssertions()) { try (var softly = new AutoCloseableSoftAssertions()) {
softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2"); softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2");
@ -368,6 +372,7 @@ class CompileOptionsTest {
softly.assertThat(options.plugin()).containsExactly("id:name:value"); softly.assertThat(options.plugin()).containsExactly("id:name:value");
softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2"); softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2");
softly.assertThat(options.isWError()).isTrue(); softly.assertThat(options.isWError()).isTrue();
softly.assertThat(options.isWExtra()).isTrue();
} }
} }
} }

View file

@ -22,4 +22,5 @@
-script-templates -script-templates
-verbose -verbose
-Werror -Werror
-Wextra
-X -X