Compare commits
12 commits
1623b902f9
...
1ad14d56c7
Author | SHA1 | Date | |
---|---|---|---|
1ad14d56c7 | |||
5de764b4b8 | |||
c952b980bb | |||
c901065b3a | |||
c54672a7a0 | |||
c595632732 | |||
c151a49935 | |||
19d662a81f | |||
2d754ffe64 | |||
41e60f606a | |||
dcc68afdf3 | |||
8d34f37af0 |
26 changed files with 565 additions and 2080 deletions
8
.github/workflows/bld.yml
vendored
8
.github/workflows/bld.yml
vendored
|
@ -32,14 +32,6 @@ jobs:
|
|||
working-directory: examples
|
||||
run: ./bld compile test
|
||||
|
||||
- name: Build examples documentation
|
||||
working-directory: examples
|
||||
run: |
|
||||
./bld javadoc
|
||||
./bld dokka-html
|
||||
./bld dokka-gfm
|
||||
./bld dokka-jekyll
|
||||
|
||||
- name: Grant execute permission for bld
|
||||
run: chmod +x bld
|
||||
|
||||
|
|
4
.idea/copyright/Apache_License.xml
generated
4
.idea/copyright/Apache_License.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="Copyright 2023-Copyright &#36;today.yearamp;#36;today.year 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." />
|
||||
<option name="notice" value="Copyright 2023-&#36;today.year 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." />
|
||||
<option name="myName" value="Apache License" />
|
||||
</copyright>
|
||||
</component>
|
||||
</component>
|
11
.idea/misc.xml
generated
11
.idea/misc.xml
generated
|
@ -1,7 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0">
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin ALL_OPEN" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin ASSIGNMENT" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin KOTLIN_SERIALIZATION" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin LOMBOK" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin NOARG" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin POWER_ASSERT" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin SAM_WITH_RECEIVER" />
|
||||
</entry_points>
|
||||
<pattern value="rife.bld.extension.CompileKotlinOperationBuild" method="pmd" />
|
||||
<pattern value="rife.bld.extension.kotlin.CompilerPlugin" />
|
||||
<pattern value="rife.bld.extension.kotlin.CompilerPlugin" method="CompilerPlugin" />
|
||||
</component>
|
||||
<component name="PDMPlugin">
|
||||
<option name="customRuleSets">
|
||||
|
|
29
README.md
29
README.md
|
@ -17,7 +17,7 @@ To compile the source code located in `src/main/kotlin` and `src/test/kotlin` fr
|
|||
|
||||
```java
|
||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||
public void compile() throws IOException {
|
||||
public void compile() throws Exception {
|
||||
new CompileKotlinOperation()
|
||||
.fromProject(this)
|
||||
.execute();
|
||||
|
@ -33,31 +33,6 @@ public void compile() throws IOException {
|
|||
Please check the [Compile Operation documentation](https://rife2.github.io/bld-kotlin/rife/bld/extension/CompileKotlinOperation.html#method-summary)
|
||||
for all available configuration options.
|
||||
|
||||
## Generate Javadoc
|
||||
|
||||
To generate the Javadoc using [Dokka](https://github.com/Kotlin/dokka):
|
||||
|
||||
```java
|
||||
@Override
|
||||
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.outputDir(new File(buildDirectory(), "javadoc"))
|
||||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.execute();
|
||||
}
|
||||
```
|
||||
|
||||
```console
|
||||
./bld javadoc
|
||||
```
|
||||
|
||||
- [View Examples Project](https://github.com/rife2/bld-kotlin/tree/main/examples/)
|
||||
|
||||
Please check the [Dokka Operation documentation](https://rife2.github.io/bld-kotlin/rife/bld/extension/dokka/DokkaOperation.html#method-summary)
|
||||
for all available configuration options.
|
||||
|
||||
## Template Project
|
||||
|
||||
There is also a [Template Project](https://github.com/rife2/kotlin-bld-example) with support for Dokka and the
|
||||
[Detekt](https://github.com/rife2/bld-detekt) extensions.
|
||||
There is also a [Template Project](https://github.com/rife2/kotlin-bld-example) with support for the [Dokka](https://github.com/rife2/bld-dokka) and [Detekt](https://github.com/rife2/bld-detekt) extensions.
|
||||
|
|
|
@ -16,12 +16,3 @@
|
|||
```console
|
||||
./bld test
|
||||
```
|
||||
|
||||
## Build the documentation with [Dokka](https://github.com/Kotlin/dokka)
|
||||
|
||||
```console
|
||||
./bld javadoc
|
||||
./bld dokka-html
|
||||
./bld dokka-gfm
|
||||
./bld dokka-jekyll
|
||||
```
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
bld.downloadExtensionJavadoc=false
|
||||
bld.downloadExtensionSources=true
|
||||
bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.8
|
||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||
bld.downloadLocation=
|
||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.0-SNAPSHOT
|
||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||
bld.sourceDirectories=
|
||||
bld.version=1.9.1
|
||||
|
|
|
@ -3,14 +3,9 @@ package com.example;
|
|||
import rife.bld.BuildCommand;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
import rife.bld.extension.dokka.DokkaOperation;
|
||||
import rife.bld.extension.dokka.LoggingLevel;
|
||||
import rife.bld.extension.dokka.OutputFormat;
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
|
@ -39,8 +34,8 @@ public class ExampleBuild extends Project {
|
|||
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin));
|
||||
scope(test)
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)));
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3)));
|
||||
|
||||
// Include the Kotlin source directory when creating or publishing sources Java Archives
|
||||
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
|
||||
|
@ -48,21 +43,21 @@ public class ExampleBuild extends Project {
|
|||
|
||||
public static void main(String[] args) {
|
||||
// Enable detailed logging for the Kotlin extension
|
||||
// var level = Level.ALL;
|
||||
// var logger = Logger.getLogger("rife.bld.extension");
|
||||
// var consoleHandler = new ConsoleHandler();
|
||||
var level = Level.ALL;
|
||||
var logger = Logger.getLogger("rife.bld.extension");
|
||||
var consoleHandler = new ConsoleHandler();
|
||||
|
||||
// consoleHandler.setLevel(level);
|
||||
// logger.addHandler(consoleHandler);
|
||||
// logger.setLevel(level);
|
||||
// logger.setUseParentHandlers(false);
|
||||
consoleHandler.setLevel(level);
|
||||
logger.addHandler(consoleHandler);
|
||||
logger.setLevel(level);
|
||||
logger.setUseParentHandlers(false);
|
||||
|
||||
new ExampleBuild().start(args);
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||
@Override
|
||||
public void compile() throws IOException {
|
||||
public void compile() throws Exception {
|
||||
// The source code located in src/main/kotlin and src/test/kotlin will be compiled
|
||||
new CompileKotlinOperation()
|
||||
.fromProject(this)
|
||||
|
@ -72,50 +67,4 @@ public class ExampleBuild extends Project {
|
|||
// op.compileOptions().verbose(true);
|
||||
// op.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "dokka-gfm", summary = "Generates documentation in GitHub flavored markdown format")
|
||||
public void dokkaGfm() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/dokka/gfm
|
||||
.outputDir(Path.of(buildDirectory().getAbsolutePath(), "dokka", "gfm").toFile())
|
||||
.outputFormat(OutputFormat.MARKDOWN)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "dokka-html", summary = "Generates documentation in HTML format")
|
||||
public void dokkaHtml() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/dokka/html
|
||||
.outputDir(Path.of(buildDirectory().getAbsolutePath(), "dokka", "html").toFile())
|
||||
.outputFormat(OutputFormat.HTML)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "dokka-jekyll", summary = "Generates documentation in Jekyll flavored markdown format")
|
||||
public void dokkaJekyll() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/dokka/jekyll
|
||||
.outputDir(Path.of(buildDirectory().getAbsolutePath(), "dokka", "jekkyl").toFile())
|
||||
.outputFormat(OutputFormat.JEKYLL)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Generates Javadoc for the project")
|
||||
@Override
|
||||
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.failOnWarning(true)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/javadoc
|
||||
.outputDir(new File(buildDirectory(), "javadoc"))
|
||||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
bld.downloadExtensionJavadoc=false
|
||||
bld.downloadExtensionSources=true
|
||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.9
|
||||
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.0
|
||||
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_RELEASES
|
||||
bld.downloadLocation=
|
||||
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.1
|
||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.2
|
||||
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||
bld.sourceDirectories=
|
||||
bld.version=1.9.1
|
||||
|
|
|
@ -1,19 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
main=org.jetbrains.dokka.MainKt
|
||||
new=/tmp/checkcliargs-new
|
||||
old=/tmp/checkcliargs-old
|
||||
|
||||
java -cp "lib/compile/*" $main -h >$new
|
||||
java -cp "examples/lib/bld/*" $main -h >$old
|
||||
|
||||
diff $old $new
|
||||
|
||||
java -cp "lib/compile/*" $main -sourceSet -h >$new
|
||||
java -cp "examples/lib/bld/*" $main -sourceSet -h >$old
|
||||
|
||||
diff $old $new
|
||||
|
||||
main=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
|
||||
java -cp "lib/compile/*" $main -h 2>$new
|
||||
|
|
|
@ -3,15 +3,3 @@
|
|||
java -cp "lib/compile/*" org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -h 2> >(grep "^ ") |\
|
||||
sed -e "s/^ //" -e "s/ .*//" -e "s/<.*//" -e '/-help/d' -e '/-version/d' -e '/^$/d'|\
|
||||
sort > "src/test/resources/kotlinc-args.txt"
|
||||
|
||||
main=org.jetbrains.dokka.MainKt
|
||||
|
||||
java -cp "lib/compile/*" $main -h |\
|
||||
grep " -" |\
|
||||
sed -e "s/^ -/-/" -e "s/ \[.*//" -e "s/ ->.*//" -e '/help/d' |\
|
||||
sort > "src/test/resources/dokka-args.txt"
|
||||
|
||||
java -cp "lib/compile/*" $main -sourceSet -h |\
|
||||
grep " -" |\
|
||||
sed -e "s/^ -/-/" -e "s/ \[.*//" -e "s/ ->.*//" -e '/help/d' -e '/includeNonPublic/d' |\
|
||||
sort > "src/test/resources/dokka-sourceset-args.txt"
|
||||
|
|
|
@ -33,31 +33,37 @@ public class CompileKotlinOperationBuild extends Project {
|
|||
public CompileKotlinOperationBuild() {
|
||||
pkg = "rife.bld.extension";
|
||||
name = "bld-kotlin";
|
||||
version = version(0, 9, 8);
|
||||
version = version(1, 0, 0, "SNAPSHOT");
|
||||
|
||||
javaRelease = 17;
|
||||
|
||||
downloadSources = true;
|
||||
autoDownloadPurge = true;
|
||||
|
||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||
|
||||
var dokka = version(1, 9, 20);
|
||||
var kotlin = version(2, 0, 0);
|
||||
scope(compile)
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-compiler", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-annotation-processing", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-scripting-compiler", kotlin))
|
||||
.include(dependency("org.jetbrains.dokka", "dokka-cli", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "dokka-base", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "analysis-kotlin-descriptors", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "javadoc-plugin", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "gfm-plugin", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "jekyll-plugin", dokka))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-reflect", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib-common", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm", version(1, 9, 0, "RC")))
|
||||
// Compiler Plugins
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-allopen-compiler-plugin", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-assignment-compiler-plugin", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-serialization-compiler-plugin", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-lombok-compiler-plugin", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-allopen-compiler-plugin", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-noarg-compiler-plugin", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-power-assert-compiler-plugin", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-sam-with-receiver-compiler-plugin", kotlin))
|
||||
.include(dependency("com.uwyn.rife2", "bld", version(1, 9, 1)));
|
||||
scope(test)
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)))
|
||||
.include(dependency("org.assertj", "assertj-core", version(3, 26, 0)));
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3)))
|
||||
.include(dependency("org.assertj", "assertj-core", version(3, 26, 3)));
|
||||
|
||||
javadocOperation()
|
||||
.javadocOptions()
|
||||
|
@ -99,7 +105,7 @@ public class CompileKotlinOperationBuild extends Project {
|
|||
}
|
||||
|
||||
@BuildCommand(summary = "Runs PMD analysis")
|
||||
public void pmd() {
|
||||
public void pmd() throws Exception {
|
||||
new PmdOperation()
|
||||
.fromProject(this)
|
||||
.failOnViolation(true)
|
||||
|
|
|
@ -18,15 +18,20 @@ package rife.bld.extension;
|
|||
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
|
||||
import rife.bld.BaseProject;
|
||||
import rife.bld.extension.kotlin.CompileOptions;
|
||||
import rife.bld.extension.kotlin.CompilerPlugin;
|
||||
import rife.bld.operations.AbstractOperation;
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
import rife.tools.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Compiles main and test Kotlin sources in the relevant build directories.
|
||||
|
@ -35,10 +40,6 @@ import java.util.regex.Pattern;
|
|||
* @since 1.0
|
||||
*/
|
||||
public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOperation> {
|
||||
/**
|
||||
* The Kotlin file (.kt) pattern.
|
||||
*/
|
||||
public static final Pattern KOTLIN_FILE_PATTERN = Pattern.compile("^.*\\.kt$");
|
||||
private static final Logger LOGGER = Logger.getLogger(CompileKotlinOperation.class.getName());
|
||||
private final Collection<String> compileMainClasspath_ = new ArrayList<>();
|
||||
private final Collection<String> compileTestClasspath_ = new ArrayList<>();
|
||||
|
@ -49,11 +50,11 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
private final Collection<File> testSourceFiles_ = new ArrayList<>();
|
||||
private File buildMainDirectory_;
|
||||
private File buildTestDirectory_;
|
||||
private CompileKotlinOptions compileOptions_ = new CompileKotlinOptions();
|
||||
private CompileOptions compileOptions_ = new CompileOptions();
|
||||
private BaseProject project_;
|
||||
|
||||
/**
|
||||
* Returns the list of JARs contained in a given directory.
|
||||
* Returns the list of Java archives contained in a given directory.
|
||||
*
|
||||
* @param directory the directory
|
||||
* @param regex the regular expression to match
|
||||
|
@ -77,26 +78,6 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
return jars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of Kotlin source file {{@code .kt}} contained in a given directory.
|
||||
*
|
||||
* @param directory the directory
|
||||
* @return the list of Kotlin files
|
||||
*/
|
||||
public static Collection<File> getKotlinFileList(File directory) {
|
||||
if (directory == null) {
|
||||
return Collections.emptyList();
|
||||
} else if (!directory.exists()) {
|
||||
if (LOGGER.isLoggable(Level.WARNING)) {
|
||||
LOGGER.warning("Directory not found: " + directory.getAbsolutePath());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return FileUtils.getFileList(directory, KOTLIN_FILE_PATTERN, null).stream().map((file) ->
|
||||
new File(directory, file)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the given string is not blank.
|
||||
*
|
||||
|
@ -121,7 +102,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
/**
|
||||
* Retrieves the main build destination directory.
|
||||
*
|
||||
* @return the main build destination
|
||||
* @return the main build directory
|
||||
*/
|
||||
public File buildMainDirectory() {
|
||||
return buildMainDirectory_;
|
||||
|
@ -141,7 +122,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
/**
|
||||
* Retrieves the test build destination directory.
|
||||
*
|
||||
* @return the test build destination
|
||||
* @return the test build directory
|
||||
*/
|
||||
public File buildTestDirectory() {
|
||||
return buildTestDirectory_;
|
||||
|
@ -154,14 +135,14 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation compileMainClasspath(String... classpath) {
|
||||
Collections.addAll(compileMainClasspath_, classpath);
|
||||
compileMainClasspath_.addAll(List.of(classpath));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of entries for the main compilation classpath.
|
||||
* Provides the entries for the main compilation classpath.
|
||||
*
|
||||
* @param classpath a list of classpath entries
|
||||
* @param classpath the classpath entries
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation compileMainClasspath(Collection<String> classpath) {
|
||||
|
@ -170,30 +151,30 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of entries for the main compilation classpath.
|
||||
* Retrieves the entries for the main compilation classpath.
|
||||
*
|
||||
* @return the main compilation classpath list
|
||||
* @return the classpath entries
|
||||
*/
|
||||
public Collection<String> compileMainClasspath() {
|
||||
return compileMainClasspath_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of compilation options for the compiler.
|
||||
* Retrieves the compilation options for the compiler.
|
||||
*
|
||||
* @return the compile kotlin options
|
||||
* @return the compilation options
|
||||
*/
|
||||
public CompileKotlinOptions compileOptions() {
|
||||
public CompileOptions compileOptions() {
|
||||
return compileOptions_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of compilation options to pass to the Kotlin compiler.
|
||||
* Provides the compilation options to pass to the Kotlin compiler.
|
||||
*
|
||||
* @param options the compiler options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation compileOptions(CompileKotlinOptions options) {
|
||||
public CompileKotlinOperation compileOptions(CompileOptions options) {
|
||||
compileOptions_ = options;
|
||||
return this;
|
||||
}
|
||||
|
@ -205,14 +186,14 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation compileTestClasspath(String... classpath) {
|
||||
Collections.addAll(compileTestClasspath_, classpath);
|
||||
compileTestClasspath_.addAll(List.of(classpath));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of entries for the test compilation classpath.
|
||||
* Provides the entries for the test compilation classpath.
|
||||
*
|
||||
* @param classpath a list of classpath entries
|
||||
* @param classpath the classpath entries
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation compileTestClasspath(Collection<String> classpath) {
|
||||
|
@ -221,9 +202,9 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of entries for the test compilation classpath.
|
||||
* Retrieves the entries for the test compilation classpath.
|
||||
*
|
||||
* @return the test compilation classpath list
|
||||
* @return the classpath entries
|
||||
*/
|
||||
public Collection<String> compileTestClasspath() {
|
||||
return compileTestClasspath_;
|
||||
|
@ -234,10 +215,12 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
*/
|
||||
@Override
|
||||
@SuppressWarnings("PMD.SystemPrintln")
|
||||
public void execute()
|
||||
throws IOException {
|
||||
public void execute() throws Exception {
|
||||
if (project_ == null) {
|
||||
throw new IllegalArgumentException("A project must be specified.");
|
||||
if (LOGGER.isLoggable(Level.SEVERE) && !silent()) {
|
||||
LOGGER.severe("A project must be specified.");
|
||||
}
|
||||
throw new ExitStatusException(ExitStatusException.EXIT_FAILURE);
|
||||
}
|
||||
|
||||
executeCreateBuildDirectories();
|
||||
|
@ -252,11 +235,10 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
/**
|
||||
* Part of the {@link #execute execute} operation, builds the main sources.
|
||||
*
|
||||
* @throws IOException if an error occurs
|
||||
* @throws ExitStatusException if an error occurs
|
||||
*/
|
||||
@SuppressWarnings("PMD.SystemPrintln")
|
||||
protected void executeBuildMainSources()
|
||||
throws IOException {
|
||||
protected void executeBuildMainSources() throws ExitStatusException {
|
||||
if (!silent()) {
|
||||
System.out.println("Compiling Kotlin main sources.");
|
||||
}
|
||||
|
@ -275,11 +257,11 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @param sources the source files to compile
|
||||
* @param destination the destination directory
|
||||
* @param friendPaths the output directory for friendly modules
|
||||
* @throws IOException if an error occurs
|
||||
* @throws ExitStatusException if an error occurs
|
||||
*/
|
||||
protected void executeBuildSources(Collection<String> classpath, Collection<File> sources, File destination,
|
||||
File friendPaths)
|
||||
throws IOException {
|
||||
throws ExitStatusException {
|
||||
if (sources.isEmpty() || destination == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -317,20 +299,19 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
LOGGER.fine("kotlinc " + String.join(" ", args));
|
||||
}
|
||||
|
||||
var exitCode = k2.exec(System.err, args.toArray(new String[0]));
|
||||
var exitCode = k2.exec(System.err, args.toArray(String[]::new));
|
||||
if (exitCode.getCode() != 0) {
|
||||
throw new IOException("Kotlin compilation failed.");
|
||||
throw new ExitStatusException(exitCode.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the {@link #execute execute} operation, builds the test sources.
|
||||
*
|
||||
* @throws IOException if an error occurs
|
||||
* @throws ExitStatusException if an error occurs
|
||||
*/
|
||||
@SuppressWarnings("PMD.SystemPrintln")
|
||||
protected void executeBuildTestSources()
|
||||
throws IOException {
|
||||
protected void executeBuildTestSources() throws ExitStatusException {
|
||||
if (!silent()) {
|
||||
System.out.println("Compiling Kotlin test sources.");
|
||||
}
|
||||
|
@ -364,12 +345,12 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* <li>{@link #buildTestDirectory() buildTestDirectory}</li>
|
||||
* <li>{@link #compileMainClasspath() compileMainClassPath}</li>
|
||||
* <li>{@link #compileTestClasspath() compilesTestClassPath}</li>
|
||||
* <li>{@link #mainSourceFiles() mainSourceFiles} to the {@code kotlin} directory in
|
||||
* <li>{@link #mainSourceDirectories()} () mainSourceDirectories} to the {@code kotlin} directory in
|
||||
* {@link BaseProject#srcMainDirectory() srcMainDirectory}</li>
|
||||
* <li>{@link #testSourceFiles() testSourceFile} to the {@code kotlin} directory in
|
||||
* <li>{@link #testSourceDirectories() testSourceDirectories} to the {@code kotlin} directory in
|
||||
* {@link BaseProject#srcTestDirectory() srcTestDirectory}</li>
|
||||
* <li>{@link CompileKotlinOptions#jdkRelease jdkRelease} to {@link BaseProject#javaRelease() javaRelease}</li>
|
||||
* <li>{@link CompileKotlinOptions#noStdLib(boolean) noStdLib} to {@code true}</li>
|
||||
* <li>{@link CompileOptions#jdkRelease jdkRelease} to {@link BaseProject#javaRelease() javaRelease}</li>
|
||||
* <li>{@link CompileOptions#noStdLib(boolean) noStdLib} to {@code true}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param project the project to configure the compile operation from
|
||||
|
@ -381,8 +362,8 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
.buildTestDirectory(project.buildTestDirectory())
|
||||
.compileMainClasspath(project.compileMainClasspath())
|
||||
.compileTestClasspath(project.compileTestClasspath())
|
||||
.mainSourceFiles(getKotlinFileList(new File(project.srcMainDirectory(), "kotlin")))
|
||||
.testSourceFiles(getKotlinFileList(new File(project.srcTestDirectory(), "kotlin")));
|
||||
.mainSourceDirectories(new File(project.srcMainDirectory(), "kotlin"))
|
||||
.testSourceDirectories(new File(project.srcTestDirectory(), "kotlin"));
|
||||
if (project.javaRelease() != null && !compileOptions_.hasRelease()) {
|
||||
compileOptions_.jdkRelease(project.javaRelease());
|
||||
}
|
||||
|
@ -398,14 +379,25 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation mainSourceDirectories(File... directories) {
|
||||
Collections.addAll(mainSourceDirectories_, directories);
|
||||
mainSourceDirectories_.addAll(List.of(directories));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of main source directories that should be compiled.
|
||||
* Provides main source directories that should be compiled.
|
||||
*
|
||||
* @param directories a list of main source directories
|
||||
* @param directories one or more main source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation mainSourceDirectories(String... directories) {
|
||||
mainSourceDirectories_.addAll(Arrays.stream(directories).map(File::new).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the main source directories that should be compiled.
|
||||
*
|
||||
* @param directories the main source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation mainSourceDirectories(Collection<File> directories) {
|
||||
|
@ -414,29 +406,40 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of main source directories that should be compiled.
|
||||
* Retrieves the main source directories that should be compiled.
|
||||
*
|
||||
* @return the list of main source directories to compile
|
||||
* @return the main source directories
|
||||
*/
|
||||
public Collection<File> mainSourceDirectories() {
|
||||
return mainSourceDirectories_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides main files that should be compiled.
|
||||
* Provides main source files that should be compiled.
|
||||
*
|
||||
* @param files one or more main files
|
||||
* @param files one or more main source files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation mainSourceFiles(File... files) {
|
||||
mainSourceFiles_.addAll(Arrays.asList(files));
|
||||
mainSourceFiles_.addAll(List.of(files));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of main files that should be compiled.
|
||||
* Provides main source files that should be compiled.
|
||||
*
|
||||
* @param files a list of main files
|
||||
* @param files one or more main source files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation mainSourceFiles(String... files) {
|
||||
mainSourceFiles_.addAll(Arrays.stream(files).map(File::new).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the main source files that should be compiled.
|
||||
*
|
||||
* @param files the main source files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation mainSourceFiles(Collection<File> files) {
|
||||
|
@ -445,9 +448,9 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of main files that should be compiled.
|
||||
* Retrieves the main files that should be compiled.
|
||||
*
|
||||
* @return the list of main files to compile
|
||||
* @return the files
|
||||
*/
|
||||
public Collection<File> mainSourceFiles() {
|
||||
return mainSourceFiles_;
|
||||
|
@ -460,14 +463,23 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @return this class instance
|
||||
*/
|
||||
public CompileKotlinOperation plugins(String... plugins) {
|
||||
Collections.addAll(plugins_, plugins);
|
||||
plugins_.addAll(List.of(plugins));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the compiler plugins.
|
||||
*
|
||||
* @return the compiler plugins
|
||||
*/
|
||||
public Collection<String> plugins() {
|
||||
return plugins_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides compiler plugins.
|
||||
*
|
||||
* @param plugins a list of plugins
|
||||
* @param plugins the compiler plugins
|
||||
* @return this class instance
|
||||
*/
|
||||
public CompileKotlinOperation plugins(Collection<String> plugins) {
|
||||
|
@ -482,9 +494,9 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @param plugins one or more plugins
|
||||
* @return this class instance
|
||||
*/
|
||||
public CompileKotlinOperation plugins(File directory, CompileKotlinPlugin... plugins) {
|
||||
public CompileKotlinOperation plugins(File directory, CompilerPlugin... plugins) {
|
||||
for (var plugin : plugins) {
|
||||
plugins_.addAll(getJarList(directory, plugin.label));
|
||||
plugins_.addAll(getJarList(directory, plugin.regex));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -492,14 +504,27 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
/**
|
||||
* Provides compiler plugins.
|
||||
*
|
||||
* @param jars the list of plugin JARs
|
||||
* @param plugins one or more plugins
|
||||
* @return this class instance
|
||||
*/
|
||||
public CompileKotlinOperation plugins(Collection<File> jars, CompileKotlinPlugin... plugins) {
|
||||
public CompileKotlinOperation plugins(CompilerPlugin... plugins) {
|
||||
for (var plugin : plugins) {
|
||||
plugins_.addAll(getJarList(project_.libBldDirectory(), plugin.regex));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides compiler plugins.
|
||||
*
|
||||
* @param jars the plugins Java archives
|
||||
* @param plugins one or more plugins
|
||||
* @return this class instance
|
||||
*/
|
||||
public CompileKotlinOperation plugins(Collection<File> jars, CompilerPlugin... plugins) {
|
||||
jars.forEach(jar -> {
|
||||
for (var plugin : plugins) {
|
||||
if (jar.getName().matches(plugin.label)) {
|
||||
if (jar.getName().matches(plugin.regex)) {
|
||||
plugins_.add(jar.getAbsolutePath());
|
||||
break;
|
||||
}
|
||||
|
@ -512,10 +537,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
// Combine Kotlin sources
|
||||
private Collection<File> sources(Collection<File> files, Collection<File> directories) {
|
||||
var sources = new ArrayList<>(files);
|
||||
for (var directory : directories) {
|
||||
sources.addAll(getKotlinFileList(directory));
|
||||
}
|
||||
|
||||
sources.addAll(directories);
|
||||
return sources;
|
||||
}
|
||||
|
||||
|
@ -526,14 +548,25 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation testSourceDirectories(File... directories) {
|
||||
Collections.addAll(testSourceDirectories_, directories);
|
||||
testSourceDirectories_.addAll(List.of(directories));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of test source directories that should be compiled.
|
||||
* Provides test source directories that should be compiled.
|
||||
*
|
||||
* @param directories a list of test source directories
|
||||
* @param directories one or more test source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation testSourceDirectories(String... directories) {
|
||||
testSourceDirectories_.addAll(Arrays.stream(directories).map(File::new).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the test source directories that should be compiled.
|
||||
*
|
||||
* @param directories the test source directories
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation testSourceDirectories(Collection<File> directories) {
|
||||
|
@ -542,29 +575,40 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of test source directories that should be compiled.
|
||||
* Retrieves the test source directories that should be compiled.
|
||||
*
|
||||
* @return the list of test source directories to compile
|
||||
* @return the test source directories
|
||||
*/
|
||||
public Collection<File> testSourceDirectories() {
|
||||
return testSourceDirectories_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test files that should be compiled.
|
||||
* Provides test source files that should be compiled.
|
||||
*
|
||||
* @param files one or more test files
|
||||
* @param files one or more test source files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation testSourceFiles(File... files) {
|
||||
testSourceFiles_.addAll(Arrays.asList(files));
|
||||
testSourceFiles_.addAll(List.of(files));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of test files that should be compiled.
|
||||
* Provides the test sources files that should be compiled.
|
||||
*
|
||||
* @param files a list of test files
|
||||
* @param files one or more test source files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation testSourceFiles(String... files) {
|
||||
testSourceFiles_.addAll(Arrays.stream(files).map(File::new).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the test source files that should be compiled.
|
||||
*
|
||||
* @param files the test source files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOperation testSourceFiles(Collection<File> files) {
|
||||
|
@ -573,9 +617,9 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of test files that should be compiled.
|
||||
* Retrieves the test files that should be compiled.
|
||||
*
|
||||
* @return the list of test files to compile
|
||||
* @return the test files
|
||||
*/
|
||||
public Collection<File> testSourceFiles() {
|
||||
return testSourceFiles_;
|
||||
|
|
|
@ -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's analysis platforms.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum AnalysisPlatform {
|
||||
JVM, JS, NATIVE, COMMON, ANDROID
|
||||
}
|
|
@ -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 documented visibilities.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum DocumentedVisibility {
|
||||
PUBLIC, PRIVATE, PROTECTED, INTERNAL, PACKAGE
|
||||
}
|
|
@ -1,609 +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 rife.bld.BaseProject;
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
import rife.bld.operations.AbstractProcessOperation;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
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.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
|
||||
public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||
private final static String GFM_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|gfm-plugin|freemarker).*\\.jar$";
|
||||
private final static String HTML_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|kotlinx-html-jvm|freemarker).*\\.jar$";
|
||||
private final static String JAVADOC_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|javadoc-plugin|kotlin-as-java-plugin|korte-jvm).*\\.jar$";
|
||||
private final static String JEKYLL_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|jekyll-plugin|gfm-plugin|freemarker).*\\.jar$";
|
||||
private final Logger LOGGER = Logger.getLogger(DokkaOperation.class.getName());
|
||||
private final Map<String, String> globalLinks_ = new ConcurrentHashMap<>();
|
||||
private final Collection<String> globalPackageOptions_ = new ArrayList<>();
|
||||
private final Collection<String> globalSrcLinks_ = new ArrayList<>();
|
||||
private final Collection<String> includes_ = new ArrayList<>();
|
||||
private final Collection<String> pluginsClasspath_ = new ArrayList<>();
|
||||
private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>();
|
||||
private boolean delayTemplateSubstitution_;
|
||||
private boolean failOnWarning_;
|
||||
private File json;
|
||||
private LoggingLevel loggingLevel_;
|
||||
private String moduleName_;
|
||||
private String moduleVersion_;
|
||||
private boolean noSuppressObviousFunctions_;
|
||||
private boolean offlineMode_;
|
||||
private File outputDir_;
|
||||
private BaseProject project_;
|
||||
private SourceSet sourceSet_;
|
||||
private boolean suppressInheritedMembers_;
|
||||
|
||||
// Encodes to JSON adding braces as needed
|
||||
private static String encodeJson(final String json) {
|
||||
var sb = new StringBuilder(json);
|
||||
if (!json.startsWith("{") || !json.endsWith("}")) {
|
||||
sb.insert(0, "{").append('}');
|
||||
}
|
||||
return StringUtils.encodeJson(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the delay substitution of some elements.
|
||||
* <p>
|
||||
* 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<String> executeConstructProcessCommandList() {
|
||||
if (project_ == null) {
|
||||
throw new IllegalArgumentException("A project must be specified.");
|
||||
}
|
||||
|
||||
final List<String> args = new ArrayList<>();
|
||||
|
||||
// java
|
||||
args.add(javaTool());
|
||||
|
||||
var cli = CompileKotlinOperation.getJarList(project_.libBldDirectory(), "^.*dokka-cli.*\\.jar$");
|
||||
|
||||
if (cli.size() != 1) {
|
||||
throw new RuntimeException("The dokka-cli JAR could not be found.");
|
||||
}
|
||||
|
||||
// -jar dokka-cli
|
||||
args.add("-jar");
|
||||
args.add(cli.get(0));
|
||||
|
||||
// -pluginClasspath
|
||||
if (!pluginsClasspath_.isEmpty()) {
|
||||
args.add("-pluginsClasspath");
|
||||
args.add(String.join(";", pluginsClasspath_));
|
||||
}
|
||||
|
||||
// -sourceSet
|
||||
var sourceSetArgs = sourceSet_.args();
|
||||
if (sourceSetArgs.isEmpty()) {
|
||||
throw new IllegalArgumentException("At least one sourceSet is required.");
|
||||
} else {
|
||||
args.add("-sourceSet");
|
||||
args.add(String.join(" ", sourceSet_.args()));
|
||||
}
|
||||
|
||||
// -outputDir
|
||||
if (outputDir_ != null) {
|
||||
if (!outputDir_.exists() && !outputDir_.mkdirs()) {
|
||||
throw new RuntimeException("Could not create: " + outputDir_.getAbsolutePath());
|
||||
}
|
||||
|
||||
args.add("-outputDir");
|
||||
args.add(outputDir_.getAbsolutePath());
|
||||
}
|
||||
|
||||
// -delayTemplateSubstitution
|
||||
if (delayTemplateSubstitution_) {
|
||||
args.add("-delayTemplateSubstitution");
|
||||
}
|
||||
|
||||
// -failOnWarning
|
||||
if (failOnWarning_) {
|
||||
args.add("-failOnWarning");
|
||||
}
|
||||
|
||||
// -globalLinks_
|
||||
if (!globalLinks_.isEmpty()) {
|
||||
args.add("-globalLinks");
|
||||
var links = new ArrayList<String>();
|
||||
globalLinks_.forEach((k, v) ->
|
||||
links.add(String.format("%s^%s", k, v)));
|
||||
args.add(String.join("^^", links));
|
||||
}
|
||||
|
||||
// -globalPackageOptions
|
||||
if (!globalPackageOptions_.isEmpty()) {
|
||||
args.add("-globalPackageOptions");
|
||||
args.add(String.join(";", globalPackageOptions_));
|
||||
}
|
||||
|
||||
// -globalSrcLinks
|
||||
if (!globalSrcLinks_.isEmpty()) {
|
||||
args.add("-globalSrcLinks_");
|
||||
args.add(String.join(";", globalSrcLinks_));
|
||||
}
|
||||
|
||||
// -includes
|
||||
if (!includes_.isEmpty()) {
|
||||
args.add("-includes");
|
||||
args.add(String.join(";", includes_));
|
||||
}
|
||||
|
||||
// -loggingLevel
|
||||
if (loggingLevel_ != null) {
|
||||
args.add("-loggingLevel");
|
||||
args.add(loggingLevel_.name().toLowerCase());
|
||||
}
|
||||
|
||||
// -moduleName
|
||||
if (isNotBlank(moduleName_)) {
|
||||
args.add("-moduleName");
|
||||
args.add(moduleName_);
|
||||
}
|
||||
|
||||
// -moduleVersion
|
||||
if (isNotBlank(moduleVersion_)) {
|
||||
args.add("-moduleVersion");
|
||||
args.add(moduleVersion_);
|
||||
}
|
||||
|
||||
// -noSuppressObviousFunctions
|
||||
if (noSuppressObviousFunctions_) {
|
||||
args.add("-noSuppressObviousFunctions");
|
||||
}
|
||||
|
||||
// -offlineMode
|
||||
if (offlineMode_) {
|
||||
args.add("-offlineMode");
|
||||
}
|
||||
|
||||
// -pluginConfiguration
|
||||
if (!pluginsConfiguration_.isEmpty()) {
|
||||
args.add("-pluginsConfiguration");
|
||||
var confs = new ArrayList<String>();
|
||||
pluginsConfiguration_.forEach((k, v) ->
|
||||
confs.add(String.format("%s=%s", encodeJson(k), encodeJson(v))));
|
||||
args.add(String.join("^^", confs));
|
||||
}
|
||||
|
||||
// -suppressInheritedMembers
|
||||
if (suppressInheritedMembers_) {
|
||||
args.add("-suppressInheritedMembers");
|
||||
}
|
||||
|
||||
// json
|
||||
if (json != null) {
|
||||
args.add(json.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine(String.join(" ", args));
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the operation from a {@link BaseProject}.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<String, String> globalLinks) {
|
||||
globalLinks_.putAll(globalLinks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global list of package configurations.
|
||||
* <p>
|
||||
* Using format:
|
||||
* <ul>
|
||||
* <li>matchingRegexp</li>
|
||||
* <li>-deprecated</li>
|
||||
* <li>-privateApi</li>
|
||||
* <li>+warnUndocumented</li>
|
||||
* <li>+suppress</li>
|
||||
* <li>+visibility:PUBLIC</li>
|
||||
* <li>...</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param options ome pr more package configurations
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation globalPackageOptions(String... options) {
|
||||
Collections.addAll(globalPackageOptions_, options);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global list of package configurations.
|
||||
* <p>
|
||||
* Using format:
|
||||
* <ul>
|
||||
* <li>matchingRegexp</li>
|
||||
* <li>-deprecated</li>
|
||||
* <li>-privateApi</li>
|
||||
* <li>+warnUndocumented</li>
|
||||
* <li>+suppress</li>
|
||||
* <li>+visibility:PUBLIC</li>
|
||||
* <li>...</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param options the list of package configurations
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation globalPackageOptions(Collection<String> options) {
|
||||
globalPackageOptions_.addAll(options);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global mapping between a source directory and a Web service for browsing the code.
|
||||
*
|
||||
* @param links one or more links mapping
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation globalSrcLink(String... links) {
|
||||
Collections.addAll(globalSrcLinks_, links);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the global mapping between a source directory and a Web service for browsing the code.
|
||||
*
|
||||
* @param links the links mapping
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation globalSrcLink(Collection<String> links) {
|
||||
globalSrcLinks_.addAll(links);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Markdown files that contain module and package documentation.
|
||||
* <p>
|
||||
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
|
||||
* <p>
|
||||
* This can be configured on per-package basis.
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation includes(String... files) {
|
||||
Collections.addAll(includes_, files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Markdown files that contain module and package documentation.
|
||||
* <p>
|
||||
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
|
||||
* <p>
|
||||
* This can be configured on per-package basis.
|
||||
*
|
||||
* @param files the list of files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation includes(Collection<String> files) {
|
||||
includes_.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON configuration file path.
|
||||
*
|
||||
* @param configuration the configuration file path
|
||||
*/
|
||||
public DokkaOperation json(File configuration) {
|
||||
json = configuration;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logging level.
|
||||
*
|
||||
* @param loggingLevel the logging level
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation loggingLevel(LoggingLevel loggingLevel) {
|
||||
loggingLevel_ = loggingLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the project/module. Default is {@code root}.
|
||||
* <p>
|
||||
* 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
|
||||
* <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/">kotlin.Any</a> and {@link java.lang.Object}.
|
||||
* <p>
|
||||
* A function is considered to be obvious if it is:
|
||||
* <ul>
|
||||
* <li>Inherited from <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/">kotlin.Any</a>,
|
||||
* <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/">Kotlin.Enum</a>, {@link java.lang.Object}
|
||||
* or {@link java.lang.Enum}, such as {@code equals}, {@code hashCode}, {@code toString}.
|
||||
* <li>Synthetic (generated by the compiler) and does not have any documentation, such as
|
||||
* {@code dataClass.componentN} or {@code dataClass.copy}.
|
||||
* </ul>
|
||||
*
|
||||
* @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.
|
||||
* <p>
|
||||
* This includes package-lists used for generating external documentation links. For example, to make classes from
|
||||
* the standard library clickable.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<String, String> pluginConfiguratione) {
|
||||
pluginsConfiguration_.putAll(pluginConfiguratione);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of jars with Dokka plugins and their dependencies.
|
||||
*
|
||||
* @param jars one or more jars
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation pluginsClasspath(String... jars) {
|
||||
Collections.addAll(pluginsClasspath_, jars);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of jars with Dokka plugins and their dependencies.
|
||||
*
|
||||
* @param jars the list of jars
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation pluginsClasspath(Collection<String> jars) {
|
||||
pluginsClasspath_.addAll(jars);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the list of Dokka plugins.
|
||||
*
|
||||
* @param clear set to clear the list
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation pluginsClasspath(boolean clear) {
|
||||
if (clear) {
|
||||
pluginsClasspath_.clear();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configurations for a source set.
|
||||
* <p>
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -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 <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum LoggingLevel {
|
||||
DEBUG, PROGRESS, INFO, WARN, ERROR
|
||||
}
|
|
@ -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 <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum OutputFormat {
|
||||
JAVADOC, JEKYLL, HTML, MARKDOWN
|
||||
}
|
|
@ -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 <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SourceSet {
|
||||
private static final String SEMICOLON = ";";
|
||||
private final Collection<String> classpath_ = new ArrayList<>();
|
||||
private final Map<String, String> dependentSourceSets_ = new ConcurrentHashMap<>();
|
||||
private final Collection<DocumentedVisibility> documentedVisibilities_ = new ArrayList<>();
|
||||
private final Map<String, String> externalDocumentationLinks_ = new ConcurrentHashMap<>();
|
||||
private final Collection<String> includes_ = new ArrayList<>();
|
||||
private final Collection<String> perPackageOptions_ = new ArrayList<>();
|
||||
private final Collection<String> samples_ = new ArrayList<>();
|
||||
private final Map<String, String> srcLinks_ = new ConcurrentHashMap<>();
|
||||
private final Collection<String> src_ = new ArrayList<>();
|
||||
private final Collection<String> suppressedFiles_ = new ArrayList<>();
|
||||
private AnalysisPlatform analysisPlatform_;
|
||||
private String apiVersion_;
|
||||
private String displayName_;
|
||||
private String jdkVersion_;
|
||||
private String languageVersion_;
|
||||
private boolean noJdkLink_;
|
||||
private boolean noSkipEmptyPackages_;
|
||||
private boolean noStdlibLink_;
|
||||
private boolean reportUndocumented_;
|
||||
private boolean skipDeprecated_;
|
||||
private String sourceSetName_;
|
||||
|
||||
/**
|
||||
* Sets the platform used for setting up analysis. Default is {@link AnalysisPlatform#JVM JVM}
|
||||
* <p>
|
||||
* 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<String> args() {
|
||||
var args = new ArrayList<String>();
|
||||
|
||||
// -analysisPlatform
|
||||
if (analysisPlatform_ != null) {
|
||||
args.add("-analysisPlatform");
|
||||
args.add(analysisPlatform_.name().toLowerCase());
|
||||
}
|
||||
|
||||
// -apiVersion
|
||||
if (apiVersion_ != null) {
|
||||
args.add("-apiVersion");
|
||||
args.add(apiVersion_);
|
||||
}
|
||||
|
||||
// -classpath
|
||||
if (!classpath_.isEmpty()) {
|
||||
args.add("-classpath");
|
||||
args.add(String.join(SEMICOLON, classpath_));
|
||||
}
|
||||
|
||||
// -dependentSourceSets
|
||||
if (!dependentSourceSets_.isEmpty()) {
|
||||
args.add("-dependentSourceSets");
|
||||
var deps = new ArrayList<String>();
|
||||
dependentSourceSets_.forEach((k, v) -> deps.add(String.format("%s/%s", k, v)));
|
||||
args.add(String.join(SEMICOLON, deps));
|
||||
}
|
||||
|
||||
// -displayName
|
||||
if (displayName_ != null) {
|
||||
args.add("-displayName");
|
||||
args.add(displayName_);
|
||||
}
|
||||
|
||||
// -documentedVisibilities
|
||||
if (!documentedVisibilities_.isEmpty()) {
|
||||
args.add("-documentedVisibilities");
|
||||
var vis = new ArrayList<String>();
|
||||
documentedVisibilities_.forEach(d -> vis.add(d.name().toLowerCase()));
|
||||
args.add(String.join(SEMICOLON, vis));
|
||||
}
|
||||
|
||||
// -externalDocumentationLinks
|
||||
if (!externalDocumentationLinks_.isEmpty()) {
|
||||
args.add("-externalDocumentationLinks");
|
||||
var links = new ArrayList<String>();
|
||||
externalDocumentationLinks_.forEach((k, v) -> links.add(String.format("%s^%s", k, v)));
|
||||
args.add(String.join("^^", links));
|
||||
}
|
||||
|
||||
// -jdkVersion
|
||||
if (jdkVersion_ != null) {
|
||||
args.add("-jdkVersion");
|
||||
args.add(jdkVersion_);
|
||||
}
|
||||
|
||||
// -includes
|
||||
if (!includes_.isEmpty()) {
|
||||
args.add("-includes");
|
||||
args.add(String.join(SEMICOLON, includes_));
|
||||
}
|
||||
|
||||
// -languageVersion
|
||||
if (languageVersion_ != null) {
|
||||
args.add("-languageVersion");
|
||||
args.add(languageVersion_);
|
||||
}
|
||||
|
||||
// -noJdkLink
|
||||
if (noJdkLink_) {
|
||||
args.add("-noJdkLink");
|
||||
args.add(String.valueOf(noJdkLink_));
|
||||
}
|
||||
|
||||
// -noSkipEmptyPackages
|
||||
if (noSkipEmptyPackages_) {
|
||||
args.add("-noSkipEmptyPackages");
|
||||
args.add(String.valueOf(noSkipEmptyPackages_));
|
||||
}
|
||||
|
||||
// -noStdlibLink
|
||||
if (noStdlibLink_) {
|
||||
args.add("-noStdlibLink");
|
||||
args.add(String.valueOf(noStdlibLink_));
|
||||
}
|
||||
|
||||
// -reportUndocumented
|
||||
if (reportUndocumented_) {
|
||||
args.add("-reportUndocumented");
|
||||
args.add(String.valueOf(reportUndocumented_));
|
||||
}
|
||||
|
||||
// -perPackageOptions
|
||||
if (!perPackageOptions_.isEmpty()) {
|
||||
args.add("-perPackageOptions");
|
||||
args.add(String.join(SEMICOLON, perPackageOptions_));
|
||||
}
|
||||
|
||||
// -samples
|
||||
if (!samples_.isEmpty()) {
|
||||
args.add("-samples");
|
||||
args.add(String.join(SEMICOLON, samples_));
|
||||
}
|
||||
|
||||
// -skipDeprecated
|
||||
if (skipDeprecated_) {
|
||||
args.add("-skipDeprecated");
|
||||
args.add(String.valueOf(skipDeprecated_));
|
||||
}
|
||||
|
||||
// -src
|
||||
if (!src_.isEmpty()) {
|
||||
args.add("-src");
|
||||
args.add(String.join(SEMICOLON, src_));
|
||||
}
|
||||
|
||||
// -srcLink
|
||||
if (!srcLinks_.isEmpty()) {
|
||||
args.add("-srcLink");
|
||||
var links = new ArrayList<String>();
|
||||
srcLinks_.forEach((k, v) -> links.add(String.format("%s=%s", k, v)));
|
||||
args.add(String.join(SEMICOLON, links));
|
||||
}
|
||||
|
||||
// -sourceSetName
|
||||
if (sourceSetName_ != null) {
|
||||
args.add("-sourceSetName");
|
||||
args.add(sourceSetName_);
|
||||
}
|
||||
|
||||
// -suppressedFiles
|
||||
if (!suppressedFiles_.isEmpty()) {
|
||||
args.add("-suppressedFiles");
|
||||
args.add(String.join(SEMICOLON, suppressedFiles_));
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets classpath for analysis and interactive samples.
|
||||
* <p>
|
||||
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
|
||||
* <p>
|
||||
* 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) {
|
||||
Collections.addAll(classpath_, files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets classpath for analysis and interactive samples.
|
||||
* <p>
|
||||
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
|
||||
* <p>
|
||||
* This option accepts both {@code .jar} and {@code .klib} files.
|
||||
*
|
||||
* @param files the list of files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet classpath(Collection<String> files) {
|
||||
classpath_.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets classpath for analysis and interactive samples.
|
||||
* <p>
|
||||
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
|
||||
* <p>
|
||||
* This option accepts both {@code .jar} and {@code .klib} files.
|
||||
*
|
||||
* @param files the list of files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet classpath(List<File> files) {
|
||||
files.forEach(it -> classpath_.add(it.getAbsolutePath()));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the names of dependent source sets.
|
||||
*
|
||||
* @param moduleName the module name
|
||||
* @param sourceSetName the source set name
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet dependentSourceSets(String moduleName, String sourceSetName) {
|
||||
dependentSourceSets_.put(moduleName, sourceSetName);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the names of dependent source sets.
|
||||
*
|
||||
* @param dependentSourceSets the map of dependent source set names
|
||||
* @return this operation instance
|
||||
* @see #dependentSourceSets(String, String)
|
||||
*/
|
||||
public SourceSet dependentSourceSets(Map<String, String> dependentSourceSets) {
|
||||
dependentSourceSets_.putAll(dependentSourceSets);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name of the source set, used both internally and externally.
|
||||
* <p>
|
||||
* 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}).
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<String, String> externalDocumentationLinks) {
|
||||
externalDocumentationLinks_.putAll(externalDocumentationLinks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Markdown files that contain module and package documentation.
|
||||
* <p>
|
||||
* A list of Markdown files that contain module and package documentation.
|
||||
* <p>
|
||||
* 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) {
|
||||
Collections.addAll(includes_, files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Markdown files that contain module and package documentation.
|
||||
* <p>
|
||||
* A list of Markdown files that contain module and package documentation.
|
||||
* <p>
|
||||
* 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<String> files) {
|
||||
includes_.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version of JDK to use for linking to JDK Javadocs.
|
||||
* <p>
|
||||
* The JDK version to use when generating external documentation links for Java types.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* The JDK version to use when generating external documentation links for Java types.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Whether to generate external documentation links to JDK's Javadocs.
|
||||
* <p>
|
||||
* The version of JDK Javadocs is determined by the {@link #jdkVersion jdkVersion} option.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Whether to generate external documentation links that lead to the API reference documentation of Kotlin's
|
||||
* standard library.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* A set of parameters specific to matched packages within this source set.
|
||||
* <p>
|
||||
* Using format:
|
||||
* <ul>
|
||||
* <li>matchingRegexp</li>
|
||||
* <li>-deprecated</li>
|
||||
* <li>-privateApi</li>
|
||||
* <li>+warnUndocumented</li>
|
||||
* <li>+suppress</li>
|
||||
* <li>+visibility:PUBLIC</li>
|
||||
* <li>...</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param perPackageOptions the list of per package options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet perPackageOptions(Collection<String> perPackageOptions) {
|
||||
perPackageOptions_.addAll(perPackageOptions);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of package source set configuration.
|
||||
* <p>
|
||||
* A set of parameters specific to matched packages within this source set.
|
||||
* <p>
|
||||
* Using format:
|
||||
* <ul>
|
||||
* <li>matchingRegexp</li>
|
||||
* <li>-deprecated</li>
|
||||
* <li>-privateApi</li>
|
||||
* <li>+warnUndocumented</li>
|
||||
* <li>+suppress</li>
|
||||
* <li>+visibility:PUBLIC</li>
|
||||
* <li>...</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param perPackageOptions the list of per package options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet perPackageOptions(String... perPackageOptions) {
|
||||
Collections.addAll(perPackageOptions_, perPackageOptions);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to report undocumented declarations.
|
||||
* <p>
|
||||
* Whether to emit warnings about visible undocumented declarations, that is declarations without KDocs after they
|
||||
* have been filtered by documentedVisibilities and other filters.
|
||||
* <p>
|
||||
* This setting works well with {@link DokkaOperation#failOnWarning}.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<String> samples) {
|
||||
samples_.addAll(samples);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of directories or files that contain sample functions.
|
||||
* <p>
|
||||
* 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) {
|
||||
Collections.addAll(samples_, samples);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to skip deprecated declarations.
|
||||
* <p>
|
||||
* Whether to document declarations annotated with {@code @Deprecated}.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<String> src) {
|
||||
src_.addAll(src);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source code roots to be analyzed and documented.
|
||||
* <p>
|
||||
* 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) {
|
||||
Collections.addAll(src_, 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.
|
||||
* <p>
|
||||
* The files to be suppressed when generating documentation.
|
||||
*
|
||||
* @param suppressedFiles the list of suppressed files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet suppressedFiles(Collection<String> suppressedFiles) {
|
||||
suppressedFiles_.addAll(suppressedFiles);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paths to files to be suppressed.
|
||||
* <p>
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -14,13 +14,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension;
|
||||
package rife.bld.extension.kotlin;
|
||||
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
|
||||
|
||||
|
@ -30,30 +33,30 @@ import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
|
|||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public class CompileKotlinOptions {
|
||||
private final List<String> advancedOptions_ = new ArrayList<>();
|
||||
private final List<String> argFile_ = new ArrayList<>();
|
||||
private final List<String> classpath_ = new ArrayList<>();
|
||||
private final List<String> jvmOptions_ = new ArrayList<>();
|
||||
private final List<String> optIn_ = new ArrayList<>();
|
||||
private final List<String> options_ = new ArrayList<>();
|
||||
private final List<String> plugin_ = new ArrayList<>();
|
||||
private final List<String> scriptTemplates_ = new ArrayList<>();
|
||||
public class CompileOptions {
|
||||
private final Collection<String> advancedOptions_ = new ArrayList<>();
|
||||
private final Collection<File> argFile_ = new ArrayList<>();
|
||||
private final Collection<File> classpath_ = new ArrayList<>();
|
||||
private final Collection<String> jvmOptions_ = new ArrayList<>();
|
||||
private final Collection<String> optIn_ = new ArrayList<>();
|
||||
private final Collection<String> options_ = new ArrayList<>();
|
||||
private final Collection<String> plugin_ = new ArrayList<>();
|
||||
private final Collection<String> scriptTemplates_ = new ArrayList<>();
|
||||
private String apiVersion_;
|
||||
private String expression_;
|
||||
private boolean includeRuntime_;
|
||||
private boolean javaParameters_;
|
||||
private String jdkHome_;
|
||||
private File jdkHome_;
|
||||
private String jdkRelease_;
|
||||
private String jvmTarget_;
|
||||
private String kotlinHome_;
|
||||
private File kotlinHome_;
|
||||
private String languageVersion_;
|
||||
private String moduleName_;
|
||||
private boolean noJdk_;
|
||||
private boolean noReflect_;
|
||||
private boolean noStdLib_;
|
||||
private boolean noWarn_;
|
||||
private String path_;
|
||||
private File path_;
|
||||
private boolean progressive_;
|
||||
private boolean verbose_;
|
||||
private boolean wError_;
|
||||
|
@ -64,29 +67,38 @@ public class CompileKotlinOptions {
|
|||
* @param options one or more advanced options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions advancedOptions(String... options) {
|
||||
Collections.addAll(advancedOptions_, options);
|
||||
public CompileOptions advancedOptions(String... options) {
|
||||
advancedOptions_.addAll(List.of(options));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify advanced compiler options.
|
||||
*
|
||||
* @param options list of compiler options
|
||||
* @param options the compiler options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions advancedOptions(Collection<String> options) {
|
||||
public CompileOptions advancedOptions(Collection<String> options) {
|
||||
advancedOptions_.addAll(options);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves advanced compiler options.
|
||||
*
|
||||
* @return the advanced compiler options
|
||||
*/
|
||||
public Collection<String> advancedOptions() {
|
||||
return advancedOptions_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow using declarations only from the specified version of Kotlin bundled libraries.
|
||||
*
|
||||
* @param version the api version
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions apiVersion(String version) {
|
||||
public CompileOptions apiVersion(String version) {
|
||||
apiVersion_ = version;
|
||||
return this;
|
||||
}
|
||||
|
@ -97,7 +109,7 @@ public class CompileKotlinOptions {
|
|||
* @param version the api version
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions apiVersion(int version) {
|
||||
public CompileOptions apiVersion(int version) {
|
||||
apiVersion_ = String.valueOf(version);
|
||||
return this;
|
||||
}
|
||||
|
@ -120,23 +132,56 @@ public class CompileKotlinOptions {
|
|||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions argFile(String... files) {
|
||||
Collections.addAll(argFile_, files);
|
||||
public CompileOptions argFile(String... files) {
|
||||
argFile_.addAll(Arrays.stream(files).map(File::new).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the compiler options from the given files.
|
||||
* <p>
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>{@code -include-runtime -d hello.jar hello.kt}</li>
|
||||
* </ul>
|
||||
* 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 (\).
|
||||
* <ul>
|
||||
* <li>{@code -include-runtime -d 'My folder'}</li>
|
||||
* </ul>
|
||||
* If the files reside in locations different from the current directory, use relative paths.
|
||||
*
|
||||
* @param files the list of files
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileOptions argFile(File... files) {
|
||||
argFile_.addAll(List.of(files));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read the compiler options from the given files.
|
||||
*
|
||||
* @param files the compiler options files
|
||||
* @return this operation instance
|
||||
* @see #argFile(String...)
|
||||
*/
|
||||
public CompileKotlinOptions argFile(Collection<String> files) {
|
||||
public CompileOptions argFile(Collection<File> files) {
|
||||
argFile_.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the files containing compiler options.
|
||||
*
|
||||
* @return the compiler options files
|
||||
*/
|
||||
public Collection<File> argFile() {
|
||||
return argFile_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the formatted arguments.
|
||||
*
|
||||
|
@ -153,13 +198,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 +230,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 +246,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 +295,9 @@ public class CompileKotlinOptions {
|
|||
}
|
||||
|
||||
// path
|
||||
if (isNotBlank(path_)) {
|
||||
if (path_ != null) {
|
||||
args.add("-d");
|
||||
args.add(path_);
|
||||
args.add(path_.getAbsolutePath());
|
||||
}
|
||||
|
||||
// plugin
|
||||
|
@ -298,8 +343,8 @@ public class CompileKotlinOptions {
|
|||
* @param paths one pr more paths
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions classpath(String... paths) {
|
||||
Collections.addAll(classpath_, paths);
|
||||
public CompileOptions classpath(String... paths) {
|
||||
classpath_.addAll(Arrays.stream(paths).map(File::new).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -308,21 +353,43 @@ public class CompileKotlinOptions {
|
|||
* <p>
|
||||
* The classpath can contain file and directory paths, ZIP, or JAR files.
|
||||
*
|
||||
* @param paths the list of paths
|
||||
* @param paths one or more path
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions classpath(Collection<String> paths) {
|
||||
public CompileOptions classpath(File... paths) {
|
||||
classpath_.addAll(List.of(paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for class files in the specified paths.
|
||||
* <p>
|
||||
* The classpath can contain file and directory paths, ZIP, or JAR files.
|
||||
*
|
||||
* @param paths the search paths
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileOptions classpath(Collection<File> paths) {
|
||||
classpath_.addAll(paths);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the class files classpath.
|
||||
*
|
||||
* @return the class files classpath
|
||||
*/
|
||||
public Collection<File> 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 +410,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 +441,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 +468,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 +480,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 +491,27 @@ public class CompileKotlinOptions {
|
|||
* @param jvmOptions one or more JVM option
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions jvmOptions(String... jvmOptions) {
|
||||
Collections.addAll(jvmOptions_, jvmOptions);
|
||||
public CompileOptions jvmOptions(String... jvmOptions) {
|
||||
jvmOptions_.addAll(List.of(jvmOptions));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass an option directly to JVM
|
||||
* Retrieves the Java Virtual Machine options.
|
||||
*
|
||||
* @param jvmOptions the list JVM options
|
||||
* @return the JVM options
|
||||
*/
|
||||
public Collection<String> jvmOptions() {
|
||||
return jvmOptions_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass an option directly to Java Virtual Machine
|
||||
*
|
||||
* @param jvmOptions the JVM options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions jvmOptions(Collection<String> jvmOptions) {
|
||||
public CompileOptions jvmOptions(Collection<String> jvmOptions) {
|
||||
jvmOptions_.addAll(jvmOptions);
|
||||
return this;
|
||||
}
|
||||
|
@ -428,7 +524,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 +536,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 +547,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 +580,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 +591,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 +602,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 +614,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 +625,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 +636,27 @@ public class CompileKotlinOptions {
|
|||
* @param annotations one or more annotation names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions optIn(String... annotations) {
|
||||
Collections.addAll(optIn_, annotations);
|
||||
public CompileOptions optIn(String... annotations) {
|
||||
optIn_.addAll(List.of(annotations));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the opt-in fully qualified names.
|
||||
*
|
||||
* @return the fully qualified names
|
||||
*/
|
||||
public Collection<String> 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
|
||||
* @param annotations the annotation names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions optIn(Collection<String> annotations) {
|
||||
public CompileOptions optIn(Collection<String> annotations) {
|
||||
optIn_.addAll(annotations);
|
||||
return this;
|
||||
}
|
||||
|
@ -551,18 +667,27 @@ public class CompileKotlinOptions {
|
|||
* @param options one or more compiler options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions options(String... options) {
|
||||
Collections.addAll(options_, options);
|
||||
public CompileOptions options(String... options) {
|
||||
options_.addAll(List.of(options));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves additional compiler options.
|
||||
*
|
||||
* @return the compiler options
|
||||
*/
|
||||
public Collection<String> options() {
|
||||
return options_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify additional compiler options.
|
||||
*
|
||||
* @param options list of compiler options
|
||||
* @param options the compiler options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions options(Collection<String> options) {
|
||||
public CompileOptions options(Collection<String> options) {
|
||||
options_.addAll(options);
|
||||
return this;
|
||||
}
|
||||
|
@ -575,8 +700,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 +713,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 +726,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 plugin ofoptions.
|
||||
*/
|
||||
public Collection<String> 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,20 +759,29 @@ public class CompileKotlinOptions {
|
|||
* @param classNames one or more class names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions scriptTemplates(String... classNames) {
|
||||
Collections.addAll(scriptTemplates_, classNames);
|
||||
public CompileOptions scriptTemplates(String... classNames) {
|
||||
scriptTemplates_.addAll(List.of(classNames));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the script templates.
|
||||
*
|
||||
* @return the script templates.
|
||||
*/
|
||||
public Collection<String> scriptTemplates() {
|
||||
return scriptTemplates_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Script definition template classes.
|
||||
* <p>
|
||||
* Use fully qualified class names.
|
||||
*
|
||||
* @param classNames the list class names
|
||||
* @param classNames the class names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions scriptTemplates(Collection<String> classNames) {
|
||||
public CompileOptions scriptTemplates(Collection<String> classNames) {
|
||||
scriptTemplates_.addAll(classNames);
|
||||
return this;
|
||||
}
|
||||
|
@ -649,7 +792,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 +803,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;
|
||||
}
|
|
@ -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,20 +22,18 @@ package rife.bld.extension;
|
|||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum CompileKotlinPlugin {
|
||||
ALL_OPEN("^allopen-compiler-plugin-.*$"),
|
||||
ASSIGNMENT("^assignment-compiler-plugin-.*$"),
|
||||
KOTLIN_IMPORTS_DUMPER("^kotlin-imports-dumper-compiler-plugin-.*$"),
|
||||
public enum CompilerPlugin {
|
||||
ALL_OPEN("^kotlin-allopen-compiler-plugin-.*$"),
|
||||
ASSIGNMENT("^kotlin-assignment-compiler-plugin-.*$"),
|
||||
KOTLIN_SERIALIZATION("^kotlin-serialization-compiler-plugin-.*$"),
|
||||
KOTLINX_SERIALIZATION("^kotlinx-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;
|
||||
}
|
||||
}
|
|
@ -18,14 +18,17 @@ package rife.bld.extension;
|
|||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.blueprints.BaseProjectBlueprint;
|
||||
import rife.bld.extension.kotlin.CompileOptions;
|
||||
import rife.bld.extension.kotlin.CompilerPlugin;
|
||||
import rife.tools.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
|
@ -47,7 +50,49 @@ class CompileKotlinOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testExecute() throws IOException {
|
||||
void testCollections() {
|
||||
var op = new CompileKotlinOperation()
|
||||
.fromProject(new Project())
|
||||
.compileMainClasspath("path1", "path2")
|
||||
.compileOptions(new CompileOptions().jdkRelease("17").verbose(true))
|
||||
.mainSourceDirectories("dir1", "dir2")
|
||||
.mainSourceDirectories(List.of(new File("dir3"), new File("dir4")))
|
||||
.mainSourceFiles("file1", "file2")
|
||||
.mainSourceFiles(List.of(new File("file3"), new File("file4")))
|
||||
.mainSourceFiles(new File("file5"), new File("file6"))
|
||||
.testSourceDirectories("tdir1", "tdir2")
|
||||
.testSourceDirectories(List.of(new File("tdir3"), new File("tdir4")))
|
||||
.testSourceFiles("tfile1", "tfile2")
|
||||
.testSourceFiles(List.of(new File("tfile3"), new File("tfile4")))
|
||||
.testSourceFiles(new File("tfile5"), new File("tfile6"))
|
||||
.plugins("plugin1", "plugin2")
|
||||
.plugins(CompilerPlugin.KOTLIN_SERIALIZATION, CompilerPlugin.ASSIGNMENT)
|
||||
.plugins(new File("lib/compile"), CompilerPlugin.LOMBOK, CompilerPlugin.POWER_ASSERT)
|
||||
.plugins(List.of("plugin3", "plugin4"))
|
||||
.plugins(Arrays.stream(Objects.requireNonNull(new File("lib/compile").listFiles())).toList(),
|
||||
CompilerPlugin.ALL_OPEN, CompilerPlugin.SAM_WITH_RECEIVER);
|
||||
|
||||
assertThat(op.compileMainClasspath()).as("compileMainClassPath")
|
||||
.containsAll(List.of("path1", "path2"));
|
||||
assertThat(op.compileOptions().hasRelease()).as("hasRelease").isTrue();
|
||||
assertThat(op.compileOptions().isVerbose()).as("isVerbose").isTrue();
|
||||
assertThat(op.mainSourceDirectories()).as("mainSourceDirectories").containsExactly(
|
||||
Path.of("src", "main", "kotlin").toFile().getAbsoluteFile(), new File("dir1"),
|
||||
new File("dir2"), new File("dir3"), new File("dir4"));
|
||||
assertThat(op.testSourceDirectories()).as("testSourceDirectories").containsOnly(
|
||||
Path.of("src", "test", "kotlin").toFile().getAbsoluteFile(), new File("tdir1"),
|
||||
new File("tdir2"), new File("tdir3"), new File("tdir4"));
|
||||
assertThat(op.mainSourceFiles()).as("mainSourceFiles").containsOnly(
|
||||
new File("file1"), new File("file2"), new File("file3"),
|
||||
new File("file4"), new File("file5"), new File("file6"));
|
||||
assertThat(op.testSourceFiles()).as("testSourceFiles").containsOnly(
|
||||
new File("tfile1"), new File("tfile2"), new File("tfile3"),
|
||||
new File("tfile4"), new File("tfile5"), new File("tfile6"));
|
||||
assertThat(op.plugins()).hasSize(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute() throws Exception {
|
||||
var tmpDir = Files.createTempDirectory("bld-kotlin").toFile();
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,123 +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.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
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() throws IOException {
|
||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt"));
|
||||
|
||||
assertThat(args).isNotEmpty();
|
||||
|
||||
var examples = new File("examples");
|
||||
var jsonConf = new File("config.json");
|
||||
var params = new DokkaOperation()
|
||||
.delayTemplateSubstitution(true)
|
||||
.failOnWarning(true)
|
||||
.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"))
|
||||
.json(jsonConf)
|
||||
.loggingLevel(LoggingLevel.DEBUG)
|
||||
.moduleName("name")
|
||||
.moduleVersion("1.0")
|
||||
.noSuppressObviousFunctions(true)
|
||||
.offlineMode(true)
|
||||
.outputDir(new File(examples, "build"))
|
||||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.pluginConfigurations("name", "{\"json\"}")
|
||||
.pluginConfigurations(Map.of("{\"name2\"}", "json2", "name3}", "{json3"))
|
||||
.pluginsClasspath("path1", "path2")
|
||||
.pluginsClasspath(List.of("path3", "path4"))
|
||||
.sourceSet(new SourceSet().classpath(
|
||||
List.of(
|
||||
new File("examples/foo.jar"),
|
||||
new File("examples/bar.jar")
|
||||
)))
|
||||
.suppressInheritedMembers(true)
|
||||
.executeConstructProcessCommandList();
|
||||
|
||||
for (var p : args) {
|
||||
var found = false;
|
||||
for (var a : params) {
|
||||
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(params).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, params.size()).forEach(i -> {
|
||||
if (params.get(i).contains(".jar;")) {
|
||||
var jars = params.get(i).split(";");
|
||||
Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).as(matches.get(i)).contains(jar));
|
||||
} else {
|
||||
assertThat(params.get(i)).as(params.get(i)).isEqualTo(matches.get(i));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,132 +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.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
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() throws IOException {
|
||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-sourceset-args.txt"));
|
||||
|
||||
assertThat(args).isNotEmpty();
|
||||
|
||||
var sourceSet = new SourceSet()
|
||||
.analysisPlatform(AnalysisPlatform.JVM)
|
||||
.apiVersion("1.0")
|
||||
.classpath("classpath1", "classpath2")
|
||||
.dependentSourceSets("moduleName", "sourceSetName")
|
||||
.displayName("name")
|
||||
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
||||
.externalDocumentationLinks("url1", "packageListUrl1")
|
||||
.externalDocumentationLinks("url2", "packageListUrl2")
|
||||
.includes("includes1", "includes2")
|
||||
.jdkVersion(18)
|
||||
.languageVersion("2.0")
|
||||
.noJdkLink(true)
|
||||
.noSkipEmptyPackages(true)
|
||||
.noStdlibLink(true)
|
||||
.perPackageOptions("options1", "options2")
|
||||
.reportUndocumented(true)
|
||||
.samples("samples1", "sample2")
|
||||
.skipDeprecated(true)
|
||||
.sourceSetName("setName")
|
||||
.src("src1", "src2")
|
||||
.srcLink("path1", "remote1", "#suffix1")
|
||||
.srcLink("path2", "remote2", "#suffix2")
|
||||
.suppressedFiles("sup1", "sup2");
|
||||
|
||||
var params = sourceSet.args();
|
||||
|
||||
for (var p : args) {
|
||||
var found = false;
|
||||
for (var a : params) {
|
||||
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(params).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
||||
|
||||
sourceSet.classpath(List.of("classpath1", "classpath2"));
|
||||
|
||||
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension;
|
||||
package rife.bld.extension.kotlin;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -23,61 +23,39 @@ import java.io.IOException;
|
|||
import java.nio.file.Files;
|
||||
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 CompileKotlinOptionsTest {
|
||||
@Test
|
||||
void argsCollectionTest() {
|
||||
var args = new CompileKotlinOptions()
|
||||
.advancedOptions(List.of("Xoption1", "Xoption2"))
|
||||
.argFile(List.of("arg1.txt", "arg2.txt"))
|
||||
.classpath(List.of("path1", "path2"))
|
||||
.jvmOptions(List.of("option1", "option2"))
|
||||
.noStdLib(false)
|
||||
.optIn(List.of("opt1", "opt2"))
|
||||
.options(List.of("-foo", "-bar"))
|
||||
.scriptTemplates(List.of("temp1", "temp2"))
|
||||
.args();
|
||||
var matches = List.of(
|
||||
"@arg1.txt", "@arg2.txt",
|
||||
"-classpath", "path1:path2",
|
||||
"-Joption1", "-Joption2",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
"-foo", "-bar",
|
||||
"-script-templates",
|
||||
"temp1,temp2",
|
||||
"-XXoption1", "-XXoption2");
|
||||
|
||||
for (var arg : args) {
|
||||
var found = false;
|
||||
for (var match : matches) {
|
||||
if (match.equals(arg)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertThat(found).as(arg).isTrue();
|
||||
}
|
||||
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
|
||||
void argsTest() {
|
||||
var options = new CompileKotlinOptions()
|
||||
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
|
||||
void testArgs() {
|
||||
var options = new CompileOptions()
|
||||
.apiVersion("11")
|
||||
.argFile("file.txt", "file2.txt")
|
||||
.classpath("path1", "path2")
|
||||
.argFile(new File("file.txt"), new File("file2.txt"))
|
||||
.classpath(new File("path1"), new File("path2"))
|
||||
.javaParameters(true)
|
||||
.jvmTarget("11")
|
||||
.includeRuntime(true)
|
||||
.jdkHome("path")
|
||||
.jdkHome(new File("path"))
|
||||
.jdkRelease("11")
|
||||
.kotlinHome("path")
|
||||
.kotlinHome(new File("path"))
|
||||
.languageVersion("1.0")
|
||||
.moduleName("module")
|
||||
.noJdk(true)
|
||||
|
@ -94,14 +72,14 @@ class CompileKotlinOptionsTest {
|
|||
|
||||
var matches = List.of(
|
||||
"-api-version", "11",
|
||||
"@file.txt", "@file2.txt",
|
||||
"-classpath", "path1" + File.pathSeparator + "path2",
|
||||
"@" + localPath("file.txt"), "@" + localPath("file2.txt"),
|
||||
"-classpath", localPath("path1", "path2"),
|
||||
"-java-parameters",
|
||||
"-jvm-target", "11",
|
||||
"-include-runtime",
|
||||
"-jdk-home", "path",
|
||||
"-jdk-home", localPath("path"),
|
||||
"-Xjdk-release=11",
|
||||
"-kotlin-home", "path",
|
||||
"-kotlin-home", localPath("path"),
|
||||
"-language-version", "1.0",
|
||||
"-module-name", "module",
|
||||
"-no-jdk",
|
||||
|
@ -111,7 +89,7 @@ class CompileKotlinOptionsTest {
|
|||
"-opt-in", "opt2",
|
||||
"-foo",
|
||||
"-bar",
|
||||
"-d", "path",
|
||||
"-d", localPath("path"),
|
||||
"-P", "plugin:id:name:value",
|
||||
"-progressive",
|
||||
"-script-templates", "name,name2",
|
||||
|
@ -123,18 +101,86 @@ class CompileKotlinOptionsTest {
|
|||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkAllParamsTest() throws IOException {
|
||||
void testArgsCollections() {
|
||||
var advanceOptions = List.of("Xoption1", "Xoption2");
|
||||
var argFile = List.of(new File("arg1.txt"), new File("arg2.txt"));
|
||||
var classpath = List.of(new File("path1"), new File("path2"));
|
||||
var jvmOptions = List.of("option1", "option2");
|
||||
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)
|
||||
.jvmOptions(jvmOptions)
|
||||
.noStdLib(false)
|
||||
.optIn(optIn)
|
||||
.options(options)
|
||||
.scriptTemplates(scriptTemplates);
|
||||
|
||||
plugin.forEach(it -> {
|
||||
var p = it.split(":");
|
||||
op.plugin(p[0], p[1], p[2]);
|
||||
});
|
||||
|
||||
assertThat(op.advancedOptions()).as("advancedOptions")
|
||||
.hasSize(advanceOptions.size()).containsAll(advanceOptions);
|
||||
assertThat(op.argFile()).as("argFile")
|
||||
.hasSize(argFile.size()).containsAll(argFile);
|
||||
assertThat(op.classpath()).as("classpath")
|
||||
.hasSize(classpath.size()).containsAll(classpath);
|
||||
assertThat(op.jvmOptions()).as("jvmOptions")
|
||||
.hasSize(jvmOptions.size()).containsAll(jvmOptions);
|
||||
assertThat(op.optIn()).as("optIn")
|
||||
.hasSize(optIn.size()).containsAll(optIn);
|
||||
assertThat(op.options()).as("options")
|
||||
.hasSize(options.size()).containsAll(options);
|
||||
assertThat(op.plugin()).as("plugin")
|
||||
.hasSize(plugin.size()).containsAll(plugin);
|
||||
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",
|
||||
"-XXoption1", "-XXoption2",
|
||||
"-P", "plugin:id:name:value",
|
||||
"-P", "plugin:id2:name2:value2");
|
||||
|
||||
var args = op.args();
|
||||
for (var arg : args) {
|
||||
var found = false;
|
||||
for (var match : matches) {
|
||||
if (match.equals(arg)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertThat(found).as(arg).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckAllParams() throws IOException {
|
||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "kotlinc-args.txt"));
|
||||
|
||||
assertThat(args).isNotEmpty();
|
||||
|
||||
var params = new CompileKotlinOptions()
|
||||
var params = new CompileOptions()
|
||||
.advancedOptions("Xoption")
|
||||
.argFile("file")
|
||||
.classpath("classpath")
|
||||
|
@ -152,7 +198,7 @@ class CompileKotlinOptionsTest {
|
|||
.noWarn(true)
|
||||
.optIn("annotation")
|
||||
.options("option")
|
||||
.path("path")
|
||||
.path(new File("path"))
|
||||
.plugin("id", "option", "value")
|
||||
.progressive(true)
|
||||
.scriptTemplates("template")
|
|
@ -1,16 +0,0 @@
|
|||
-delayTemplateSubstitution
|
||||
-failOnWarning
|
||||
-globalLinks
|
||||
-globalPackageOptions
|
||||
-globalSrcLink
|
||||
-includes
|
||||
-loggingLevel
|
||||
-moduleName
|
||||
-moduleVersion
|
||||
-noSuppressObviousFunctions
|
||||
-offlineMode
|
||||
-outputDir
|
||||
-pluginsClasspath
|
||||
-pluginsConfiguration
|
||||
-sourceSet
|
||||
-suppressInheritedMembers
|
|
@ -1,21 +0,0 @@
|
|||
-analysisPlatform
|
||||
-apiVersion
|
||||
-classpath
|
||||
-dependentSourceSets
|
||||
-displayName
|
||||
-documentedVisibilities
|
||||
-externalDocumentationLinks
|
||||
-includes
|
||||
-jdkVersion
|
||||
-languageVersion
|
||||
-noJdkLink
|
||||
-noSkipEmptyPackages
|
||||
-noStdlibLink
|
||||
-perPackageOptions
|
||||
-reportUndocumented
|
||||
-samples
|
||||
-skipDeprecated
|
||||
-sourceSetName
|
||||
-src
|
||||
-srcLink
|
||||
-suppressedFiles
|
Loading…
Add table
Add a link
Reference in a new issue