- * Such a file can contain compiler options with values and paths to the source files. - * Options and paths should be separated by whitespaces. For example: - *
- * The classpath can contain file and directory paths, ZIP, or JAR files. - * - * @param paths one pr more paths - * @return this operation instance - */ - public CompileKotlinOptions classpath(String... paths) { - classpath_.addAll(List.of(paths)); - return this; - } - - /** - * Search for class files in the specified paths. - *
- * The classpath can contain file and directory paths, ZIP, or JAR files.
- *
- * @param paths the list of paths
- * @return this operation instance
- */
- public CompileKotlinOptions classpath(Collection
- * Limit the API of the JDK in the classpath to the specified Java version. Automatically sets
- * {@link #jvmTarget(String) JVM target} version.
- *
- * Possible values are 1.8, 9, 10, ..., 21. The default value is 1.8.
- *
- * @param version the target version
- * @return this operation instance
- */
- public CompileKotlinOptions jdkRelease(String version) {
- jdkRelease_ = version;
- return this;
- }
-
- /**
- * Specify the target version of the generated JVM bytecode.
- *
- * @param version the target version
- * @return this operation instance
- * @see #jdkRelease(String)
- */
- public CompileKotlinOptions jdkRelease(int version) {
- jdkRelease_ = String.valueOf(version);
- return this;
- }
-
- /**
- * Specify the target version of the generated JVM bytecode.
- *
- * Possible values are 1.8, 9, 10, ..., 21. The default value is 1.8.
- *
- * @param target the target version
- * @return this operation instance
- */
- public CompileKotlinOptions jvmTarget(String target) {
- jvmTarget_ = target;
- return this;
- }
-
- /**
- * Specify the target version of the generated JVM bytecode.
- *
- * @param target the target version
- * @return this operation instance
- * @see #jvmTarget(String)
- */
- public CompileKotlinOptions jvmTarget(int target) {
- jvmTarget_ = String.valueOf(target);
- 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 CompileKotlinOptions kotlinHome(String path) {
- kotlinHome_ = 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) {
- languageVersion_ = version;
- return this;
- }
-
- /**
- * Set a custom name for the generated {@code .kotlin_module} file.
- *
- * @param name the module name
- * @return this operation instance
- */
- public CompileKotlinOptions moduleName(String name) {
- moduleName_ = name;
- return this;
- }
-
- /**
- * Don't automatically include the Java runtime into the classpath.
- *
- * @param noJdk {@code true} or {@code false}
- * @return this operation instance
- */
- public CompileKotlinOptions noJdk(boolean noJdk) {
- noJdk_ = noJdk;
- return this;
- }
-
- /**
- * Don't automatically include the Kotlin reflection ({@code kotlin-reflect.jar}) into the classpath.
- *
- * @param noReflect {@code true} or {@code false}
- * @return this operation instance
- */
- public CompileKotlinOptions noReflect(boolean noReflect) {
- noReflect_ = noReflect;
- return this;
- }
-
- /**
- * Don't automatically include the Kotlin/JVM stdlib ({@code kotlin-stdlib.jar}) and Kotlin reflection
- * ({@code kotlin-reflect.jar}) into the classpath.
- *
- * @param noStdLib {@code true} or {@code false}
- * @return this operation instance
- */
- public CompileKotlinOptions noStdLib(boolean noStdLib) {
- noStdLib_ = noStdLib;
- return this;
- }
-
- /**
- * Suppress the compiler from displaying warnings during compilation.
- *
- * @param noWarn {@code true} or {@code false}
- * @return this operation instance
- */
- public CompileKotlinOptions noWarn(boolean noWarn) {
- noWarn_ = noWarn;
- return this;
- }
-
- /**
- * Enable usages of API that requires opt-in with a requirement annotation with the given fully qualified name.
- *
- * @param annotations one or more annotation names
- * @return this operation instance
- */
- public CompileKotlinOptions optIn(String... annotations) {
- optIn_.addAll(List.of(annotations));
- return this;
- }
-
- /**
- * 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
- * The location can be a directory, a ZIP, or a JAR file.
- *
- * @param path the location path
- * @return this operation instance
- */
- public CompileKotlinOptions path(File path) {
- path_ = path.getAbsolutePath();
- return this;
- }
-
- /**
- * Place the generated class files into the specified location.
- *
- * The location can be a directory, a ZIP, or a JAR file.
- *
- * @param path the location path
- * @return this operation instance
- */
- public CompileKotlinOptions path(String path) {
- path_ = path;
- return this;
- }
-
- /**
- * Pass an option to a plugin.
- *
- * @param id the plugin ID
- * @param optionName the plugin option name
- * @param value the plugin option value
- * @return this operation instance
- */
- public CompileKotlinOptions plugin(String id, String optionName, String value) {
- plugin_.add(id + ':' + optionName + ':' + value);
- return this;
- }
-
- /**
- * 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) {
- progressive_ = progressive;
- return this;
- }
-
- /**
- * Script definition template classes.
- *
- * Use fully qualified class names.
- *
- * @param classNames one or more class names
- * @return this operation instance
- */
- public CompileKotlinOptions scriptTemplates(String... classNames) {
- scriptTemplates_.addAll(List.of(classNames));
- return this;
- }
-
- /**
- * Script definition template classes.
- *
- * Use fully qualified class names.
- *
- * @param classNames the list class names
- * @return this operation instance
- */
- public CompileKotlinOptions scriptTemplates(Collection
- * Used in incremental builds of multimodule projects.
- *
- * @param delayTemplateSubstitution the delay
- * @return this operation instance
- */
- public DokkaOperation delayTemplateSubstitution(Boolean delayTemplateSubstitution) {
- delayTemplateSubstitution_ = delayTemplateSubstitution;
- return this;
- }
-
- /**
- * Part of the {@link #execute execute} operation, constructs the command list to use for building the process.
- *
- * @since 1.5
- */
- @Override
- protected List
- * Sets the {@link #sourceSet sourceSet}, {@link SourceSet#jdkVersion jdkVersion}, {@link #moduleName moduleName}
- * and {@link SourceSet#classpath(String...) classpath} from the project.
- *
- * @param project the project to configure the operation from
- */
- @Override
- public DokkaOperation fromProject(BaseProject project) {
- project_ = project;
- sourceSet_ = new SourceSet()
- .src(new File(project.srcMainDirectory(), "kotlin").getAbsolutePath())
- .classpath(project.compileClasspathJars())
- .classpath(project.providedClasspathJars());
- if (project.javaRelease() != null) {
- sourceSet_ = sourceSet_.jdkVersion(project.javaRelease());
- }
- moduleName_ = project.name();
- return this;
- }
-
- /**
- * Sets whether to fail documentation generation if Dokka has emitted a warning or an error.
- *
- * Whether to fail documentation generation if Dokka has emitted a warning or an error. The process waits until all
- * errors and warnings have been emitted first.
- *
- * This setting works well with {@link SourceSet#reportUndocumented}
- *
- * @param failOnWarning {@code true} or {@code false}
- * @return this operation instance
- */
- public DokkaOperation failOnWarning(Boolean failOnWarning) {
- failOnWarning_ = failOnWarning;
- return this;
- }
-
- /**
- * Set the global external documentation links.
- *
- * @param url the external documentation URL
- * @param packageListUrl the external documentation package list URL
- * @return this operation instance
- */
- public DokkaOperation globalLinks(String url, String packageListUrl) {
- globalLinks_.put(url, packageListUrl);
- return this;
- }
-
- /**
- * Set the global external documentation links.
- *
- * @param globalLinks the map of global links
- * @return this operation instance
- * @see #globalSrcLink(String...) #globalSrcLink(String...)#globalSrcLink(String...)
- */
- public DokkaOperation globalLinks(Map
- * Using format:
- *
- * Using format:
- *
- * The contents of specified files are parsed and embedded into documentation as module and package descriptions.
- *
- * This can be configured on per-package basis.
- *
- * @param files one or more files
- * @return this operation instance
- */
- public DokkaOperation includes(String... files) {
- includes_.addAll(Arrays.asList(files));
- return this;
- }
-
- /**
- * Sets the Markdown files that contain module and package documentation.
- *
- * The contents of specified files are parsed and embedded into documentation as module and package descriptions.
- *
- * This can be configured on per-package basis.
- *
- * @param files the list of files
- * @return this operation instance
- */
- public DokkaOperation includes(Collection
- * The display name used to refer to the module. It is used for the table of contents, navigation, logging, etc.
- *
- * @param moduleName the project/module name
- * @return this operation instance
- */
- public DokkaOperation moduleName(String moduleName) {
- moduleName_ = moduleName;
- return this;
- }
-
- /**
- * Set the documented version.
- *
- * @param version the version
- * @return this operation instance
- */
- public DokkaOperation moduleVersion(String version) {
- moduleVersion_ = version;
- return this;
- }
-
- /**
- * Sets whether to suppress obvious functions such as inherited from
- * kotlin.Any and {@link java.lang.Object}.
- *
- * A function is considered to be obvious if it is:
- *
- * This includes package-lists used for generating external documentation links. For example, to make classes from
- * the standard library clickable.
- *
- * Setting this to true can significantly speed up build times in certain cases, but can also worsen documentation
- * quality and user experience. For example, by not resolving class/member links from your dependencies, including
- * the standard library.
- *
- * Note: You can cache fetched files locally and provide them to Dokka as local paths.
- *
- * @param offlineMode the offline mode
- * @return this operation instance
- * @see SourceSet#externalDocumentationLinks(String, String)
- */
- public DokkaOperation offlineMode(Boolean offlineMode) {
- offlineMode_ = offlineMode;
- return this;
- }
-
- /**
- * Sets the output directory path, {@code ./dokka} by default.
- *
- * The directory to where documentation is generated, regardless of output format.
- *
- * @param outputDir the output directory
- * @return this operation instance
- */
- public DokkaOperation outputDir(File outputDir) {
- outputDir_ = outputDir;
- return this;
- }
-
- /**
- * Sets the output directory path, {@code ./dokka} by default.
- *
- * The directory to where documentation is generated, regardless of output format.
- *
- * @param outputDir the output directory
- * @return this operation instance
- */
- public DokkaOperation outputDir(String outputDir) {
- outputDir_ = new File(outputDir);
- return this;
- }
-
- /**
- * Sets the Dokka {@link OutputFormat output format}.
- *
- * @param format The {@link OutputFormat output format}
- * @return this operation instance
- */
- public DokkaOperation outputFormat(OutputFormat format) {
- pluginsClasspath_.clear();
- if (format.equals(OutputFormat.JAVADOC)) {
- pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
- JAVADOC_PLUGIN_REGEXP));
- } else if (format.equals(OutputFormat.HTML)) {
- pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
- HTML_PLUGIN_REGEXP));
- } else if (format.equals(OutputFormat.MARKDOWN)) {
- pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
- GFM_PLUGIN_REGEXP));
- } else if (format.equals(OutputFormat.JEKYLL)) {
- pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
- JEKYLL_PLUGIN_REGEXP));
- }
- return this;
- }
-
- /**
- * Sets the configuration for Dokka plugins.
- *
- * @param name The fully-qualified plugin name
- * @param jsonConfiguration The plugin JSON configuration
- * @return this operation instance
- */
- public DokkaOperation pluginConfigurations(String name, String jsonConfiguration) {
- pluginsConfiguration_.put(name, jsonConfiguration);
- return this;
- }
-
- /**
- * Sets the configuration for Dokka plugins.
- *
- * @param pluginConfiguratione the map of configurations
- * @return this operation instance
- * @see #pluginConfigurations(String, String)
- */
- public DokkaOperation pluginConfigurations(Map
- * Individual and additional configuration of Kotlin source sets.
- *
- * @param sourceSet the source set configurations
- * @return this operation instance
- */
- public DokkaOperation sourceSet(SourceSet sourceSet) {
- sourceSet_ = sourceSet;
- return this;
- }
-
- /**
- * Sets whether to suppress inherited members that aren't explicitly overridden in a given class.
- *
- * @param suppressInheritedMembers {@code true} or {@code false}
- * @return this operation instance
- */
- public DokkaOperation suppressInheritedMembers(Boolean suppressInheritedMembers) {
- suppressInheritedMembers_ = suppressInheritedMembers;
- return this;
- }
-}
diff --git a/src/main/java/rife/bld/extension/dokka/LoggingLevel.java b/src/main/java/rife/bld/extension/dokka/LoggingLevel.java
deleted file mode 100644
index b493e11..0000000
--- a/src/main/java/rife/bld/extension/dokka/LoggingLevel.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2023-2024 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package rife.bld.extension.dokka;
-
-/**
- * Dokka logging levels.
- *
- * @author Erik C. Thauvin
- * @since 1.0
- */
-public enum LoggingLevel {
- DEBUG, PROGRESS, INFO, WARN, ERROR
-}
diff --git a/src/main/java/rife/bld/extension/dokka/OutputFormat.java b/src/main/java/rife/bld/extension/dokka/OutputFormat.java
deleted file mode 100644
index 0d4a2c0..0000000
--- a/src/main/java/rife/bld/extension/dokka/OutputFormat.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2023-2024 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package rife.bld.extension.dokka;
-
-/**
- * Dokka output formats.
- *
- * @author Erik C. Thauvin
- * @since 1.0
- */
-public enum OutputFormat {
- JAVADOC, JEKYLL, HTML, MARKDOWN
-}
diff --git a/src/main/java/rife/bld/extension/dokka/SourceSet.java b/src/main/java/rife/bld/extension/dokka/SourceSet.java
deleted file mode 100644
index 28aedd8..0000000
--- a/src/main/java/rife/bld/extension/dokka/SourceSet.java
+++ /dev/null
@@ -1,680 +0,0 @@
-/*
- * Copyright 2023-2024 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package rife.bld.extension.dokka;
-
-import java.io.File;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Configuration for a Dokka source set.
- *
- * @author Erik C. Thauvin
- * @since 1.0
- */
-public class SourceSet {
- private static final String SEMICOLON = ";";
- private final Collection
- * Platform to be used for setting up code analysis and {@code @sample} environment.
- *
- * @param analysisPlatform the analysis platform
- * @return this operation instance
- */
- public SourceSet analysisPlatform(AnalysisPlatform analysisPlatform) {
- analysisPlatform_ = analysisPlatform;
- return this;
- }
-
- /**
- * Sets the Kotlin API version used for setting up analysis and samples.
- *
- * @param apiVersion the api version
- * @return this operation instance
- */
- public SourceSet apiVersion(String apiVersion) {
- apiVersion_ = apiVersion;
- return this;
- }
-
- /**
- * Sets the Kotlin API version used for setting up analysis and samples.
- *
- * @param apiVersion the api version
- * @return this operation instance
- */
- public SourceSet apiVersion(int apiVersion) {
- apiVersion_ = String.valueOf(apiVersion);
- return this;
- }
-
- /**
- * Returns the formatted arguments.
- *
- * @return the arguments
- */
- public List
- * This is useful if some types that come from dependencies are not resolved/picked up automatically.
- *
- * This option accepts both {@code .jar} and {@code .klib} files.
- *
- * @param files one or more file
- * @return this operation instance
- */
- public SourceSet classpath(String... files) {
- classpath_.addAll(Arrays.asList(files));
- return this;
- }
-
- /**
- * Sets classpath for analysis and interactive samples.
- *
- * This is useful if some types that come from dependencies are not resolved/picked up automatically.
- *
- * This option accepts both {@code .jar} and {@code .klib} files.
- *
- * @param files the list of files
- * @return this operation instance
- */
- public SourceSet classpath(Collection
- * This is useful if some types that come from dependencies are not resolved/picked up automatically.
- *
- * This option accepts both {@code .jar} and {@code .klib} files.
- *
- * @param files the list of files
- * @return this operation instance
- */
- public SourceSet classpath(List
- * The name is used both externally (for example, the source set name is visible to documentation readers) and
- * internally (for example, for logging messages of {@link #reportUndocumented reportUndocumented}).
- *
- * The platform name can be used if you don't have a better alternative.
- *
- * @param displayName the display name
- * @return this operation instance
- */
- public SourceSet displayName(String displayName) {
- displayName_ = displayName;
- return this;
- }
-
- /**
- * Sets visibilities to be documented.
- *
- * This can be used if you want to document protected/internal/private declarations, as well as if you want to
- * exclude public declarations and only document internal API.
- *
- * This can be configured on per-package basis.
- *
- * @param visibilities one or more visibilities
- * @return this operation instance
- */
- public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) {
- documentedVisibilities_.addAll(Arrays.asList(visibilities));
- return this;
- }
-
- /**
- * Sets the external documentation links.
- *
- * A set of parameters for external documentation links that is applied only for this source set.
- *
- * @param url the external documentation URL
- * @param packageListUrl the external documentation package list URL
- * @return this operation instance
- */
- public SourceSet externalDocumentationLinks(String url, String packageListUrl) {
- externalDocumentationLinks_.put(url, packageListUrl);
- return this;
- }
-
- /**
- * Sets the external documentation links.
- *
- * A set of parameters for external documentation links that is applied only for this source set.
- *
- * @param externalDocumentationLinks the map of external documentation links
- * @return this operation instance
- * @see #externalDocumentationLinks(String, String)
- */
- public SourceSet externalDocumentationLinks(Map
- * A list of Markdown files that contain module and package documentation.
- *
- * The contents of the specified files are parsed and embedded into documentation as module and package
- * descriptions.
- *
- * @param files one or more files
- * @return this operation instance
- */
- public SourceSet includes(String... files) {
- includes_.addAll(Arrays.asList(files));
- return this;
- }
-
- /**
- * Sets the Markdown files that contain module and package documentation.
- *
- * A list of Markdown files that contain module and package documentation.
- *
- * The contents of the specified files are parsed and embedded into documentation as module and package
- * descriptions.
- *
- * @param files the list of files
- * @return this operation instance
- */
- public SourceSet includes(Collection
- * The JDK version to use when generating external documentation links for Java types.
- *
- * For example, if you use {@link java.util.UUID} in some public declaration signature, and this option is set to 8,
- * Dokka generates an external documentation link to JDK 8 Javadocs for it.
- *
- * @param jdkVersion the JDK version
- * @return this operation instance
- */
- public SourceSet jdkVersion(String jdkVersion) {
- jdkVersion_ = jdkVersion;
- return this;
- }
-
- /**
- * Sets the version of JDK to use for linking to JDK Javadocs.
- *
- * The JDK version to use when generating external documentation links for Java types.
- *
- * For example, if you use {@link java.util.UUID} in some public declaration signature, and this option is set to 8,
- * Dokka generates an external documentation link to JDK 8 Javadocs for it.
- *
- * @param jdkVersion the JDK version
- * @return this operation instance
- */
- public SourceSet jdkVersion(int jdkVersion) {
- jdkVersion_ = String.valueOf(jdkVersion);
- return this;
- }
-
- /**
- * Sets the language version used for setting up analysis and samples.
- *
- * @param languageVersion the language version
- * @return this operation instance
- */
- public SourceSet languageVersion(String languageVersion) {
- languageVersion_ = languageVersion;
- return this;
- }
-
- /**
- * Sets the language version used for setting up analysis and samples.
- *
- * @param languageVersion the language version
- * @return this operation instance
- */
- public SourceSet languageVersion(int languageVersion) {
- languageVersion_ = String.valueOf(languageVersion);
- return this;
- }
-
- /**
- * Sets whether to generate links to JDK Javadocs.
- *
- * Whether to generate external documentation links to JDK's Javadocs.
- *
- * The version of JDK Javadocs is determined by the {@link #jdkVersion jdkVersion} option.
- *
- * Note: Links are generated when noJdkLink is set to false.
- *
- * @param noJdkLink {@code true} or {@code false}
- * @return this operation instance
- */
- public SourceSet noJdkLink(Boolean noJdkLink) {
- noJdkLink_ = noJdkLink;
- return this;
- }
-
- /**
- * Sets whether to create pages for empty packages.
- *
- * Whether to skip packages that contain no visible declarations after various filters have been applied.
- *
- * @param noSkipEmptyPackages {@code true} or {@code false}
- * @return this operation instance
- */
- public SourceSet noSkipEmptyPackages(boolean noSkipEmptyPackages) {
- noSkipEmptyPackages_ = noSkipEmptyPackages;
- return this;
- }
-
- /**
- * Sets whether to generate links to Standard library.
- *
- * Whether to generate external documentation links that lead to the API reference documentation of Kotlin's
- * standard library.
- *
- * Note: Links are generated when noStdLibLink is set to {@code false}.
- *
- * @param noStdlibLink {@code true} or {@code false}
- * @return this operation instance
- */
- public SourceSet noStdlibLink(Boolean noStdlibLink) {
- noStdlibLink_ = noStdlibLink;
- return this;
- }
-
- /**
- * Set the list of package source set configuration.
- *
- * A set of parameters specific to matched packages within this source set.
- *
- * Using format:
- *
- * A set of parameters specific to matched packages within this source set.
- *
- * Using format:
- *
- * Whether to emit warnings about visible undocumented declarations, that is declarations without KDocs after they
- * have been filtered by documentedVisibilities and other filters.
- *
- * This setting works well with {@link DokkaOperation#failOnWarning}.
- *
- * This can be configured on per-package basis.
- *
- * @param reportUndocumented {@code true} or {@code false}
- * @return this operation instance
- */
- public SourceSet reportUndocumented(Boolean reportUndocumented) {
- reportUndocumented_ = reportUndocumented;
- return this;
- }
-
- /**
- * Set the list of directories or files that contain sample functions.
- *
- * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc
- * tag.
- *
- * @param samples the list of samples
- * @return this operation instance
- */
- public SourceSet samples(Collection
- * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc
- * tag.
- *
- * @param samples nne or more samples
- * @return this operation instance
- */
- public SourceSet samples(String... samples) {
- samples_.addAll(List.of(samples));
- return this;
- }
-
- /**
- * Sets whether to skip deprecated declarations.
- *
- * Whether to document declarations annotated with {@code @Deprecated}.
- *
- * This can be configured on per-package basis.
- *
- * @param skipDeprecated {@code true} or {@code false}
- * @return this operation instance
- */
- public SourceSet skipDeprecated(boolean skipDeprecated) {
- skipDeprecated_ = skipDeprecated;
- return this;
- }
-
- /**
- * Sets the name of the source set. Default is {@code main}.
- *
- * @param sourceSetName the source set name.
- * @return this operation instance
- */
- public SourceSet sourceSetName(String sourceSetName) {
- sourceSetName_ = sourceSetName;
- return this;
- }
-
- /**
- * Sets the source code roots to be analyzed and documented.
- *
- * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual
- * {@code .kt} / {@code .java} files.
- *
- * @param src the list of source code roots
- * @return this operation instance
- */
- public SourceSet src(Collection
- * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual
- * {@code .kt} / {@code .java} files.
- *
- * @param src pne ore moe source code roots
- * @return this operation instance
- */
- public SourceSet src(String... src) {
- src_.addAll(List.of(src));
- return this;
- }
-
- /**
- * Sets the mapping between a source directory and a Web service for browsing the code.
- *
- * @param srcPath the source path
- * @param remotePath the remote path
- * @param lineSuffix the line suffix
- * @return this operation instance
- */
- public SourceSet srcLink(String srcPath, String remotePath, String lineSuffix) {
- srcLinks_.put(srcPath, remotePath + lineSuffix);
- return this;
- }
-
- /**
- * Sets the paths to files to be suppressed.
- *
- * The files to be suppressed when generating documentation.
- *
- * @param suppressedFiles the list of suppressed files
- * @return this operation instance
- */
- public SourceSet suppressedFiles(Collection
- * The files to be suppressed when generating documentation.
- *
- * @param suppressedFiles one or moe suppressed files
- * @return this operation instance
- */
- public SourceSet suppressedFiles(String... suppressedFiles) {
- suppressedFiles_.addAll(Arrays.asList(suppressedFiles));
- return this;
- }
-}
diff --git a/src/main/java/rife/bld/extension/kotlin/CompileOptions.java b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java
new file mode 100644
index 0000000..e43adc8
--- /dev/null
+++ b/src/main/java/rife/bld/extension/kotlin/CompileOptions.java
@@ -0,0 +1,1087 @@
+/*
+ * Copyright 2023-2025 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rife.bld.extension.kotlin;
+
+import rife.bld.extension.CompileKotlinOperation;
+import rife.bld.operations.AbstractToolProviderOperation;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
+
+/**
+ * Configuration for the Kotlin compiler options.
+ *
+ * @author Erik C. Thauvin
+ * @since 1.0
+ */
+public class CompileOptions {
+ private static final Logger LOGGER = Logger.getLogger(CompileOptions.class.getName());
+ private final Collection
+ * Such a file can contain compiler options with values and paths to the source files.
+ * Options and paths should be separated by whitespaces. For example:
+ *
+ * Such a file can contain compiler options with values and paths to the source files.
+ * Options and paths should be separated by whitespaces. For example:
+ *
+ * Such a file can contain compiler options with values and paths to the source files.
+ * Options and paths should be separated by whitespaces. For example:
+ *
+ * The classpath can contain file and directory paths, ZIP, or JAR files.
+ *
+ * @param paths one pr more paths
+ * @return this operation instance
+ * @see #classpathStrings(Collection)
+ */
+ public CompileOptions classpath(String... paths) {
+ return classpathStrings(List.of(paths));
+ }
+
+ /**
+ * 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
+ * @see #classpath(Collection)
+ */
+ public CompileOptions classpath(File... paths) {
+ return classpath(List.of(paths));
+ }
+
+ /**
+ * 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
+ * @see #classpathPaths(Collection)
+ */
+ public CompileOptions classpath(Path... paths) {
+ return classpathPaths(List.of(paths));
+ }
+
+ /**
+ * Search for class files in the specified paths.
+ *
+ * The classpath can contain file and directory paths, ZIP, or JAR files.
+ *
+ * @param paths the search paths
+ * @return this operation instance
+ * @see #classpath(File...)
+ */
+ public CompileOptions classpath(Collection
+ * The classpath can contain file and directory paths, ZIP, or JAR files.
+ *
+ * @param paths one pr more paths
+ * @return this operation instance
+ * @see #classpath(Path...)
+ */
+ public CompileOptions classpathPaths(Collection
+ * The classpath can contain file and directory paths, ZIP, or JAR files.
+ *
+ * @param paths one pr more paths
+ * @return this operation instance
+ * @see #classpath(String...)
+ */
+ public CompileOptions classpathStrings(Collection
+ * Limit the API of the JDK in the classpath to the specified Java version. Automatically sets
+ * {@link #jvmTarget(String) JVM target} version.
+ *
+ * Possible values are 1.8, 9, 10, ..., 23. The default value is 1.8.
+ *
+ * @param version the target version
+ * @return this operation instance
+ */
+ public CompileOptions jdkRelease(String version) {
+ jdkRelease_ = version;
+ return this;
+ }
+
+ /**
+ * Compile against the specified JDK API version.
+ *
+ * Limit the API of the JDK in the classpath to the specified Java version. Automatically sets
+ * {@link #jvmTarget(String) JVM target} version.
+ *
+ * @param version the target version
+ * @return this operation instance
+ * @see #jdkRelease(String)
+ */
+ public CompileOptions jdkRelease(int version) {
+ return jdkRelease(String.valueOf(version));
+ }
+
+ /**
+ * Specify the target version of the generated JVM bytecode.
+ *
+ * @param target the target version
+ * @return this operation instance
+ * @see #jvmTarget(String)
+ */
+ public CompileOptions jvmTarget(int target) {
+ return jvmTarget(String.valueOf(target));
+ }
+
+ /**
+ * Specify the target version of the generated JVM bytecode.
+ *
+ * Possible values are 1.8, 9, 10, ..., 23. The default value is 1.8.
+ *
+ * @param target the target version
+ * @return this operation instance
+ */
+ public CompileOptions jvmTarget(String target) {
+ jvmTarget_ = target;
+ return this;
+ }
+
+ /**
+ * Retrieves the target version of the generated JVM bytecode.
+ *
+ * @return the target version
+ */
+ public String jvmTarget() {
+ return jvmTarget_;
+ }
+
+ /**
+ * 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(File path) {
+ kotlinHome_ = path;
+ return this;
+ }
+
+ /**
+ * Retrieves the custom path of the Kotlin compiler.
+ *
+ * @return the Kotlin home path
+ */
+ public File kotlinHome() {
+ return kotlinHome_;
+ }
+
+ /**
+ * 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(Path path) {
+ return kotlinHome(path.toFile());
+ }
+
+ /**
+ * 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) {
+ return kotlinHome(new File(path));
+ }
+
+ /**
+ * Provide source compatibility with the specified version of Kotlin.
+ *
+ * @param version the language version
+ * @return this operation instance
+ */
+ public CompileOptions languageVersion(String version) {
+ languageVersion_ = version;
+ return this;
+ }
+
+ /**
+ * Retrieves the {@link #languageVersion(String) language version}.
+ *
+ * @return the language version
+ */
+ public String languageVersion() {
+ return languageVersion_;
+ }
+
+ /**
+ * Set a custom name for the generated {@code .kotlin_module} file.
+ *
+ * @param name the module name
+ * @return this operation instance
+ */
+ public CompileOptions moduleName(String name) {
+ moduleName_ = name;
+ return this;
+ }
+
+ /**
+ * Retrieves the {@link #moduleName(String) module name}.
+ *
+ * @return the module name
+ */
+ public String moduleName() {
+ return moduleName_;
+ }
+
+ /**
+ * Don't automatically include the Java runtime into the classpath.
+ *
+ * @param noJdk {@code true} or {@code false}
+ * @return this operation instance
+ */
+ public CompileOptions noJdk(boolean noJdk) {
+ noJdk_ = noJdk;
+ return this;
+ }
+
+ /**
+ * Don't automatically include the Kotlin reflection ({@code kotlin-reflect.jar}) into the classpath.
+ *
+ * @param noReflect {@code true} or {@code false}
+ * @return this operation instance
+ */
+ public CompileOptions noReflect(boolean noReflect) {
+ noReflect_ = noReflect;
+ return this;
+ }
+
+ /**
+ * Don't automatically include the Kotlin/JVM stdlib ({@code kotlin-stdlib.jar}) and Kotlin reflection
+ * ({@code kotlin-reflect.jar}) into the classpath.
+ *
+ * @param noStdLib {@code true} or {@code false}
+ * @return this operation instance
+ */
+ public CompileOptions noStdLib(boolean noStdLib) {
+ noStdLib_ = noStdLib;
+ return this;
+ }
+
+ /**
+ * Suppress the compiler from displaying warnings during compilation.
+ *
+ * @param noWarn {@code true} or {@code false}
+ * @return this operation instance
+ */
+ public CompileOptions noWarn(boolean noWarn) {
+ noWarn_ = noWarn;
+ return this;
+ }
+
+ /**
+ * Enable usages of API that requires opt-in with a requirement annotation with the given fully qualified name.
+ *
+ * @param annotations one or more annotation names
+ * @return this operation instance
+ */
+ public CompileOptions optIn(String... annotations) {
+ return optIn(List.of(annotations));
+ }
+
+ /**
+ * Retrieves the opt-in fully qualified names.
+ *
+ * @return the fully qualified names
+ */
+ public Collection
+ * The location can be a directory, a ZIP, or a JAR file.
+ *
+ * @param path the location path
+ * @return this operation instance
+ */
+ public CompileOptions path(File path) {
+ path_ = path;
+ return this;
+ }
+
+ /**
+ * Retrieves the location to place generated class files into.
+ *
+ * @return the location path.
+ */
+ public File path() {
+ return path_;
+ }
+
+ /**
+ * Place the generated class files into the specified location.
+ *
+ * The location can be a directory, a ZIP, or a JAR file.
+ *
+ * @param path the location path
+ * @return this operation instance
+ */
+ public CompileOptions path(Path path) {
+ return path(path.toFile());
+ }
+
+ /**
+ * Place the generated class files into the specified location.
+ *
+ * The location can be a directory, a ZIP, or a JAR file.
+ *
+ * @param path the location path
+ * @return this operation instance
+ */
+ public CompileOptions path(String path) {
+ return path(new File(path));
+ }
+
+ /**
+ * Pass an option to a plugin.
+ *
+ * @param id the plugin ID
+ * @param optionName the plugin option name
+ * @param value the plugin option value
+ * @return this operation instance
+ */
+ public CompileOptions plugin(String id, String optionName, String value) {
+ plugin_.add(id + ':' + optionName + ':' + value);
+ return this;
+ }
+
+ /**
+ * Retrieves the plugin options.
+ *
+ * @return the plugin options.
+ */
+ public Collection
+ * Use fully qualified class names.
+ *
+ * @param classNames one or more class names
+ * @return this operation instance
+ */
+ public CompileOptions scriptTemplates(String... classNames) {
+ return scriptTemplates(List.of(classNames));
+ }
+
+ /**
+ * Retrieves the script templates.
+ *
+ * @return the script templates.
+ */
+ public Collection
+ * Use fully qualified class names.
+ *
+ * @param classNames the class names
+ * @return this operation instance
+ */
+ public CompileOptions scriptTemplates(Collection
- *
- *
- * @param options ome pr more package configurations
- * @return this operation instance
- */
- public DokkaOperation globalPackageOptions(String... options) {
- globalPackageOptions_.addAll(Arrays.asList(options));
- return this;
- }
-
- /**
- * Sets the global list of package configurations.
- *
- *
- *
- * @param options the list of package configurations
- * @return this operation instance
- */
- public DokkaOperation globalPackageOptions(Collection
- *
- *
- * @param noSuppressObviousFunctions {@code true} or {@code false}
- * @return this operation instance
- */
- public DokkaOperation noSuppressObviousFunctions(Boolean noSuppressObviousFunctions) {
- noSuppressObviousFunctions_ = noSuppressObviousFunctions;
- return this;
- }
-
- /**
- * Sets whether to resolve remote files/links over network.
- *
- *
- *
- * @param perPackageOptions the list of per package options
- * @return this operation instance
- */
- public SourceSet perPackageOptions(Collection
- *
- *
- * @param perPackageOptions the list of per package options
- * @return this operation instance
- */
- public SourceSet perPackageOptions(String... perPackageOptions) {
- perPackageOptions_.addAll(List.of(perPackageOptions));
- return this;
- }
-
- /**
- * Sets whether to report undocumented declarations.
- *
+ *
+ * To pass values that contain whitespaces, surround them with single ({@code '}) or double ({@code "}) quotes.
+ * If a value contains quotation marks in it, escape them with a backslash (\).
+ *
+ *
+ * If the files reside in locations different from the current directory, use relative paths.
+ *
+ * @param files one or more files
+ * @return this operation instance
+ * @see #argFileStrings(Collection)
+ */
+ public CompileOptions argFile(String... files) {
+ return argFileStrings(List.of(files));
+ }
+
+ /**
+ * Read the compiler options from the given files.
+ *
+ * @param files the compiler options files
+ * @return this operation instance
+ * @see #argFile(File...)
+ */
+ public CompileOptions argFile(Collection
+ *
+ * To pass values that contain whitespaces, surround them with single ({@code '}) or double ({@code "}) quotes.
+ * If a value contains quotation marks in it, escape them with a backslash (\).
+ *
+ *
+ * If the files reside in locations different from the current directory, use relative paths.
+ *
+ * @param files one or more files
+ * @return this operation instance
+ * @see #argFile(Collection)
+ */
+ public CompileOptions argFile(File... files) {
+ return argFile(List.of(files));
+ }
+
+ /**
+ * Read the compiler options from the given files.
+ *
+ *
+ * To pass values that contain whitespaces, surround them with single ({@code '}) or double ({@code "}) quotes.
+ * If a value contains quotation marks in it, escape them with a backslash (\).
+ *
+ *
+ * If the files reside in locations different from the current directory, use relative paths.
+ *
+ * @param files one or more files
+ * @return this operation instance
+ * @see #argFilePaths(Collection)
+ */
+ public CompileOptions argFile(Path... files) {
+ return argFilePaths(List.of(files));
+ }
+
+ /**
+ * Retrieves the files containing compiler options.
+ *
+ * @return the compiler options files
+ */
+ public Collection>();
- args.add(options.args());
- args.add(options.apiVersion(11).jvmTarget(11).args());
-
- for (var a : args) {
- assertThat(a).hasSize(matches.size());
- IntStream.range(0, a.size()).forEach(i -> assertThat(a.get(i)).isEqualTo(matches.get(i)));
- }
- }
-}
diff --git a/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java b/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java
deleted file mode 100644
index f115a27..0000000
--- a/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2023-2024 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package rife.bld.extension.dokka;
-
-import org.junit.jupiter.api.Test;
-import rife.bld.blueprints.BaseProjectBlueprint;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.IntStream;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class DokkaOperationTest {
- @Test
- @SuppressWarnings({"ExtractMethodRecommender", "PMD.AvoidDuplicateLiterals"})
- void executeConstructProcessCommandListTest() {
- var params = List.of(
- "-moduleName",
- "-moduleVersion",
- "-outputDir",
- "-sourceSet",
- "-pluginsConfiguration",
- "-pluginsClasspath",
- "-offlineMode",
- "-failOnWarning",
- "-delayTemplateSubstitution",
- "-noSuppressObviousFunctions",
- "-includes",
- "-suppressInheritedMembers",
- "-globalPackageOptions",
- "-globalLinks",
- "-globalSrcLink",
- "-loggingLevel");
- var examples = new File("examples");
- var jsonConf = new File("config.json");
- var args = new DokkaOperation()
- .fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
- .globalLinks("s", "link")
- .globalLinks(Map.of("s2", "link2"))
- .globalPackageOptions("option1", "option2")
- .globalPackageOptions(List.of("option3", "option4"))
- .globalSrcLink("link1", "link2")
- .globalSrcLink(List.of("link3", "link4"))
- .includes("file1", "file2")
- .includes(List.of("file3", "file4"))
- .pluginConfigurations("name", "{\"json\"}")
- .pluginConfigurations(Map.of("{\"name2\"}", "json2", "name3}", "{json3"))
- .pluginsClasspath("path1", "path2")
- .pluginsClasspath(List.of("path3", "path4"))
- .delayTemplateSubstitution(true)
- .failOnWarning(true)
- .loggingLevel(LoggingLevel.DEBUG)
- .moduleName("name")
- .moduleVersion("1.0")
- .noSuppressObviousFunctions(true)
- .offlineMode(true)
- .outputDir(new File(examples, "build"))
- .outputFormat(OutputFormat.JAVADOC)
- .suppressInheritedMembers(true)
- .sourceSet(new SourceSet().classpath(
- List.of(
- new File("examples/foo.jar"),
- new File("examples/bar.jar")
- )))
- .json(jsonConf)
- .executeConstructProcessCommandList();
-
- for (var p : params) {
- var found = false;
- for (var a : args) {
- if (a.startsWith(p)) {
- found = true;
- break;
- }
- }
- assertThat(found).as(p + " not found.").isTrue();
- }
-
- var path = examples.getAbsolutePath();
- var dokkaJar = "1.9.20.jar";
- var matches = List.of("java",
- "-jar", path + "/lib/bld/dokka-cli-" + dokkaJar,
- "-pluginsClasspath", path + "/lib/bld/dokka-base-" + dokkaJar + ';' +
- path + "/lib/bld/analysis-kotlin-descriptors-" + dokkaJar + ';' +
- path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' +
- path + "/lib/bld/korte-jvm-4.0.10.jar;" +
- path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ";path1;path2;path3;path4",
- "-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;" + path + "/bar.jar",
- "-outputDir", path + "/build",
- "-delayTemplateSubstitution",
- "-failOnWarning",
- "-globalLinks", "s^link^^s2^link2",
- "-globalPackageOptions", "option1;option2;option3;option4",
- "-globalSrcLinks_", "link1;link2;link3;link4",
- "-includes", "file1;file2;file3;file4",
- "-loggingLevel", "debug",
- "-moduleName", "name",
- "-moduleVersion", "1.0",
- "-noSuppressObviousFunctions",
- "-offlineMode",
- "-pluginsConfiguration", "{\\\"name2\\\"}={json2}^^{name}={\\\"json\\\"}^^{name3}}={{json3}",
- "-suppressInheritedMembers",
- jsonConf.getAbsolutePath());
-
- assertThat(args).hasSize(matches.size());
-
- IntStream.range(0, args.size()).forEach(i -> {
- if (args.get(i).contains(".jar;")) {
- var jars = args.get(i).split(";");
- Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).as(matches.get(i)).contains(jar));
- } else {
- assertThat(args.get(i)).as(args.get(i)).isEqualTo(matches.get(i));
- }
- });
- }
-}
diff --git a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java b/src/test/java/rife/bld/extension/dokka/SourceSetTest.java
deleted file mode 100644
index ac1c20b..0000000
--- a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2023-2024 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package rife.bld.extension.dokka;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.List;
-import java.util.Map;
-import java.util.stream.IntStream;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class SourceSetTest {
- @Test
- void sourceSetCollectionsTest() {
- var args = new SourceSet()
- .classpath(List.of("path1", "path2"))
- .dependentSourceSets(Map.of("set1", "set2", "set3", "set4"))
- .externalDocumentationLinks(Map.of("link1", "link2", "link3", "link4"))
- .perPackageOptions(List.of("option1", "option2"))
- .samples(List.of("samples1", "samples1"))
- .suppressedFiles(List.of("sup1", "sup2"))
- .args();
-
- var matches = List.of(
- "-classpath", "path1;path2",
- "-dependentSourceSets", "set1/set2;set3/set4",
- "-externalDocumentationLinks", "link3^link4^^link1^link2",
- "-perPackageOptions", "option1;option2",
- "-samples", "samples1;samples1",
- "-suppressedFiles", "sup1;sup2"
- );
-
- assertThat(args).hasSize(matches.size());
-
- IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
- }
-
- @Test
- @SuppressWarnings("PMD.AvoidDuplicateLiterals")
- void sourceSetTest() {
- var params = List.of(
- "-sourceSetName",
- "-displayName",
- "-classpath",
- "-src",
- "-dependentSourceSets",
- "-samples",
- "-includes",
- "-documentedVisibilities",
- "-reportUndocumented",
- "-noSkipEmptyPackages",
- "-skipDeprecated",
- "-jdkVersion",
- "-languageVersion",
- "-apiVersion",
- "-noStdlibLink",
- "-noJdkLink",
- "-suppressedFiles",
- "-analysisPlatform",
- "-perPackageOptions",
- "-externalDocumentationLinks",
- "-srcLink"
- );
- var sourceSet = new SourceSet()
- .classpath("classpath1", "classpath2")
- .dependentSourceSets("moduleName", "sourceSetName")
- .documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
- .externalDocumentationLinks("url1", "packageListUrl1")
- .externalDocumentationLinks("url2", "packageListUrl2")
- .includes("includes1", "includes2")
- .perPackageOptions("options1", "options2")
- .samples("samples1", "sample2")
- .srcLink("path1", "remote1", "#suffix1")
- .srcLink("path2", "remote2", "#suffix2")
- .src("src1", "src2")
- .suppressedFiles("sup1", "sup2")
- .analysisPlatform(AnalysisPlatform.JVM)
- .apiVersion("1.0")
- .displayName("name")
- .jdkVersion(18)
- .languageVersion("2.0")
- .noJdkLink(true)
- .noSkipEmptyPackages(true)
- .noStdlibLink(true)
- .reportUndocumented(true)
- .skipDeprecated(true)
- .sourceSetName("setName");
-
- var args = sourceSet.args();
-
- for (var p : params) {
- var found = false;
- for (var a : args) {
- if (a.startsWith(p)) {
- found = true;
- break;
- }
- }
- assertThat(found).as(p + " not found.").isTrue();
- }
-
- var matches = List.of(
- "-analysisPlatform", "jvm",
- "-apiVersion", "1.0",
- "-classpath", "classpath1;classpath2",
- "-dependentSourceSets", "moduleName/sourceSetName",
- "-displayName", "name",
- "-documentedVisibilities", "package;private",
- "-externalDocumentationLinks", "url1^packageListUrl1^^url2^packageListUrl2",
- "-jdkVersion", "18",
- "-includes", "includes1;includes2",
- "-languageVersion", "2.0",
- "-noJdkLink", "true",
- "-noSkipEmptyPackages", "true",
- "-noStdlibLink", "true",
- "-reportUndocumented", "true",
- "-perPackageOptions", "options1;options2",
- "-samples", "samples1;sample2",
- "-skipDeprecated", "true",
- "-src", "src1;src2",
- "-srcLink", "path1=remote1#suffix1;path2=remote2#suffix2",
- "-sourceSetName", "setName",
- "-suppressedFiles", "sup1;sup2");
-
- assertThat(args).hasSize(matches.size());
-
- IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
-
- sourceSet.classpath(List.of("classpath1", "classpath2"));
-
- IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
- }
-}
diff --git a/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java
new file mode 100644
index 0000000..c6e6965
--- /dev/null
+++ b/src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java
@@ -0,0 +1,393 @@
+/*
+ * Copyright 2023-2025 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rife.bld.extension.kotlin;
+
+import org.assertj.core.api.AutoCloseableSoftAssertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SuppressWarnings("PMD.AvoidDuplicateLiterals")
+class CompileOptionsTest {
+ /**
+ * Returns the local path of the given file names.
+ *
+ * @param fileNames The file names
+ * @return the local path
+ */
+ private String localPath(String... fileNames) {
+ return Arrays.stream(fileNames).map(it -> new File(it).getAbsolutePath())
+ .collect(Collectors.joining(File.pathSeparator));
+ }
+
+ @Test
+ @SuppressWarnings("PMD.UnitTestShouldIncludeAssert")
+ void testArgs() {
+ var options = new CompileOptions()
+ .apiVersion("11")
+ .javaParameters(true)
+ .jvmTarget("11")
+ .includeRuntime(true)
+ .jdkHome(new File("path"))
+ .jdkRelease("11")
+ .kotlinHome(new File("path"))
+ .languageVersion("1.0")
+ .moduleName("module")
+ .noJdk(true)
+ .noReflect(true)
+ .noWarn(true)
+ .optIn("opt1", "opt2")
+ .options("-foo", "-bar")
+ .path("path")
+ .plugin("id", "name", "value")
+ .progressive(true)
+ .scriptTemplates("name", "name2")
+ .verbose(true)
+ .wError(true)
+ .wExtra(true);
+
+ var matches = List.of(
+ "-api-version", "11",
+ "-java-parameters",
+ "-jvm-target", "11",
+ "-include-runtime",
+ "-jdk-home", localPath("path"),
+ "-Xjdk-release=11",
+ "-kotlin-home", localPath("path"),
+ "-language-version", "1.0",
+ "-module-name", "module",
+ "-no-jdk",
+ "-no-reflect",
+ "-nowarn",
+ "-opt-in", "opt1",
+ "-opt-in", "opt2",
+ "-foo",
+ "-bar",
+ "-d", localPath("path"),
+ "-P", "plugin:id:name:value",
+ "-progressive",
+ "-script-templates", "name,name2",
+ "-verbose",
+ "-Werror",
+ "-Wextra");
+
+ var args = new ArrayList
>();
+ args.add(options.args());
+ args.add(options.apiVersion(11).jvmTarget(11).args());
+
+ try (var softly = new AutoCloseableSoftAssertions()) {
+ for (var a : args) {
+ IntStream.range(0, a.size()).forEach(i -> softly.assertThat(a.get(i))
+ .as(a.get(i) + " == " + matches.get(i)).isEqualTo(matches.get(i)));
+ }
+ }
+ }
+
+ @Test
+ void testArgsCollections() {
+ var advanceOptions = List.of("-Xoption1", "option=2");
+ var argFile = List.of(new File("arg1.txt"), new File("arg2.txt"));
+ var classpath = List.of(new File("path1"), new File("path2"));
+ var optIn = List.of("opt1", "opt2");
+ var options = List.of("-foo", "-bar");
+ var plugin = List.of("id:name:value", "id2:name2:value2");
+ var scriptTemplates = List.of("temp1", "temp2");
+
+ var op = new CompileOptions()
+ .advancedOptions(advanceOptions)
+ .argFile(argFile)
+ .classpath(classpath)
+ .noStdLib(false)
+ .optIn(optIn)
+ .options(options)
+ .scriptTemplates(scriptTemplates);
+
+ plugin.forEach(it -> {
+ var p = it.split(":");
+ op.plugin(p[0], p[1], p[2]);
+ });
+
+ try (var softly = new AutoCloseableSoftAssertions()) {
+ softly.assertThat(op.advancedOptions()).as("advancedOptions")
+ .hasSize(advanceOptions.size()).containsAll(advanceOptions);
+ softly.assertThat(op.argFile()).as("argFile")
+ .hasSize(argFile.size()).containsAll(argFile);
+ softly.assertThat(op.classpath()).as("classpath")
+ .hasSize(classpath.size()).containsAll(classpath);
+ softly.assertThat(op.optIn()).as("optIn")
+ .hasSize(optIn.size()).containsAll(optIn);
+ softly.assertThat(op.options()).as("options")
+ .hasSize(options.size()).containsAll(options);
+ softly.assertThat(op.plugin()).as("plugin")
+ .hasSize(plugin.size()).containsAll(plugin);
+ softly.assertThat(op.scriptTemplates()).as("scriptTemplates")
+ .hasSize(scriptTemplates.size()).containsAll(scriptTemplates);
+ }
+
+ var matches = List.of(
+ '@' + localPath("arg1.txt"), '@' + localPath("arg2.txt"),
+ "-classpath", localPath("path1", "path2"),
+ "-Joption1", "-Joption2",
+ "-opt-in", "opt1",
+ "-opt-in", "opt2",
+ "-foo", "-bar",
+ "-script-templates",
+ "temp1,temp2",
+ "-Xoption1", "-Xoption=2",
+ "-P", "plugin:id:name:value",
+ "-P", "plugin:id2:name2:value2");
+
+ try (var softly = new AutoCloseableSoftAssertions()) {
+ var args = op.args();
+ for (var arg : args) {
+ var found = false;
+ for (var match : matches) {
+ if (match.equals(arg)) {
+ found = true;
+ break;
+ }
+ }
+ softly.assertThat(found).as(arg + " not found.").isTrue();
+ }
+ }
+ }
+
+ @Test
+ void testArgsFile() {
+ var foo = new File("foo.txt");
+ var bar = new File("bar.txt");
+ var options = new CompileOptions();
+
+ options = options.argFile(foo);
+ assertThat(options.argFile()).contains(foo);
+ options.argFile().clear();
+ assertThat(options.argFile()).isEmpty();
+
+ options.argFile(foo, bar);
+ assertThat(options.argFile()).contains(foo, bar);
+ options.argFile().clear();
+ assertThat(options.argFile()).isEmpty();
+
+ options = options.argFile(foo.toPath(), bar.toPath());
+ assertThat(options.argFile()).contains(foo, bar);
+ options.argFile().clear();
+ assertThat(options.argFile()).isEmpty();
+
+ options = options.argFile(foo.getAbsolutePath(), bar.getAbsolutePath());
+ assertThat(options.argFile()).contains(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
+ }
+
+ @Test
+ @EnabledOnOs(OS.LINUX)
+ void testCheckAllParams() throws IOException {
+ var args = Files.readAllLines(Paths.get("src", "test", "resources", "kotlinc-args.txt"));
+
+ assertThat(args).isNotEmpty();
+
+ var params = new CompileOptions()
+ .advancedOptions("Xoption")
+ .apiVersion("11")
+ .expression("expression")
+ .includeRuntime(true)
+ .javaParameters(true)
+ .jdkHome("jdkhome")
+ .jvmTarget(12)
+ .kotlinHome("kotlin")
+ .languageVersion("1.0")
+ .moduleName("moduleName")
+ .noJdk(true)
+ .noReflect(true)
+ .noStdLib(true)
+ .noWarn(true)
+ .optIn("annotation")
+ .options("option")
+ .path(new File("path"))
+ .plugin("id", "option", "value")
+ .progressive(true)
+ .scriptTemplates("template")
+ .verbose(true)
+ .wError(true)
+ .wExtra(true);
+
+ var skipArgs = List.of("-J", "-classpath", "@");
+ assertThat(args).as(skipArgs + " not found.").containsAll(skipArgs);
+ args.removeAll(skipArgs);
+
+ try (var softly = new AutoCloseableSoftAssertions()) {
+ for (var p : args) {
+ var found = false;
+ for (var a : params.args()) {
+ if (a.startsWith(p)) {
+ found = true;
+ break;
+ }
+ }
+ softly.assertThat(found).as(p + " not found.").isTrue();
+ }
+ }
+ }
+
+ @Test
+ void testClasspath() {
+ var foo = new File("foo.txt");
+ var bar = new File("bar.txt");
+ var options = new CompileOptions();
+
+ options = options.classpath(foo);
+ assertThat(options.classpath()).as("File").containsExactly(foo);
+ options.classpath().clear();
+ assertThat(options.argFile()).isEmpty();
+
+
+ options.classpath(foo, bar);
+ assertThat(options.classpath()).as("File...").containsExactly(foo, bar);
+ options.classpath().clear();
+ assertThat(options.argFile()).isEmpty();
+
+
+ options.classpath(List.of(foo, bar));
+ assertThat(options.classpath()).as("List(File...)").containsExactly(foo, bar);
+ options.classpath().clear();
+ assertThat(options.argFile()).isEmpty();
+
+
+ options = options.classpath(foo.toPath(), bar.toPath());
+ assertThat(options.classpath()).as("Path...").containsExactly(foo, bar);
+ options.classpath().clear();
+ assertThat(options.argFile()).isEmpty();
+
+
+ options = options.classpathPaths(List.of(foo.toPath(), bar.toPath()));
+ assertThat(options.classpath()).as("List(Path...)").containsExactly(foo, bar);
+ options.classpath().clear();
+ assertThat(options.argFile()).isEmpty();
+
+
+ options.classpath(foo.getAbsolutePath(), bar.getAbsolutePath());
+ assertThat(options.classpath()).as("String...")
+ .containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
+ options.classpath().clear();
+ assertThat(options.argFile()).isEmpty();
+
+ options.classpathStrings(List.of(foo.getAbsolutePath(), bar.getAbsolutePath()));
+ assertThat(options.classpath()).as("List(String...)")
+ .containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
+ }
+
+ @Test
+ void testJdkHome() {
+ var foo = new File("foo.txt");
+ var options = new CompileOptions();
+
+ options.jdkHome(foo);
+ assertThat(options.jdkHome()).isEqualTo(foo);
+
+ options = options.jdkHome(foo.toPath());
+ assertThat(options.jdkHome()).isEqualTo(foo);
+
+ options.jdkHome(foo.getAbsolutePath());
+ assertThat(options.jdkHome().getAbsolutePath()).isEqualTo(foo.getAbsolutePath());
+ }
+
+ @Test
+ void testKotlinHome() {
+ var foo = new File("foo.txt");
+ var options = new CompileOptions();
+
+ options.kotlinHome(foo);
+ assertThat(options.kotlinHome()).isEqualTo(foo);
+
+ options = options.kotlinHome(foo.toPath());
+ assertThat(options.kotlinHome()).isEqualTo(foo);
+
+ options.kotlinHome(foo.getAbsolutePath());
+ assertThat(options.kotlinHome().getAbsolutePath()).isEqualTo(foo.getAbsolutePath());
+ }
+
+ @Test
+ void testOptions() {
+ var options = new CompileOptions()
+ .advancedOptions("xopt1", "xopt2")
+ .apiVersion("11")
+ .argFile(Path.of("args.txt"))
+ .classpath("classpath")
+ .expression("expression")
+ .includeRuntime(true)
+ .javaParameters(true)
+ .jdkHome("jdk-home")
+ .jdkRelease(22)
+ .jvmTarget("9")
+ .kotlinHome("kotlin-home")
+ .languageVersion("1.0")
+ .moduleName("module")
+ .noJdk(true)
+ .noReflect(true)
+ .noStdLib(true)
+ .noWarn(true)
+ .optIn("opt1", "opt2")
+ .options("-foo", "-bar")
+ .path(Path.of("path"))
+ .plugin("id", "name", "value")
+ .progressive(true)
+ .scriptTemplates("name", "name2")
+ .verbose(true)
+ .wError(true)
+ .wExtra(true);
+
+ try (var softly = new AutoCloseableSoftAssertions()) {
+ softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2");
+ softly.assertThat(options.apiVersion()).isEqualTo("11");
+ softly.assertThat(options.argFile()).containsExactly(new File("args.txt"));
+ softly.assertThat(options.classpath()).containsExactly(new File("classpath"));
+ softly.assertThat(options.expression()).isEqualTo("expression");
+ softly.assertThat(options.isIncludeRuntime()).isTrue();
+ softly.assertThat(options.isJavaParameters()).isTrue();
+ softly.assertThat(options.isNoJdk()).isTrue();
+ softly.assertThat(options.isNoReflect()).isTrue();
+ softly.assertThat(options.isNoStdLib()).isTrue();
+ softly.assertThat(options.isNoWarn()).isTrue();
+ softly.assertThat(options.isProgressive()).isTrue();
+ softly.assertThat(options.isVerbose()).isTrue();
+ softly.assertThat(options.jdkHome()).isEqualTo(new File("jdk-home"));
+ softly.assertThat(options.jdkRelease()).isEqualTo("22");
+ softly.assertThat(options.jvmTarget()).isEqualTo("9");
+ softly.assertThat(options.kotlinHome()).isEqualTo(new File("kotlin-home"));
+ softly.assertThat(options.languageVersion()).isEqualTo("1.0");
+ softly.assertThat(options.moduleName()).isEqualTo("module");
+ softly.assertThat(options.optIn()).containsExactly("opt1", "opt2");
+ softly.assertThat(options.options()).containsExactly("-foo", "-bar");
+ softly.assertThat(options.path()).isEqualTo(new File("path"));
+ softly.assertThat(options.plugin()).containsExactly("id:name:value");
+ softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2");
+ softly.assertThat(options.isWError()).isTrue();
+ softly.assertThat(options.isWExtra()).isTrue();
+ }
+ }
+}
diff --git a/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java
new file mode 100644
index 0000000..6f8474f
--- /dev/null
+++ b/src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2023-2025 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rife.bld.extension.kotlin;
+
+import org.junit.jupiter.api.Test;
+import rife.bld.extension.CompileKotlinOperation;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SuppressWarnings("PMD.AvoidDuplicateLiterals")
+class JvmOptionsTest {
+ @Test
+ void testop() {
+ var op = new CompileKotlinOperation().jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED));
+ assertThat(op.jvmOptions()).as(JvmOptions.ALL_UNNAMED).containsExactly("--enable-native-access=ALL-UNNAMED");
+
+ op = new CompileKotlinOperation().jvmOptions(new JvmOptions().enableNativeAccess("m1", "m2"));
+ assertThat(op.jvmOptions()).as("m1,m2").containsExactly("--enable-native-access=m1,m2");
+ }
+
+ @Test
+ void testEnableNativeAccess() {
+ var options = new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED);
+ assertThat(options).as(JvmOptions.ALL_UNNAMED).containsExactly("--enable-native-access=ALL-UNNAMED");
+
+ options = new JvmOptions().enableNativeAccess("m1");
+ assertThat(options).as("m1").containsExactly("--enable-native-access=m1");
+
+ options = new JvmOptions().enableNativeAccess("m1", "m2");
+ assertThat(options).as("m1,m2").containsExactly("--enable-native-access=m1,m2");
+ }
+
+ @Test
+ void testIllegalNativeAccess() {
+ var options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW);
+ assertThat(options).as("ALLOW").containsExactly("--illegal-native-access=allow");
+
+ options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.DENY);
+ assertThat(options).as("DENY").containsExactly("--illegal-native-access=deny");
+
+ options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.WARN);
+ assertThat(options).as("WARN").containsExactly("--illegal-native-access=warn");
+ }
+
+ @Test
+ void testJvmOptions() {
+ var op = new CompileKotlinOperation().jvmOptions("option1", "option2");
+ assertThat(op.jvmOptions()).as("option1,option2").containsExactly("option1", "option2");
+
+ op = new CompileKotlinOperation().jvmOptions(List.of("option1", "option2"));
+ assertThat(op.jvmOptions()).as("List.of(option1,option2)").containsExactly("option1", "option2");
+
+ op = op.jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED));
+ assertThat(op.jvmOptions()).as("List.of(option1,option2,ALL_UNNAMED)")
+ .containsExactly("option1", "option2", "--enable-native-access=ALL-UNNAMED");
+
+ op = op.jvmOptions(new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW));
+ assertThat(op.jvmOptions()).as("allow")
+ .containsExactly("option1", "option2", "--enable-native-access=ALL-UNNAMED",
+ "--illegal-native-access=allow");
+ }
+}
diff --git a/src/test/resources/argfile.txt b/src/test/resources/argfile.txt
new file mode 100644
index 0000000..d128d62
--- /dev/null
+++ b/src/test/resources/argfile.txt
@@ -0,0 +1,3 @@
+-Xjdk-release=17 -no-reflect
+
+-progressive
diff --git a/src/test/resources/argfile2.txt b/src/test/resources/argfile2.txt
new file mode 100644
index 0000000..93f9181
--- /dev/null
+++ b/src/test/resources/argfile2.txt
@@ -0,0 +1 @@
+-include-runtime
\ No newline at end of file
diff --git a/src/test/resources/kotlinc-args.txt b/src/test/resources/kotlinc-args.txt
new file mode 100644
index 0000000..e764231
--- /dev/null
+++ b/src/test/resources/kotlinc-args.txt
@@ -0,0 +1,26 @@
+@
+-api-version
+-classpath
+-d
+-expression
+-include-runtime
+-J
+-java-parameters
+-jdk-home
+-jvm-target
+-kotlin-home
+-language-version
+-module-name
+-no-jdk
+-no-reflect
+-no-stdlib
+-nowarn
+-opt-in
+-P
+-progressive
+-script
+-script-templates
+-verbose
+-Werror
+-Wextra
+-X