Compare commits

..

No commits in common. "6a6d6ce62aed38776d0713bbd16f34a0d1dcbea3" and "af8e211feb3991db8110715f6897357f1e42c559" have entirely different histories.

18 changed files with 277 additions and 348 deletions

View file

@ -1,6 +1,6 @@
name: bld-ci name: bld-ci
on: [ push, pull_request, workflow_dispatch ] on: [push, pull_request, workflow_dispatch]
jobs: jobs:
build-bld-project: build-bld-project:
@ -8,8 +8,7 @@ jobs:
strategy: strategy:
matrix: matrix:
java-version: [ 17, 21, 22 ] java-version: [17, 21, 22]
kotlin-version: [ 1.19.24, 2.0.0 ]
steps: steps:
- name: Checkout source repository - name: Checkout source repository
@ -23,15 +22,17 @@ jobs:
distribution: "zulu" distribution: "zulu"
java-version: ${{ matrix.java-version }} java-version: ${{ matrix.java-version }}
- name: Download dependencies [examples] - name: Download the examples dependencies
working-directory: examples working-directory: examples
run: ./bld download run: |
chmod +x bld
./bld download
- name: Run tests [examples] - name: Run examples tests
working-directory: examples working-directory: examples
run: ./bld compile test run: ./bld compile test
- name: Build documentation [examples] - name: Build examples documentation
working-directory: examples working-directory: examples
run: | run: |
./bld javadoc ./bld javadoc
@ -39,7 +40,10 @@ jobs:
./bld dokka-gfm ./bld dokka-gfm
./bld dokka-jekyll ./bld dokka-jekyll
- name: Download dependencies - name: Grant execute permission for bld
run: chmod +x bld
- name: Download the dependencies
run: ./bld download run: ./bld download
- name: Run tests - name: Run tests

View file

@ -2,12 +2,12 @@
<library name="bld"> <library name="bld">
<CLASSES> <CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1.jar!/" />
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT-sources.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1-sources.jar!/" />
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
</SOURCES> </SOURCES>
<excluded> <excluded>

View file

@ -9,7 +9,7 @@
], ],
"java.configuration.updateBuildConfiguration": "automatic", "java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [ "java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-2.0.0-SNAPSHOT.jar", "${HOME}/.bld/dist/bld-1.9.1.jar",
"lib/**/*.jar" "lib/**/*.jar"
] ]
} }

View file

@ -2,12 +2,12 @@
<library name="bld"> <library name="bld">
<CLASSES> <CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="file://$PROJECT_DIR$/lib/bld" /> <root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT-sources.jar!/" /> <root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1-sources.jar!/" />
</SOURCES> </SOURCES>
<excluded> <excluded>
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" /> <root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />

View file

@ -6,7 +6,6 @@
<pattern value="com.example.ExampleBuild" method="dokkaHtml" /> <pattern value="com.example.ExampleBuild" method="dokkaHtml" />
<pattern value="com.example.ExampleBuild" method="dokkaGfm" /> <pattern value="com.example.ExampleBuild" method="dokkaGfm" />
<pattern value="com.example.ExampleBuild" method="dokkaJekyll" /> <pattern value="com.example.ExampleBuild" method="dokkaJekyll" />
<pattern value="com.example.ExampleBuild" method="docs" />
</component> </component>
<component name="PDMPlugin"> <component name="PDMPlugin">
<option name="customRuleSets"> <option name="customRuleSets">

View file

@ -9,7 +9,7 @@
], ],
"java.configuration.updateBuildConfiguration": "automatic", "java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [ "java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-2.0.0-SNAPSHOT.jar", "${HOME}/.bld/dist/bld-1.9.1.jar",
"lib/**/*.jar" "lib/**/*.jar"
] ]
} }

View file

@ -20,8 +20,6 @@
## Build the documentation with [Dokka](https://github.com/Kotlin/dokka) ## Build the documentation with [Dokka](https://github.com/Kotlin/dokka)
```console ```console
./bld docs
./bld javadoc ./bld javadoc
./bld dokka-html ./bld dokka-html
./bld dokka-gfm ./bld dokka-gfm

Binary file not shown.

View file

@ -5,4 +5,4 @@ bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.0-SNAPSHOT
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.0-SNAPSHOT bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.0-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=
bld.version=2.0.0-SNAPSHOT bld.version=1.9.1

View file

