String arguments should not be blank
This commit is contained in:
parent
2a88bbb045
commit
d800fda561
5 changed files with 33 additions and 16 deletions
|
@ -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:
|
To compile the source code located in `src/main/kotlin` and `src/test/kotlin` from the current project:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@BuildCommand(summary = "Compile the Kotlin project")
|
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||||
public void compile() throws IOException {
|
public void compile() throws IOException {
|
||||||
new CompileKotlinOperation()
|
new CompileKotlinOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
|
|
|
@ -32,8 +32,11 @@ public class ExampleBuild extends Project {
|
||||||
autoDownloadPurge = true;
|
autoDownloadPurge = true;
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||||
|
|
||||||
|
final var kotlin = version(1, 9, 21);
|
||||||
scope(compile)
|
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)
|
scope(test)
|
||||||
.include(dependency("org.jetbrains.kotlin:kotlin-test-junit5:1.9.21"))
|
.include(dependency("org.jetbrains.kotlin:kotlin-test-junit5:1.9.21"))
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
|
||||||
|
@ -57,7 +60,7 @@ public class ExampleBuild extends Project {
|
||||||
new ExampleBuild().start(args);
|
new ExampleBuild().start(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Compile the Kotlin project")
|
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||||
@Override
|
@Override
|
||||||
public void compile() throws IOException {
|
public void compile() throws IOException {
|
||||||
// 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
|
||||||
|
|
|
@ -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.
|
* Provides the main build destination directory.
|
||||||
*
|
*
|
||||||
|
@ -276,7 +286,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
||||||
args.add(destination.getAbsolutePath());
|
args.add(destination.getAbsolutePath());
|
||||||
|
|
||||||
// friend-path
|
// friend-path
|
||||||
if (friendPaths != null) {
|
if (friendPaths != null && friendPaths.exists()) {
|
||||||
args.add("-Xfriend-paths=" + friendPaths.getAbsolutePath());
|
args.add("-Xfriend-paths=" + friendPaths.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration for the Kotlin compiler options.
|
* Configuration for the Kotlin compiler options.
|
||||||
*
|
*
|
||||||
|
@ -106,8 +108,8 @@ public class CompileKotlinOptions {
|
||||||
public List<String> args() {
|
public List<String> args() {
|
||||||
var args = new ArrayList<String>();
|
var args = new ArrayList<String>();
|
||||||
|
|
||||||
// api-version
|
// api-isNotBlankversion
|
||||||
if (apiVersion_ != null) {
|
if (isNotBlank(apiVersion_)) {
|
||||||
args.add("-api-version");
|
args.add("-api-version");
|
||||||
args.add(apiVersion_);
|
args.add(apiVersion_);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +131,7 @@ public class CompileKotlinOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// jvm-target
|
// jvm-target
|
||||||
if (jvmTarget_ != null) {
|
if (isNotBlank(jvmTarget_)) {
|
||||||
args.add("-jvm-target");
|
args.add("-jvm-target");
|
||||||
args.add(jvmTarget_);
|
args.add(jvmTarget_);
|
||||||
}
|
}
|
||||||
|
@ -140,30 +142,30 @@ public class CompileKotlinOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// jdk-home
|
// jdk-home
|
||||||
if (jdkHome_ != null) {
|
if (isNotBlank(jdkHome_)) {
|
||||||
args.add("-jdk-home");
|
args.add("-jdk-home");
|
||||||
args.add(jdkHome_);
|
args.add(jdkHome_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// jdk-release
|
// jdk-release
|
||||||
if (jdkRelease_ != null) {
|
if (isNotBlank(jdkRelease_)) {
|
||||||
args.add("-Xjdk-release=" + jdkRelease_);
|
args.add("-Xjdk-release=" + jdkRelease_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// kotlin-home
|
// kotlin-home
|
||||||
if (kotlinHome_ != null) {
|
if (isNotBlank(kotlinHome_)) {
|
||||||
args.add("-kotlin-home");
|
args.add("-kotlin-home");
|
||||||
args.add(kotlinHome_);
|
args.add(kotlinHome_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// language-version
|
// language-version
|
||||||
if (languageVersion_ != null) {
|
if (isNotBlank(languageVersion_)) {
|
||||||
args.add("-language-version");
|
args.add("-language-version");
|
||||||
args.add(languageVersion_);
|
args.add(languageVersion_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// module-name
|
// module-name
|
||||||
if (moduleName_ != null) {
|
if (isNotBlank(moduleName_)) {
|
||||||
args.add("-module-name");
|
args.add("-module-name");
|
||||||
args.add(moduleName_);
|
args.add(moduleName_);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +204,7 @@ public class CompileKotlinOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// path
|
// path
|
||||||
if (path_ != null) {
|
if (isNotBlank(path_)) {
|
||||||
args.add("-d");
|
args.add("-d");
|
||||||
args.add(path_);
|
args.add(path_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds documentation (javadoc, HTML, etc.) using Dokka.
|
* Builds documentation (javadoc, HTML, etc.) using Dokka.
|
||||||
*
|
*
|
||||||
|
@ -172,13 +174,13 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -moduleName
|
// -moduleName
|
||||||
if (moduleName_ != null) {
|
if (isNotBlank(moduleName_)) {
|
||||||
args.add("-moduleName");
|
args.add("-moduleName");
|
||||||
args.add(moduleName_);
|
args.add(moduleName_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -moduleVersion
|
// -moduleVersion
|
||||||
if (moduleVersion_ != null) {
|
if (isNotBlank(moduleVersion_)) {
|
||||||
args.add("-moduleVersion");
|
args.add("-moduleVersion");
|
||||||
args.add(moduleVersion_);
|
args.add(moduleVersion_);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue