argFile() {
+ return argFile_;
+ }
+
/**
* Returns the formatted arguments.
*
@@ -153,13 +197,13 @@ public class CompileKotlinOptions {
// @argfile
if (!argFile_.isEmpty()) {
- argFile_.forEach(f -> args.add("@" + f));
+ argFile_.forEach(f -> args.add("@" + f.getAbsolutePath()));
}
// classpath
if (!classpath_.isEmpty()) {
args.add("-classpath");
- args.add(String.join(File.pathSeparator, classpath_));
+ args.add(classpath_.stream().map(File::getAbsolutePath).collect(Collectors.joining(File.pathSeparator)));
}
// expression
@@ -185,9 +229,9 @@ public class CompileKotlinOptions {
}
// jdk-home
- if (isNotBlank(jdkHome_)) {
+ if (jdkHome_ != null) {
args.add("-jdk-home");
- args.add(jdkHome_);
+ args.add(jdkHome_.getAbsolutePath());
}
// jdk-release
@@ -201,9 +245,9 @@ public class CompileKotlinOptions {
}
// kotlin-home
- if (isNotBlank(kotlinHome_)) {
+ if (kotlinHome_ != null) {
args.add("-kotlin-home");
- args.add(kotlinHome_);
+ args.add(kotlinHome_.getAbsolutePath());
}
// language-version
@@ -250,9 +294,9 @@ public class CompileKotlinOptions {
}
// path
- if (isNotBlank(path_)) {
+ if (path_ != null) {
args.add("-d");
- args.add(path_);
+ args.add(path_.getAbsolutePath());
}
// plugin
@@ -298,7 +342,22 @@ public class CompileKotlinOptions {
* @param paths one pr more paths
* @return this operation instance
*/
- public CompileKotlinOptions classpath(String... paths) {
+ public CompileOptions classpath(String... paths) {
+ Collections.addAll(classpath_, Arrays.stream(paths)
+ .map(File::new)
+ .toArray(File[]::new));
+ return this;
+ }
+
+ /**
+ * Search for class files in the specified paths.
+ *
+ * The classpath can contain file and directory paths, ZIP, or JAR files.
+ *
+ * @param paths one or more path
+ * @return this operation instance
+ */
+ public CompileOptions classpath(File... paths) {
Collections.addAll(classpath_, paths);
return this;
}
@@ -311,18 +370,27 @@ public class CompileKotlinOptions {
* @param paths the list of paths
* @return this operation instance
*/
- public CompileKotlinOptions classpath(Collection paths) {
+ public CompileOptions classpath(Collection paths) {
classpath_.addAll(paths);
return this;
}
+ /**
+ * Retrieves the class files classpath.
+ *
+ * @return the list of classpath
+ */
+ public Collection classpath() {
+ return classpath_;
+ }
+
/**
* Evaluate the given string as a Kotlin script.
*
* @param expression the expression
* @return this operation instance
*/
- public CompileKotlinOptions expression(String expression) {
+ public CompileOptions expression(String expression) {
expression_ = expression;
return this;
}
@@ -343,18 +411,27 @@ public class CompileKotlinOptions {
* @param includeRuntime {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions includeRuntime(boolean includeRuntime) {
+ public CompileOptions includeRuntime(boolean includeRuntime) {
includeRuntime_ = includeRuntime;
return this;
}
+ /**
+ * Indicates whether {@link #verbose(boolean)} was set.
+ *
+ * @return {@code true} if verbose was set; or {@code false} otherwise
+ */
+ public boolean isVerbose() {
+ return verbose_;
+ }
+
/**
* Generate metadata for Java 1.8 reflection on method parameters.
*
* @param javaParameters {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions javaParameters(boolean javaParameters) {
+ public CompileOptions javaParameters(boolean javaParameters) {
javaParameters_ = javaParameters;
return this;
}
@@ -365,7 +442,18 @@ public class CompileKotlinOptions {
* @param jdkHome the JDK home path
* @return this operation instance
*/
- public CompileKotlinOptions jdkHome(String jdkHome) {
+ public CompileOptions jdkHome(String jdkHome) {
+ jdkHome_ = new File(jdkHome);
+ return this;
+ }
+
+ /**
+ * Use a custom JDK home directory to include into the classpath if it differs from the default {@code JAVA_HOME}.
+ *
+ * @param jdkHome the JDK home path
+ * @return this operation instance
+ */
+ public CompileOptions jdkHome(File jdkHome) {
jdkHome_ = jdkHome;
return this;
}
@@ -381,7 +469,7 @@ public class CompileKotlinOptions {
* @param version the target version
* @return this operation instance
*/
- public CompileKotlinOptions jdkRelease(String version) {
+ public CompileOptions jdkRelease(String version) {
jdkRelease_ = version;
return this;
}
@@ -393,7 +481,7 @@ public class CompileKotlinOptions {
* @return this operation instance
* @see #jdkRelease(String)
*/
- public CompileKotlinOptions jdkRelease(int version) {
+ public CompileOptions jdkRelease(int version) {
jdkRelease_ = String.valueOf(version);
return this;
}
@@ -404,18 +492,27 @@ public class CompileKotlinOptions {
* @param jvmOptions one or more JVM option
* @return this operation instance
*/
- public CompileKotlinOptions jvmOptions(String... jvmOptions) {
+ public CompileOptions jvmOptions(String... jvmOptions) {
Collections.addAll(jvmOptions_, jvmOptions);
return this;
}
+ /**
+ * Retrieves the JVM options.
+ *
+ * @return the list of options
+ */
+ public Collection jvmOptions() {
+ return jvmOptions_;
+ }
+
/**
* Pass an option directly to JVM
*
* @param jvmOptions the list JVM options
* @return this operation instance
*/
- public CompileKotlinOptions jvmOptions(Collection jvmOptions) {
+ public CompileOptions jvmOptions(Collection jvmOptions) {
jvmOptions_.addAll(jvmOptions);
return this;
}
@@ -428,7 +525,7 @@ public class CompileKotlinOptions {
* @param target the target version
* @return this operation instance
*/
- public CompileKotlinOptions jvmTarget(String target) {
+ public CompileOptions jvmTarget(String target) {
jvmTarget_ = target;
return this;
}
@@ -440,7 +537,7 @@ public class CompileKotlinOptions {
* @return this operation instance
* @see #jvmTarget(String)
*/
- public CompileKotlinOptions jvmTarget(int target) {
+ public CompileOptions jvmTarget(int target) {
jvmTarget_ = String.valueOf(target);
return this;
}
@@ -451,18 +548,29 @@ public class CompileKotlinOptions {
* @param path the Kotlin home path
* @return this operation instance
*/
- public CompileKotlinOptions kotlinHome(String path) {
+ public CompileOptions kotlinHome(File path) {
kotlinHome_ = path;
return this;
}
+ /**
+ * Specify a custom path to the Kotlin compiler used for the discovery of runtime libraries.
+ *
+ * @param path the Kotlin home path
+ * @return this operation instance
+ */
+ public CompileOptions kotlinHome(String path) {
+ kotlinHome_ = new File(path);
+ return this;
+ }
+
/**
* Provide source compatibility with the specified version of Kotlin.
*
* @param version the language version
* @return this operation instance
*/
- public CompileKotlinOptions languageVersion(String version) {
+ public CompileOptions languageVersion(String version) {
languageVersion_ = version;
return this;
}
@@ -473,7 +581,7 @@ public class CompileKotlinOptions {
* @param name the module name
* @return this operation instance
*/
- public CompileKotlinOptions moduleName(String name) {
+ public CompileOptions moduleName(String name) {
moduleName_ = name;
return this;
}
@@ -484,7 +592,7 @@ public class CompileKotlinOptions {
* @param noJdk {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions noJdk(boolean noJdk) {
+ public CompileOptions noJdk(boolean noJdk) {
noJdk_ = noJdk;
return this;
}
@@ -495,7 +603,7 @@ public class CompileKotlinOptions {
* @param noReflect {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions noReflect(boolean noReflect) {
+ public CompileOptions noReflect(boolean noReflect) {
noReflect_ = noReflect;
return this;
}
@@ -507,7 +615,7 @@ public class CompileKotlinOptions {
* @param noStdLib {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions noStdLib(boolean noStdLib) {
+ public CompileOptions noStdLib(boolean noStdLib) {
noStdLib_ = noStdLib;
return this;
}
@@ -518,7 +626,7 @@ public class CompileKotlinOptions {
* @param noWarn {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions noWarn(boolean noWarn) {
+ public CompileOptions noWarn(boolean noWarn) {
noWarn_ = noWarn;
return this;
}
@@ -529,18 +637,27 @@ public class CompileKotlinOptions {
* @param annotations one or more annotation names
* @return this operation instance
*/
- public CompileKotlinOptions optIn(String... annotations) {
+ public CompileOptions optIn(String... annotations) {
Collections.addAll(optIn_, annotations);
return this;
}
+ /**
+ * Retrieves the opt-in fully qualified names.
+ *
+ * @return the list of fully qualified names
+ */
+ public Collection optIn() {
+ return optIn_;
+ }
+
/**
* Enable usages of API that requires opt-in with a requirement annotation with the given fully qualified name.
*
* @param annotations list of annotation names
* @return this operation instance
*/
- public CompileKotlinOptions optIn(Collection annotations) {
+ public CompileOptions optIn(Collection annotations) {
optIn_.addAll(annotations);
return this;
}
@@ -551,18 +668,27 @@ public class CompileKotlinOptions {
* @param options one or more compiler options
* @return this operation instance
*/
- public CompileKotlinOptions options(String... options) {
+ public CompileOptions options(String... options) {
Collections.addAll(options_, options);
return this;
}
+ /**
+ * Retrieves additional compiler options.
+ *
+ * @return the list of options
+ */
+ public Collection options() {
+ return options_;
+ }
+
/**
* Specify additional compiler options.
*
* @param options list of compiler options
* @return this operation instance
*/
- public CompileKotlinOptions options(Collection options) {
+ public CompileOptions options(Collection options) {
options_.addAll(options);
return this;
}
@@ -575,8 +701,8 @@ public class CompileKotlinOptions {
* @param path the location path
* @return this operation instance
*/
- public CompileKotlinOptions path(File path) {
- path_ = path.getAbsolutePath();
+ public CompileOptions path(File path) {
+ path_ = path;
return this;
}
@@ -588,8 +714,8 @@ public class CompileKotlinOptions {
* @param path the location path
* @return this operation instance
*/
- public CompileKotlinOptions path(String path) {
- path_ = path;
+ public CompileOptions path(String path) {
+ path_ = new File(path);
return this;
}
@@ -601,18 +727,27 @@ public class CompileKotlinOptions {
* @param value the plugin option value
* @return this operation instance
*/
- public CompileKotlinOptions plugin(String id, String optionName, String value) {
+ public CompileOptions plugin(String id, String optionName, String value) {
plugin_.add(id + ':' + optionName + ':' + value);
return this;
}
+ /**
+ * Retrieves the plugin options.
+ *
+ * @return the list ofoptions.
+ */
+ public Collection plugin() {
+ return plugin_;
+ }
+
/**
* Allow using declarations only from the specified version of Kotlin bundled libraries.
*
* @param progressive {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions progressive(boolean progressive) {
+ public CompileOptions progressive(boolean progressive) {
progressive_ = progressive;
return this;
}
@@ -625,11 +760,20 @@ public class CompileKotlinOptions {
* @param classNames one or more class names
* @return this operation instance
*/
- public CompileKotlinOptions scriptTemplates(String... classNames) {
+ public CompileOptions scriptTemplates(String... classNames) {
Collections.addAll(scriptTemplates_, classNames);
return this;
}
+ /**
+ * Retrieves the script templates.
+ *
+ * @return the list of templates.
+ */
+ public Collection scriptTemplates() {
+ return scriptTemplates_;
+ }
+
/**
* Script definition template classes.
*
@@ -638,7 +782,7 @@ public class CompileKotlinOptions {
* @param classNames the list class names
* @return this operation instance
*/
- public CompileKotlinOptions scriptTemplates(Collection classNames) {
+ public CompileOptions scriptTemplates(Collection classNames) {
scriptTemplates_.addAll(classNames);
return this;
}
@@ -649,7 +793,7 @@ public class CompileKotlinOptions {
* @param verbose {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions verbose(boolean verbose) {
+ public CompileOptions verbose(boolean verbose) {
verbose_ = verbose;
return this;
}
@@ -660,7 +804,7 @@ public class CompileKotlinOptions {
* @param wError {@code true} or {@code false}
* @return this operation instance
*/
- public CompileKotlinOptions wError(boolean wError) {
+ public CompileOptions wError(boolean wError) {
wError_ = wError;
return this;
}
diff --git a/src/main/java/rife/bld/extension/CompileKotlinPlugin.java b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java
similarity index 63%
rename from src/main/java/rife/bld/extension/CompileKotlinPlugin.java
rename to src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java
index 16c0424..7a3d94e 100644
--- a/src/main/java/rife/bld/extension/CompileKotlinPlugin.java
+++ b/src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package rife.bld.extension;
+package rife.bld.extension.kotlin;
/**
* Defines the known Kotlin compiler plugins match (regex) strings.
@@ -22,18 +22,18 @@ package rife.bld.extension;
* @author Erik C. Thauvin
* @since 1.0
*/
-public enum CompileKotlinPlugin {
- ALL_OPEN("^allopen-compiler-plugin-.*$"),
- ASSIGNMENT("^assignment-compiler-plugin-.*$"),
+public enum CompilerPlugin {
+ ALL_OPEN("^kotlin-allopen-compiler-plugin-.*$"),
+ ASSIGNMENT("^kotlin-assignment-compiler-plugin-.*$"),
KOTLIN_SERIALIZATION("^kotlin-serialization-compiler-plugin-.*$"),
- LOMBOK("^lombok-compiler-plugin-.*$"),
- NOARG("^noarg-compiler-plugin-.*$"),
- POWER_ASSERT("^power-assert-compiler-plugin-.*$"),
- SAM_WITH_RECEIVER("^sam-with-receiver-compiler-plugin-.*$");
+ LOMBOK("^kotlin-lombok-compiler-plugin-.*$"),
+ NOARG("^kotlin-noarg-compiler-plugin-.*$"),
+ POWER_ASSERT("^kotlin-power-assert-compiler-plugin-.*$"),
+ SAM_WITH_RECEIVER("^kotlin-sam-with-receiver-compiler-plugin-.*$");
- public final String label;
+ public final String regex;
- CompileKotlinPlugin(String label) {
- this.label = label;
+ CompilerPlugin(String regex) {
+ this.regex = regex;
}
}