@ -39,8 +39,8 @@ public class ExampleBuild extends Project {
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin)); .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin));
scope(test) scope(test)
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin)) .include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3))); .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)));
// Include the Kotlin source directory when creating or publishing sources Java Archives // Include the Kotlin source directory when creating or publishing sources Java Archives
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin")); jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
@ -48,34 +48,26 @@ public class ExampleBuild extends Project {
public static void main(String[] args) { public static void main(String[] args) {
// Enable detailed logging for the Kotlin extension // Enable detailed logging for the Kotlin extension
var level = Level.ALL; // var level = Level.ALL;
var logger = Logger.getLogger("rife.bld.extension"); // var logger = Logger.getLogger("rife.bld.extension");
var consoleHandler = new ConsoleHandler(); // var consoleHandler = new ConsoleHandler();
//
consoleHandler.setLevel(level); // consoleHandler.setLevel(level);
logger.addHandler(consoleHandler); // logger.addHandler(consoleHandler);
logger.setLevel(level); // logger.setLevel(level);
logger.setUseParentHandlers(false); // logger.setUseParentHandlers(false);
new ExampleBuild().start(args); new ExampleBuild().start(args);
} }
@BuildCommand(summary = "Compiles the Kotlin project") @BuildCommand(summary = "Compiles the Kotlin project")
@Override @Override
public void compile() throws Exception { public void compile() throws IOException {
new CompileKotlinOperation() new CompileKotlinOperation()
.fromProject(this) .fromProject(this)
.execute(); .execute();
} }
@BuildCommand(value = "docs", summary = "Generates all documentation")
public void docs() throws ExitStatusException, IOException, InterruptedException {
dokkaGfm();
dokkaHtml();
dokkaJekyll();
javadoc();
}
@BuildCommand(value = "dokka-gfm", summary = "Generates documentation in GitHub flavored markdown format") @BuildCommand(value = "dokka-gfm", summary = "Generates documentation in GitHub flavored markdown format")
public void dokkaGfm() throws ExitStatusException, IOException, InterruptedException { public void dokkaGfm() throws ExitStatusException, IOException, InterruptedException {
new DokkaOperation() new DokkaOperation()

Binary file not shown.

View file

@ -1,8 +1,8 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.downloadLocation= bld.downloadLocation=
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.1 bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.0
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.2 bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.0.1
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=
bld.version=2.0.0-SNAPSHOT bld.version=1.9.1

View file

@ -51,9 +51,9 @@ public class DokkaOperationBuild extends Project {
.include(dependency("org.jetbrains.dokka", "jekyll-plugin", dokka)) .include(dependency("org.jetbrains.dokka", "jekyll-plugin", dokka))
.include(dependency("com.uwyn.rife2", "bld", version(1, 9, 1))); .include(dependency("com.uwyn.rife2", "bld", version(1, 9, 1)));
scope(test) scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)))
.include(dependency("org.assertj", "assertj-core", version(3, 26, 3))); .include(dependency("org.assertj", "assertj-core", version(3, 26, 0)));
javadocOperation() javadocOperation()
.javadocOptions() .javadocOptions()
@ -95,7 +95,7 @@ public class DokkaOperationBuild extends Project {
} }
@BuildCommand(summary = "Runs PMD analysis") @BuildCommand(summary = "Runs PMD analysis")
public void pmd() throws Exception { public void pmd() {
new PmdOperation() new PmdOperation()
.fromProject(this) .fromProject(this)
.failOnViolation(true) .failOnViolation(true)

View file

@ -21,11 +21,9 @@ import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat; import rife.bld.extension.dokka.OutputFormat;
import rife.bld.extension.dokka.SourceSet; import rife.bld.extension.dokka.SourceSet;
import rife.bld.operations.AbstractProcessOperation; import rife.bld.operations.AbstractProcessOperation;
import rife.bld.operations.exceptions.ExitStatusException;
import rife.tools.StringUtils; import rife.tools.StringUtils;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
@ -58,7 +56,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>(); private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>();
private boolean delayTemplateSubstitution_; private boolean delayTemplateSubstitution_;
private boolean failOnWarning_; private boolean failOnWarning_;
private File json_; private File json;
private LoggingLevel loggingLevel_; private LoggingLevel loggingLevel_;
private String moduleName_; private String moduleName_;
private String moduleVersion_; private String moduleVersion_;
@ -79,13 +77,11 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Returns the JARs contained in a given directory. * Returns the list of JARs contained in a given directory.
* <p>
* Sources and Javadoc JARs are ignored.
* *
* @param directory the directory * @param directory the directory
* @param regex the regular expression to match * @param regex the regular expression to match
* @return the Java Archives * @return the list of JARs
*/ */
public static List<File> getJarList(File directory, String regex) { public static List<File> getJarList(File directory, String regex) {
var jars = new ArrayList<File>(); var jars = new ArrayList<File>();
@ -128,18 +124,6 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
return this; return this;
} }
@Override
public void execute() throws IOException, InterruptedException, ExitStatusException {
if (project_ == null) {
if (LOGGER.isLoggable(Level.SEVERE) && !silent()) {
LOGGER.severe("A project must be specified.");
}
throw new ExitStatusException(ExitStatusException.EXIT_FAILURE);
} else {
super.execute();
}
}
/** /**
* Part of the {@link #execute execute} operation, constructs the command list to use for building the process. * Part of the {@link #execute execute} operation, constructs the command list to use for building the process.
* *
@ -147,134 +131,136 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
*/ */
@Override @Override
protected List<String> executeConstructProcessCommandList() { protected List<String> executeConstructProcessCommandList() {
if (project_ == null) {
throw new IllegalArgumentException("A project must be specified.");
}
final List<String> args = new ArrayList<>(); final List<String> args = new ArrayList<>();
if (project_ != null) { // java
// java args.add(javaTool());
args.add(javaTool());
var jarList = getJarList(project_.libBldDirectory(), "^.*dokka-cli.*\\.jar$"); var cli = getJarList(project_.libBldDirectory(), "^.*dokka-cli.*\\.jar$");
if (!jarList.isEmpty()) {
// class path if (cli.size() != 1) {
args.add("-cp"); throw new RuntimeException("The dokka-cli JAR could not be found.");
args.add(jarList.stream().map(File::getAbsolutePath).collect(Collectors.joining(File.pathSeparator))); }
// -jar dokka-cli
args.add("-jar");
args.add(cli.get(0).getAbsolutePath());
// -pluginClasspath
if (!pluginsClasspath_.isEmpty()) {
args.add("-pluginsClasspath");
args.add(pluginsClasspath_.stream().map(File::getAbsolutePath).collect(Collectors.joining(SEMICOLON)));
}
// -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());
} }
// main class args.add("-outputDir");
args.add("org.jetbrains.dokka.MainKt"); args.add(outputDir_.getAbsolutePath());
}
// -pluginClasspath // -delayTemplateSubstitution
if (!pluginsClasspath_.isEmpty()) { if (delayTemplateSubstitution_) {
args.add("-pluginsClasspath"); args.add("-delayTemplateSubstitution");
args.add(pluginsClasspath_.stream().map(File::getAbsolutePath).collect(Collectors.joining(SEMICOLON))); }
}
// -sourceSet // -failOnWarning
var sourceSetArgs = sourceSet_.args(); if (failOnWarning_) {
if (sourceSetArgs.isEmpty()) { args.add("-failOnWarning");
throw new IllegalArgumentException("At least one sourceSet is required."); }
} else {
args.add("-sourceSet");
args.add(String.join(" ", sourceSet_.args()));
}
// -outputDir // -globalLinks_
if (outputDir_ != null) { if (!globalLinks_.isEmpty()) {
if (!outputDir_.exists() && !outputDir_.mkdirs()) { args.add("-globalLinks");
throw new RuntimeException("Could not create: " + outputDir_.getAbsolutePath()); var links = new ArrayList<String>();
} globalLinks_.forEach((k, v) ->
links.add(String.format("%s^%s", k, v)));
args.add(String.join("^^", links));
}
args.add("-outputDir"); // -globalPackageOptions
args.add(outputDir_.getAbsolutePath()); if (!globalPackageOptions_.isEmpty()) {
} args.add("-globalPackageOptions");
args.add(String.join(SEMICOLON, globalPackageOptions_));
}
// -delayTemplateSubstitution // -globalSrcLinks
if (delayTemplateSubstitution_) { if (!globalSrcLinks_.isEmpty()) {
args.add("-delayTemplateSubstitution"); args.add("-globalSrcLinks_");
} args.add(String.join(SEMICOLON, globalSrcLinks_));
}
// -failOnWarning // -includes
if (failOnWarning_) { if (!includes_.isEmpty()) {
args.add("-failOnWarning"); args.add("-includes");
} args.add(includes_.stream().map(File::getAbsolutePath).collect(Collectors.joining(SEMICOLON)));
}
// -globalLinks_ // -loggingLevel
if (!globalLinks_.isEmpty()) { if (loggingLevel_ != null) {
args.add("-globalLinks"); args.add("-loggingLevel");
var links = new ArrayList<String>(); args.add(loggingLevel_.name().toLowerCase());
globalLinks_.forEach((k, v) -> }
links.add(String.format("%s^%s", k, v)));
args.add(String.join("^^", links));
}
// -globalPackageOptions // -moduleName
if (!globalPackageOptions_.isEmpty()) { if (isNotBlank(moduleName_)) {
args.add("-globalPackageOptions"); args.add("-moduleName");
args.add(String.join(SEMICOLON, globalPackageOptions_)); args.add(moduleName_);
} }
// -globalSrcLinks // -moduleVersion
if (!globalSrcLinks_.isEmpty()) { if (isNotBlank(moduleVersion_)) {
args.add("-globalSrcLinks_"); args.add("-moduleVersion");
args.add(String.join(SEMICOLON, globalSrcLinks_)); args.add(moduleVersion_);
} }
// -includes // -noSuppressObviousFunctions
if (!includes_.isEmpty()) { if (noSuppressObviousFunctions_) {
args.add("-includes"); args.add("-noSuppressObviousFunctions");
args.add(includes_.stream().map(File::getAbsolutePath).collect(Collectors.joining(SEMICOLON))); }
}
// -loggingLevel // -offlineMode
if (loggingLevel_ != null) { if (offlineMode_) {
args.add("-loggingLevel"); args.add("-offlineMode");
args.add(loggingLevel_.name().toLowerCase()); }
}
// -moduleName // -pluginConfiguration
if (isNotBlank(moduleName_)) { if (!pluginsConfiguration_.isEmpty()) {
args.add("-moduleName"); args.add("-pluginsConfiguration");
args.add(moduleName_); var confs = new ArrayList<String>();
} pluginsConfiguration_.forEach((k, v) ->
confs.add(String.format("%s=%s", encodeJson(k), encodeJson(v))));
args.add(String.join("^^", confs));
}
// -moduleVersion // -suppressInheritedMembers
if (isNotBlank(moduleVersion_)) { if (suppressInheritedMembers_) {
args.add("-moduleVersion"); args.add("-suppressInheritedMembers");
args.add(moduleVersion_); }
}
// -noSuppressObviousFunctions // json
if (noSuppressObviousFunctions_) { if (json != null) {
args.add("-noSuppressObviousFunctions"); args.add(json.getAbsolutePath());
} }
// -offlineMode if (LOGGER.isLoggable(Level.FINE)) {
if (offlineMode_) { LOGGER.fine(String.join(" ", args));
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; return args;
@ -352,7 +338,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Sets the global package configurations. * Sets the global list of package configurations.
* <p> * <p>
* Using format: * Using format:
* <ul> * <ul>
@ -369,12 +355,12 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation globalPackageOptions(String... options) { public DokkaOperation globalPackageOptions(String... options) {
globalPackageOptions_.addAll(List.of(options)); Collections.addAll(globalPackageOptions_, options);
return this; return this;
} }
/** /**
* Retrieves the global package configurations. * Retrieves the global list of package configurations.
* *
* @return the package configurations * @return the package configurations
*/ */
@ -383,7 +369,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Sets the global package configurations. * Sets the global list of package configurations.
* <p> * <p>
* Using format: * Using format:
* <ul> * <ul>
@ -396,7 +382,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* <li>...</li> * <li>...</li>
* </ul> * </ul>
* *
* @param options the package configurations * @param options the list of package configurations
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation globalPackageOptions(Collection<String> options) { public DokkaOperation globalPackageOptions(Collection<String> options) {
@ -411,7 +397,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation globalSrcLink(String... links) { public DokkaOperation globalSrcLink(String... links) {
globalSrcLinks_.addAll(List.of(links)); Collections.addAll(globalSrcLinks_, links);
return this; return this;
} }
@ -446,7 +432,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation includes(File... files) { public DokkaOperation includes(File... files) {
includes_.addAll(List.of(files)); Collections.addAll(includes_, files);
return this; return this;
} }
@ -461,7 +447,9 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation includes(String... files) { public DokkaOperation includes(String... files) {
includes_.addAll(Arrays.stream(files).map(File::new).toList()); Collections.addAll(includes_, Arrays.stream(files)
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -481,7 +469,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* <p> * <p>
* This can be configured on per-package basis. * This can be configured on per-package basis.
* *
* @param files the markdown files * @param files the list of files
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation includes(Collection<File> files) { public DokkaOperation includes(Collection<File> files) {
@ -495,7 +483,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @param configuration the configuration file path * @param configuration the configuration file path
*/ */
public DokkaOperation json(File configuration) { public DokkaOperation json(File configuration) {
json_ = configuration; json = configuration;
return this; return this;
} }
@ -660,24 +648,26 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Sets the jars for Dokka plugins and their dependencies. * Sets the list of jars with Dokka plugins and their dependencies.
* *
* @param jars one or more jars * @param jars one or more jars
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation pluginsClasspath(File... jars) { public DokkaOperation pluginsClasspath(File... jars) {
pluginsClasspath_.addAll(List.of(jars)); Collections.addAll(pluginsClasspath_, jars);
return this; return this;
} }
/** /**
* Sets the jars for Dokka plugins and their dependencies. * Sets the list of jars with Dokka plugins and their dependencies.
* *
* @param jars one or more jars * @param jars one or more jars
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation pluginsClasspath(String... jars) { public DokkaOperation pluginsClasspath(String... jars) {
pluginsClasspath_.addAll(Arrays.stream(jars).map(File::new).toList()); Collections.addAll(pluginsClasspath_, Arrays.stream(jars)
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -691,9 +681,9 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Sets the jars for Dokka plugins and their dependencies. * Sets the list of jars with Dokka plugins and their dependencies.
* *
* @param jars the jars * @param jars the list of jars
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation pluginsClasspath(Collection<File> jars) { public DokkaOperation pluginsClasspath(Collection<File> jars) {

View file

@ -164,21 +164,25 @@ public class SourceSet {
// -noJdkLink // -noJdkLink
if (noJdkLink_) { if (noJdkLink_) {
args.add("-noJdkLink"); args.add("-noJdkLink");
args.add(String.valueOf(noJdkLink_));
} }
// -noSkipEmptyPackages // -noSkipEmptyPackages
if (noSkipEmptyPackages_) { if (noSkipEmptyPackages_) {
args.add("-noSkipEmptyPackages"); args.add("-noSkipEmptyPackages");
args.add(String.valueOf(noSkipEmptyPackages_));
} }
// -noStdlibLink // -noStdlibLink
if (noStdlibLink_) { if (noStdlibLink_) {
args.add("-noStdlibLink"); args.add("-noStdlibLink");
args.add(String.valueOf(noStdlibLink_));
} }
// -reportUndocumented // -reportUndocumented
if (reportUndocumented_) { if (reportUndocumented_) {
args.add("-reportUndocumented"); args.add("-reportUndocumented");
args.add(String.valueOf(reportUndocumented_));
} }
// -perPackageOptions // -perPackageOptions
@ -196,6 +200,7 @@ public class SourceSet {
// -skipDeprecated // -skipDeprecated
if (skipDeprecated_) { if (skipDeprecated_) {
args.add("-skipDeprecated"); args.add("-skipDeprecated");
args.add(String.valueOf(skipDeprecated_));
} }
// -src // -src
@ -238,7 +243,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet classpath(File... files) { public SourceSet classpath(File... files) {
classpath_.addAll(List.of(files)); Collections.addAll(classpath_, files);
return this; return this;
} }
@ -253,7 +258,9 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet classpath(String... files) { public SourceSet classpath(String... files) {
classpath_.addAll(Arrays.stream(files).map(File::new).toList()); Collections.addAll(classpath_, Arrays.stream(files)
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -264,7 +271,7 @@ public class SourceSet {
* <p> * <p>
* This option accepts both {@code .jar} and {@code .klib} files. * This option accepts both {@code .jar} and {@code .klib} files.
* *
* @param files the collection of files * @param files the list of files
* @return this operation instance * @return this operation instance
*/ */
public SourceSet classpath(Collection<File> files) { public SourceSet classpath(Collection<File> files) {
@ -342,7 +349,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) { public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) {
documentedVisibilities_.addAll(List.of(visibilities)); documentedVisibilities_.addAll(Arrays.asList(visibilities));
return this; return this;
} }
@ -395,7 +402,7 @@ public class SourceSet {
/** /**
* Sets the Markdown files that contain module and package documentation. * Sets the Markdown files that contain module and package documentation.
* <p> * <p>
* The Markdown files that contain module and package documentation. * A list of Markdown files that contain module and package documentation.
* <p> * <p>
* The contents of the specified files are parsed and embedded into documentation as module and package * The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions. * descriptions.
@ -404,14 +411,14 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet includes(File... files) { public SourceSet includes(File... files) {
includes_.addAll(List.of(files)); Collections.addAll(includes_, files);
return this; return this;
} }
/** /**
* Sets the Markdown files that contain module and package documentation. * Sets the Markdown files that contain module and package documentation.
* <p> * <p>
* The Markdown files that contain module and package documentation. * A list of Markdown files that contain module and package documentation.
* <p> * <p>
* The contents of the specified files are parsed and embedded into documentation as module and package * The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions. * descriptions.
@ -420,7 +427,9 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet includes(String... files) { public SourceSet includes(String... files) {
includes_.addAll(Arrays.stream(files).map(File::new).toList()); Collections.addAll(includes_, Arrays.stream(files)
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -436,12 +445,12 @@ public class SourceSet {
/** /**
* Sets the Markdown files that contain module and package documentation. * Sets the Markdown files that contain module and package documentation.
* <p> * <p>
* The Markdown files that contain module and package documentation. * A list of Markdown files that contain module and package documentation.
* <p> * <p>
* The contents of the specified files are parsed and embedded into documentation as module and package * The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions. * descriptions.
* *
* @param files the collection of files * @param files the list of files
* @return this operation instance * @return this operation instance
*/ */
public SourceSet includes(Collection<File> files) { public SourceSet includes(Collection<File> files) {
@ -550,7 +559,7 @@ public class SourceSet {
} }
/** /**
* Set the package source set configuration. * Set the list of package source set configuration.
* <p> * <p>
* A set of parameters specific to matched packages within this source set. * A set of parameters specific to matched packages within this source set.
* <p> * <p>
@ -565,7 +574,7 @@ public class SourceSet {
* <li>...</li> * <li>...</li>
* </ul> * </ul>
* *
* @param perPackageOptions the per package options * @param perPackageOptions the list of per package options
* @return this operation instance * @return this operation instance
*/ */
public SourceSet perPackageOptions(Collection<String> perPackageOptions) { public SourceSet perPackageOptions(Collection<String> perPackageOptions) {
@ -574,7 +583,7 @@ public class SourceSet {
} }
/** /**
* Retrieves the package source set configuration. * Retrieves the list of package source set configuration.
* *
* @return the package source set configuration * @return the package source set configuration
*/ */
@ -583,7 +592,7 @@ public class SourceSet {
} }
/** /**
* Set the package source set configuration. * Set the list of package source set configuration.
* <p> * <p>
* A set of parameters specific to matched packages within this source set. * A set of parameters specific to matched packages within this source set.
* <p> * <p>
@ -598,11 +607,11 @@ public class SourceSet {
* <li>...</li> * <li>...</li>
* </ul> * </ul>
* *
* @param perPackageOptions the per package options * @param perPackageOptions the list of per package options
* @return this operation instance * @return this operation instance
*/ */
public SourceSet perPackageOptions(String... perPackageOptions) { public SourceSet perPackageOptions(String... perPackageOptions) {
perPackageOptions_.addAll(List.of(perPackageOptions)); Collections.addAll(perPackageOptions_, perPackageOptions);
return this; return this;
} }
@ -625,12 +634,12 @@ public class SourceSet {
} }
/** /**
* Set the directories or files that contain sample functions. * Set the list of directories or files that contain sample functions.
* <p> * <p>
* The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc
* tag. * tag.
* *
* @param samples the samples * @param samples the list of samples
* @return this operation instance * @return this operation instance
*/ */
public SourceSet samples(Collection<File> samples) { public SourceSet samples(Collection<File> samples) {
@ -639,7 +648,7 @@ public class SourceSet {
} }
/** /**
* Retrieves the directories or files that contain sample functions. * Retrieves the list of directories or files that contain sample functions.
* *
* @return the directories or files * @return the directories or files
*/ */
@ -648,30 +657,32 @@ public class SourceSet {
} }
/** /**
* Set the directories or files that contain sample functions. * Set the list of directories or files that contain sample functions.
* <p> * <p>
* The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc
* tag. * tag.
* *
* @param samples nne or more samples * @param samples nne or more samples
* @return this operation instance * @return this operation instance
*/ */
public SourceSet samples(File... samples) { public SourceSet samples(File... samples) {
samples_.addAll(List.of(samples)); Collections.addAll(samples_, samples);
return this; return this;
} }
/** /**
* Set the directories or files that contain sample functions. * Set the list of directories or files that contain sample functions.
* <p> * <p>
* The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc
* tag. * tag.
* *
* @param samples nne or more samples * @param samples nne or more samples
* @return this operation instance * @return this operation instance
*/ */
public SourceSet samples(String... samples) { public SourceSet samples(String... samples) {
samples_.addAll(Arrays.stream(samples).map(File::new).toList()); Collections.addAll(samples_, Arrays.stream(samples)
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -707,7 +718,7 @@ public class SourceSet {
* The source code roots to be analyzed and documented. Acceptable inputs are directories and individual * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual
* {@code .kt} / {@code .java} files. * {@code .kt} / {@code .java} files.
* *
* @param src the source code roots * @param src the list of source code roots
* @return this operation instance * @return this operation instance
*/ */
public SourceSet src(Collection<File> src) { public SourceSet src(Collection<File> src) {
@ -725,7 +736,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet src(File... src) { public SourceSet src(File... src) {
src_.addAll(List.of(src)); Collections.addAll(src_, src);
return this; return this;
} }
@ -739,7 +750,9 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet src(String... src) { public SourceSet src(String... src) {
src_.addAll(Arrays.stream(src).map(File::new).toList()); Collections.addAll(src_, Arrays.stream(src)
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -792,7 +805,7 @@ public class SourceSet {
* <p> * <p>
* The files to be suppressed when generating documentation. * The files to be suppressed when generating documentation.
* *
* @param suppressedFiles the suppressed files * @param suppressedFiles the list of suppressed files
* @return this operation instance * @return this operation instance
*/ */
public SourceSet suppressedFiles(Collection<File> suppressedFiles) { public SourceSet suppressedFiles(Collection<File> suppressedFiles) {
@ -819,7 +832,9 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet suppressedFiles(String... suppressedFiles) { public SourceSet suppressedFiles(String... suppressedFiles) {
suppressedFiles_.addAll(Arrays.stream(suppressedFiles).map(File::new).toList()); Collections.addAll(suppressedFiles_, Arrays.stream(suppressedFiles)
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -832,7 +847,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet suppressedFiles(File... suppressedFiles) { public SourceSet suppressedFiles(File... suppressedFiles) {
suppressedFiles_.addAll(List.of(suppressedFiles)); suppressedFiles_.addAll(Arrays.asList(suppressedFiles));
return this; return this;
} }
} }

View file

@ -16,13 +16,11 @@
package rife.bld.extension; package rife.bld.extension;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import rife.bld.blueprints.BaseProjectBlueprint; import rife.bld.blueprints.BaseProjectBlueprint;
import rife.bld.extension.dokka.LoggingLevel; import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat; import rife.bld.extension.dokka.OutputFormat;
import rife.bld.extension.dokka.SourceSet; import rife.bld.extension.dokka.SourceSet;
import rife.bld.operations.exceptions.ExitStatusException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -31,74 +29,46 @@ import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode;
class DokkaOperationTest { class DokkaOperationTest {
private static final File EXAMPLES = new File("examples");
private static final String FILE_1 = "file1";
private static final String FILE_2 = "file2";
private static final String FILE_3 = "file3";
private static final String FILE_4 = "file4";
private static final String OPTION_1 = "option1";
private static final String OPTION_2 = "option2";
private static final String OPTION_3 = "option3";
private static final String OPTION_4 = "option4";
private static final String PATH_1 = "path1";
private static final String PATH_2 = "path2";
private static final String PATH_3 = "path3";
private static final String PATH_4 = "path4";
@BeforeAll
static void beforeAll() {
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);
}
@Test @Test
@SuppressWarnings({"PMD.AvoidDuplicateLiterals"})
void executeConstructProcessCommandListTest() throws IOException { void executeConstructProcessCommandListTest() throws IOException {
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt")); var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-args.txt"));
assertThat(args).isNotEmpty(); assertThat(args).isNotEmpty();
var examples = new File("examples");
var jsonConf = new File("config.json"); var jsonConf = new File("config.json");
var op = new DokkaOperation() var op = new DokkaOperation()
.delayTemplateSubstitution(true) .delayTemplateSubstitution(true)
.failOnWarning(true) .failOnWarning(true)
.fromProject(new BaseProjectBlueprint(EXAMPLES, "com.example", "Example")) .fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
.globalLinks("s", "gLink1") .globalLinks("s", "link")
.globalLinks(Map.of("s2", "gLink2")) .globalLinks(Map.of("s2", "link2"))
.globalPackageOptions(OPTION_1, OPTION_2) .globalPackageOptions("option1", "option2")
.globalPackageOptions(List.of(OPTION_3, OPTION_4)) .globalPackageOptions(List.of("option3", "option4"))
.globalSrcLink("link1", "link2") .globalSrcLink("link1", "link2")
.globalSrcLink(List.of("link3", "link4")) .globalSrcLink(List.of("link3", "link4"))
.includes(new File(FILE_1)) .includes(new File("file1"))
.includes(FILE_2) .includes("file2")
.includes(List.of(new File(FILE_3), new File(FILE_4))) .includes(List.of(new File("file3"), new File("file4")))
.json(jsonConf) .json(jsonConf)
.loggingLevel(LoggingLevel.DEBUG) .loggingLevel(LoggingLevel.DEBUG)
.moduleName("name") .moduleName("name")
.moduleVersion("1.0") .moduleVersion("1.0")
.noSuppressObviousFunctions(true) .noSuppressObviousFunctions(true)
.offlineMode(true) .offlineMode(true)
.outputDir(new File(EXAMPLES, "build")) .outputDir(new File(examples, "build"))
.outputFormat(OutputFormat.JAVADOC) .outputFormat(OutputFormat.JAVADOC)
.pluginConfigurations("name", "{\"json\"}") .pluginConfigurations("name", "{\"json\"}")
.pluginConfigurations(Map.of("{\"name2\"}", "json2", "name3}", "{json3")) .pluginConfigurations(Map.of("{\"name2\"}", "json2", "name3}", "{json3"))
.pluginsClasspath(new File(PATH_1)) .pluginsClasspath(new File("path1"))
.pluginsClasspath(PATH_2) .pluginsClasspath("path2")
.pluginsClasspath(List.of(new File(PATH_3), new File(PATH_4))) .pluginsClasspath(List.of(new File("path3"), new File("path4")))
.sourceSet(new SourceSet().classpath( .sourceSet(new SourceSet().classpath(
List.of( List.of(
new File("examples/foo.jar"), new File("examples/foo.jar"),
@ -125,26 +95,25 @@ class DokkaOperationTest {
assertThat(found).as(p + " not found.").isTrue(); assertThat(found).as(p + " not found.").isTrue();
} }
var path = EXAMPLES.getAbsolutePath(); var path = examples.getAbsolutePath();
var dokkaJar = "1.9.20.jar"; var dokkaJar = "1.9.20.jar";
var matches = List.of("java", var matches = List.of("java",
"-cp", path + "/lib/bld/dokka-cli-" + dokkaJar, "-jar", path + "/lib/bld/dokka-cli-" + dokkaJar,
"org.jetbrains.dokka.MainKt",
"-pluginsClasspath", path + "/lib/bld/dokka-base-" + dokkaJar + ';' + "-pluginsClasspath", path + "/lib/bld/dokka-base-" + dokkaJar + ';' +
path + "/lib/bld/analysis-kotlin-descriptors-" + dokkaJar + ';' + path + "/lib/bld/analysis-kotlin-descriptors-" + dokkaJar + ';' +
path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' + path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' +
path + "/lib/bld/korte-jvm-4.0.10.jar;" + path + "/lib/bld/korte-jvm-4.0.10.jar;" +
path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ';' + path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ';' +
TestUtils.localPath(PATH_1, PATH_2, PATH_3, PATH_4), TestUtil.localPath("path1", "path2", "path3", "path4"),
"-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;" "-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;"
+ path + "/bar.jar", + path + "/bar.jar",
"-outputDir", path + "/build", "-outputDir", path + "/build",
"-delayTemplateSubstitution", "-delayTemplateSubstitution",
"-failOnWarning", "-failOnWarning",
"-globalLinks", "s^gLink1^^s2^gLink2", "-globalLinks", "s^link^^s2^link2",
"-globalPackageOptions", OPTION_1 + ';' + OPTION_2 + ';' + OPTION_3 + ';' + OPTION_4, "-globalPackageOptions", "option1;option2;option3;option4",
"-globalSrcLinks_", "link1;link2;link3;link4", "-globalSrcLinks_", "link1;link2;link3;link4",
"-includes", TestUtils.localPath(FILE_1, FILE_2, FILE_3, FILE_4), "-includes", TestUtil.localPath("file1", "file2", "file3", "file4"),
"-loggingLevel", "debug", "-loggingLevel", "debug",
"-moduleName", "name", "-moduleName", "name",
"-moduleVersion", "1.0", "-moduleVersion", "1.0",
@ -165,20 +134,4 @@ class DokkaOperationTest {
} }
}); });
} }
@Test
void executeNoProjectTest() {
var op = new DokkaOperation();
assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class);
}
@Test
void executeTest() {
var op = new DokkaOperation()
.fromProject(
new BaseProjectBlueprint(EXAMPLES, "com.example", "examples"))
.outputDir("build/javadoc")
.outputFormat(OutputFormat.JAVADOC);
assertThatCode(op::execute).doesNotThrowAnyException();
}
} }

View file

@ -23,8 +23,8 @@ import java.util.stream.Collectors;
import static rife.bld.extension.DokkaOperation.SEMICOLON; import static rife.bld.extension.DokkaOperation.SEMICOLON;
@SuppressWarnings("PMD.TestClassWithoutTestCases") @SuppressWarnings("PMD.TestClassWithoutTestCases")
public final class TestUtils { public final class TestUtil {
private TestUtils() { private TestUtil() {
// no-op // no-op
} }
@ -35,6 +35,6 @@ public final class TestUtils {
* @return the local path * @return the local path
*/ */
public static String localPath(String... fileNames) { public static String localPath(String... fileNames) {
return Arrays.stream(fileNames).map(f -> new File(f).getAbsolutePath()).collect(Collectors.joining(SEMICOLON)); return Arrays.stream(fileNames).map(it -> new File(it).getAbsolutePath()).collect(Collectors.joining(SEMICOLON));
} }
} }

View file

@ -27,52 +27,36 @@ import java.util.Map;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static rife.bld.extension.TestUtils.localPath; import static rife.bld.extension.TestUtil.localPath;
class SourceSetTest { class SourceSetTest {
private static final String CLASSPATH_1 = "classpath1"; public static final String SAMPLES_1 = "samples1";
private static final String CLASSPATH_2 = "classpath2"; public static final String SAMPLES_2 = "samples2";
private static final String INCLUDES_1 = "includes1"; public static final String SUP_1 = "sup1";
private static final String INCLUDES_2 = "includes2"; public static final String SUP_2 = "sup2";
private static final String INCLUDES_3 = "includes3";
private static final String INCLUDES_4 = "includes4";
private static final String OPTION_1 = "option1";
private static final String OPTION_2 = "option2";
private static final String PATH_1 = "path1";
private static final String PATH_2 = "path2";
private static final String SAMPLES_1 = "samples1";
private static final String SAMPLES_2 = "samples2";
private static final String SAMPLES_3 = "samples3";
private static final String SRC_1 = "src1";
private static final String SRC_2 = "src2";
private static final String SRC_3 = "src3";
private static final String SRC_4 = "src4";
private static final String SUP_1 = "sup1";
private static final String SUP_2 = "sup2";
private static final String SUP_3 = "sup3";
@Test @Test
void sourceSetCollectionsTest() { void sourceSetCollectionsTest() {
var args = new SourceSet() var args = new SourceSet()
.classpath(List.of(new File(PATH_1), new File(PATH_2))) .classpath(List.of(new File("path1"), new File("path2")))
.dependentSourceSets(Map.of("set1", "set2", "set3", "set4")) .dependentSourceSets(Map.of("set1", "set2", "set3", "set4"))
.externalDocumentationLinks(Map.of("link1", "link2", "link3", "link4")) .externalDocumentationLinks(Map.of("link1", "link2", "link3", "link4"))
.perPackageOptions(List.of(OPTION_1, OPTION_2)) .perPackageOptions(List.of("option1", "option2"))
.samples(List.of(new File(SAMPLES_1))) .samples(List.of(new File(SAMPLES_1)))
.samples(new File(SAMPLES_2)) .samples(new File(SAMPLES_2))
.samples(SAMPLES_3) .samples("samples3")
.suppressedFiles(List.of(new File(SUP_1))) .suppressedFiles(List.of(new File(SUP_1)))
.suppressedFiles(new File(SUP_2)) .suppressedFiles(new File(SUP_2))
.suppressedFiles(SUP_3) .suppressedFiles("sup3")
.args(); .args();
var matches = List.of( var matches = List.of(
"-classpath", localPath(PATH_1, PATH_2), "-classpath", localPath("path1", "path2"),
"-dependentSourceSets", "set1/set2;set3/set4", "-dependentSourceSets", "set1/set2;set3/set4",
"-externalDocumentationLinks", "link3^link4^^link1^link2", "-externalDocumentationLinks", "link3^link4^^link1^link2",
"-perPackageOptions", OPTION_1 + ';' + OPTION_2, "-perPackageOptions", "option1;option2",
"-samples", localPath(SAMPLES_1, SAMPLES_2, SAMPLES_3), "-samples", localPath(SAMPLES_1, SAMPLES_2, "samples3"),
"-suppressedFiles", localPath(SUP_1, SUP_2, SUP_3) "-suppressedFiles", localPath(SUP_1, SUP_2, "sup3")
); );
assertThat(args).hasSize(matches.size()); assertThat(args).hasSize(matches.size());
@ -81,12 +65,7 @@ class SourceSetTest {
} }
@Test @Test
void sourceSetIntVersionsTest() { @SuppressWarnings("PMD.AvoidDuplicateLiterals")
var args = new SourceSet().apiVersion(1).languageVersion(2);
assertThat(args.args()).containsExactly("-apiVersion", "1", "-languageVersion", "2");
}
@Test
void sourceSetTest() throws IOException { void sourceSetTest() throws IOException {
var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-sourceset-args.txt")); var args = Files.readAllLines(Paths.get("src", "test", "resources", "dokka-sourceset-args.txt"));
@ -95,32 +74,32 @@ class SourceSetTest {
var sourceSet = new SourceSet() var sourceSet = new SourceSet()
.analysisPlatform(AnalysisPlatform.JVM) .analysisPlatform(AnalysisPlatform.JVM)
.apiVersion("1.0") .apiVersion("1.0")
.classpath(CLASSPATH_1) .classpath("classpath1")
.classpath(new File(CLASSPATH_2)) .classpath(new File("classpath2"))
.dependentSourceSets("moduleName", "sourceSetName") .dependentSourceSets("moduleName", "sourceSetName")
.dependentSourceSets("moduleName2", "sourceSetName2") .dependentSourceSets("moduleName2", "sourceSetName2")
.displayName("name") .displayName("name")
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE) .documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
.externalDocumentationLinks("url1", "packageListUrl1") .externalDocumentationLinks("url1", "packageListUrl1")
.externalDocumentationLinks("url2", "packageListUrl2") .externalDocumentationLinks("url2", "packageListUrl2")
.includes(INCLUDES_1, INCLUDES_2) .includes("includes1", "includes2")
.includes(new File(INCLUDES_3)) .includes(new File("includes3"))
.includes(List.of(new File(INCLUDES_4))) .includes(List.of(new File("includes4")))
.jdkVersion(18) .jdkVersion(18)
.languageVersion("2.0") .languageVersion("2.0")
.noJdkLink(true) .noJdkLink(true)
.noSkipEmptyPackages(true) .noSkipEmptyPackages(true)
.noStdlibLink(true) .noStdlibLink(true)
.perPackageOptions(OPTION_1, OPTION_2) .perPackageOptions("options1", "options2")
.reportUndocumented(true) .reportUndocumented(true)
.samples(SAMPLES_1, SAMPLES_2) .samples(SAMPLES_1, SAMPLES_2)
.skipDeprecated(true) .skipDeprecated(true)
.sourceSetName("setName") .sourceSetName("setName")
.src(SRC_1, SRC_2) .src("src1", "src2")
.src(new File(SRC_3)) .src(new File("src3"))
.src(List.of(new File(SRC_4))) .src(List.of(new File("src4")))
.srcLink(PATH_1, "remote1", "#suffix1") .srcLink("path1", "remote1", "#suffix1")
.srcLink(new File(PATH_2), "remote2", "#suffix2") .srcLink(new File("path2"), "remote2", "#suffix2")
.suppressedFiles(SUP_1, SUP_2); .suppressedFiles(SUP_1, SUP_2);
assertThat(sourceSet.classpath()).as("classpath").hasSize(2); assertThat(sourceSet.classpath()).as("classpath").hasSize(2);
@ -150,32 +129,31 @@ class SourceSetTest {
var matches = List.of( var matches = List.of(
"-analysisPlatform", "jvm", "-analysisPlatform", "jvm",
"-apiVersion", "1.0", "-apiVersion", "1.0",
"-classpath", localPath(CLASSPATH_1, CLASSPATH_2), "-classpath", localPath("classpath1", "classpath2"),
"-dependentSourceSets", "moduleName/sourceSetName;moduleName2/sourceSetName2", "-dependentSourceSets", "moduleName/sourceSetName;moduleName2/sourceSetName2",
"-displayName", "name", "-displayName", "name",
"-documentedVisibilities", "package;private", "-documentedVisibilities", "package;private",
"-externalDocumentationLinks", "url1^packageListUrl1^^url2^packageListUrl2", "-externalDocumentationLinks", "url1^packageListUrl1^^url2^packageListUrl2",
"-jdkVersion", "18", "-jdkVersion", "18",
"-includes", localPath(INCLUDES_1, INCLUDES_2, INCLUDES_3, INCLUDES_4), "-includes", localPath("includes1", "includes2", "includes3", "includes4"),
"-languageVersion", "2.0", "-languageVersion", "2.0",
"-noJdkLink", "-noJdkLink", "true",
"-noSkipEmptyPackages", "-noSkipEmptyPackages", "true",
"-noStdlibLink", "-noStdlibLink", "true",
"-reportUndocumented", "-reportUndocumented", "true",
"-perPackageOptions", OPTION_1 + ';' + OPTION_2, "-perPackageOptions", "options1;options2",
"-samples", localPath(SAMPLES_1, SAMPLES_2), "-samples", localPath(SAMPLES_1, SAMPLES_2),
"-skipDeprecated", "-skipDeprecated", "true",
"-src", localPath(SRC_1, SRC_2, SRC_3, SRC_4), "-src", localPath("src1", "src2", "src3", "src4"),
"-srcLink", localPath(PATH_2) + "=remote2#suffix2;path1=remote1#suffix1", "-srcLink", localPath("path2") + "=remote2#suffix2;path1=remote1#suffix1",
"-sourceSetName", "setName", "-sourceSetName", "setName",
"-suppressedFiles", localPath(SUP_1, SUP_2)); "-suppressedFiles", localPath(SUP_1, SUP_2));
assertThat(params).hasSize(matches.size()); assertThat(params).hasSize(matches.size());
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i))); IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
sourceSet.classpath(List.of(new File(CLASSPATH_1), new File(CLASSPATH_2))); sourceSet.classpath(List.of(new File("classpath1"), new File("classpath2")));
IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i))); IntStream.range(0, params.size()).forEach(i -> assertThat(params.get(i)).isEqualTo(matches.get(i)));
} }