String arguments should not be blank

This commit is contained in:
Erik C. Thauvin 2023-11-26 17:05:07 -08:00
parent 2a88bbb045
commit d800fda561
5 changed files with 33 additions and 16 deletions

View file

@ -15,7 +15,7 @@ To install, please refer to the [extensions documentation](https://github.com/ri
To compile the source code located in `src/main/kotlin` and `src/test/kotlin` from the current project:
```java
@BuildCommand(summary = "Compile the Kotlin project")
@BuildCommand(summary = "Compiles the Kotlin project")
public void compile() throws IOException {
new CompileKotlinOperation()
.fromProject(this)

View file

@ -32,8 +32,11 @@ public class ExampleBuild extends Project {
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
final var kotlin = version(1, 9, 21);
scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", version(1, 9, 21)));
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk7", kotlin))
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8", kotlin));
scope(test)
.include(dependency("org.jetbrains.kotlin:kotlin-test-junit5:1.9.21"))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
@ -57,7 +60,7 @@ public class ExampleBuild extends Project {
new ExampleBuild().start(args);
}
@BuildCommand(summary = "Compile the Kotlin project")
@BuildCommand(summary = "Compiles the Kotlin project")
@Override
public void compile() throws IOException {
// The source code located in src/main/kotlin and src/test/kotlin will be compiled

View file

@ -94,6 +94,16 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
}
}
/**
* Determines if the given string is not blank.
*
* @param s the string
* @return {@code true} if not blank, {@code false} otherwise.
*/
public static boolean isNotBlank(String s) {
return s != null && !s.isBlank();
}
/**
* Provides the main build destination directory.
*
@ -276,7 +286,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
args.add(destination.getAbsolutePath());
// friend-path
if (friendPaths != null) {
if (friendPaths != null && friendPaths.exists()) {
args.add("-Xfriend-paths=" + friendPaths.getAbsolutePath());
}

View file

@ -21,6 +21,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
/**
* Configuration for the Kotlin compiler options.
*
@ -105,9 +107,9 @@ public class CompileKotlinOptions {
*/
public List<String> args() {
var args = new ArrayList<String>();
// api-version
if (apiVersion_ != null) {
// api-isNotBlankversion
if (isNotBlank(apiVersion_)) {
args.add("-api-version");
args.add(apiVersion_);
}
@ -129,7 +131,7 @@ public class CompileKotlinOptions {
}
// jvm-target
if (jvmTarget_ != null) {
if (isNotBlank(jvmTarget_)) {
args.add("-jvm-target");
args.add(jvmTarget_);
}
@ -140,30 +142,30 @@ public class CompileKotlinOptions {
}
// jdk-home
if (jdkHome_ != null) {
if (isNotBlank(jdkHome_)) {
args.add("-jdk-home");
args.add(jdkHome_);
}
// jdk-release
if (jdkRelease_ != null) {
if (isNotBlank(jdkRelease_)) {
args.add("-Xjdk-release=" + jdkRelease_);
}
// kotlin-home
if (kotlinHome_ != null) {
if (isNotBlank(kotlinHome_)) {
args.add("-kotlin-home");
args.add(kotlinHome_);
}
// language-version
if (languageVersion_ != null) {
if (isNotBlank(languageVersion_)) {
args.add("-language-version");
args.add(languageVersion_);
}
// module-name
if (moduleName_ != null) {
if (isNotBlank(moduleName_)) {
args.add("-module-name");
args.add(moduleName_);
}
@ -202,7 +204,7 @@ public class CompileKotlinOptions {
}
// path
if (path_ != null) {
if (isNotBlank(path_)) {
args.add("-d");
args.add(path_);
}

View file

@ -27,6 +27,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
/**
* Builds documentation (javadoc, HTML, etc.) using Dokka.
*
@ -172,13 +174,13 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
}
// -moduleName
if (moduleName_ != null) {
if (isNotBlank(moduleName_)) {
args.add("-moduleName");
args.add(moduleName_);
}
// -moduleVersion
if (moduleVersion_ != null) {
if (isNotBlank(moduleVersion_)) {
args.add("-moduleVersion");
args.add(moduleVersion_);
}