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

@ -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_);
}