diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index d897fcc..ceddff2 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -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 diff --git a/README.md b/README.md index c7801b6..8c1d080 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/examples/README.md b/examples/README.md index 1dbc9fb..e5a785f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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 -``` diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 8c08ccc..edf4d9d 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -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 diff --git a/examples/src/bld/java/com/example/ExampleBuild.java b/examples/src/bld/java/com/example/ExampleBuild.java index 5cccf1a..51fc4c5 100644 --- a/examples/src/bld/java/com/example/ExampleBuild.java +++ b/examples/src/bld/java/com/example/ExampleBuild.java @@ -3,9 +3,6 @@ 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; @@ -48,14 +45,14 @@ 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(); - - // consoleHandler.setLevel(level); - // logger.addHandler(consoleHandler); - // logger.setLevel(level); - // logger.setUseParentHandlers(false); +// 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); new ExampleBuild().start(args); } @@ -72,50 +69,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(); - } } diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index b50fe85..aea9055 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -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.0 +bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.0.1 +bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_RELEASES bld.sourceDirectories= bld.version=1.9.1 diff --git a/scripts/checkcliargs.sh b/scripts/checkcliargs.sh index aa2c55e..7855fdc 100755 --- a/scripts/checkcliargs.sh +++ b/scripts/checkcliargs.sh @@ -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 diff --git a/scripts/cliargs.sh b/scripts/cliargs.sh index 9bceae4..ebc70f7 100755 --- a/scripts/cliargs.sh +++ b/scripts/cliargs.sh @@ -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" diff --git a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java index 7d2e9b2..a93cbf1 100644 --- a/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CompileKotlinOperationBuild.java @@ -33,7 +33,7 @@ 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; @@ -41,18 +41,22 @@ public class CompileKotlinOperationBuild extends Project { 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"))) +// .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))) diff --git a/src/main/java/rife/bld/extension/dokka/AnalysisPlatform.java b/src/main/java/rife/bld/extension/dokka/AnalysisPlatform.java deleted file mode 100644 index dd6ff1a..0000000 --- a/src/main/java/rife/bld/extension/dokka/AnalysisPlatform.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rife.bld.extension.dokka; - -/** - * Dokka's analysis platforms. - * - * @author Erik C. Thauvin - * @since 1.0 - */ -public enum AnalysisPlatform { - JVM, JS, NATIVE, COMMON, ANDROID -} diff --git a/src/main/java/rife/bld/extension/dokka/DocumentedVisibility.java b/src/main/java/rife/bld/extension/dokka/DocumentedVisibility.java deleted file mode 100644 index dae65a4..0000000 --- a/src/main/java/rife/bld/extension/dokka/DocumentedVisibility.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rife.bld.extension.dokka; - -/** - * Dokka documented visibilities. - * - * @author Erik C. Thauvin - * @since 1.0 - */ -public enum DocumentedVisibility { - PUBLIC, PRIVATE, PROTECTED, INTERNAL, PACKAGE -} diff --git a/src/main/java/rife/bld/extension/dokka/DokkaOperation.java b/src/main/java/rife/bld/extension/dokka/DokkaOperation.java deleted file mode 100644 index 56d2661..0000000 --- a/src/main/java/rife/bld/extension/dokka/DokkaOperation.java +++ /dev/null @@ -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 Erik C. Thauvin - * @since 1.0 - */ -@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes") -public class DokkaOperation extends AbstractProcessOperation { - 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 globalLinks_ = new ConcurrentHashMap<>(); - private final Collection globalPackageOptions_ = new ArrayList<>(); - private final Collection globalSrcLinks_ = new ArrayList<>(); - private final Collection includes_ = new ArrayList<>(); - private final Collection pluginsClasspath_ = new ArrayList<>(); - private final Map 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. - *

- * 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 executeConstructProcessCommandList() { - if (project_ == null) { - throw new IllegalArgumentException("A project must be specified."); - } - - final List 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(); - 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(); - 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}. - *

- * Sets the {@link #sourceSet sourceSet}, {@link SourceSet#jdkVersion jdkVersion}, {@link #moduleName moduleName} - * and {@link SourceSet#classpath(String...) classpath} from the project. - * - * @param project the project to configure the operation from - */ - @Override - public DokkaOperation fromProject(BaseProject project) { - project_ = project; - sourceSet_ = new SourceSet() - .src(new File(project.srcMainDirectory(), "kotlin").getAbsolutePath()) - .classpath(project.compileClasspathJars()) - .classpath(project.providedClasspathJars()); - if (project.javaRelease() != null) { - sourceSet_ = sourceSet_.jdkVersion(project.javaRelease()); - } - moduleName_ = project.name(); - return this; - } - - /** - * Sets whether to fail documentation generation if Dokka has emitted a warning or an error. - *

- * Whether to fail documentation generation if Dokka has emitted a warning or an error. The process waits until all - * errors and warnings have been emitted first. - *

- * This setting works well with {@link SourceSet#reportUndocumented} - * - * @param failOnWarning {@code true} or {@code false} - * @return this operation instance - */ - public DokkaOperation failOnWarning(Boolean failOnWarning) { - failOnWarning_ = failOnWarning; - return this; - } - - /** - * Set the global external documentation links. - * - * @param url the external documentation URL - * @param packageListUrl the external documentation package list URL - * @return this operation instance - */ - public DokkaOperation globalLinks(String url, String packageListUrl) { - globalLinks_.put(url, packageListUrl); - return this; - } - - /** - * Set the global external documentation links. - * - * @param globalLinks the map of global links - * @return this operation instance - * @see #globalSrcLink(String...) #globalSrcLink(String...)#globalSrcLink(String...) - */ - public DokkaOperation globalLinks(Map globalLinks) { - globalLinks_.putAll(globalLinks); - return this; - } - - /** - * Sets the global list of package configurations. - *

- * Using format: - *

    - *
  • matchingRegexp
  • - *
  • -deprecated
  • - *
  • -privateApi
  • - *
  • +warnUndocumented
  • - *
  • +suppress
  • - *
  • +visibility:PUBLIC
  • - *
  • ...
  • - *
- * - * @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. - *

- * Using format: - *

    - *
  • matchingRegexp
  • - *
  • -deprecated
  • - *
  • -privateApi
  • - *
  • +warnUndocumented
  • - *
  • +suppress
  • - *
  • +visibility:PUBLIC
  • - *
  • ...
  • - *
- * - * @param options the list of package configurations - * @return this operation instance - */ - public DokkaOperation globalPackageOptions(Collection 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 links) { - globalSrcLinks_.addAll(links); - return this; - } - - /** - * Sets the Markdown files that contain module and package documentation. - *

- * The contents of specified files are parsed and embedded into documentation as module and package descriptions. - *

- * This can be configured on per-package basis. - * - * @param files 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. - *

- * The contents of specified files are parsed and embedded into documentation as module and package descriptions. - *

- * This can be configured on per-package basis. - * - * @param files the list of files - * @return this operation instance - */ - public DokkaOperation includes(Collection 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}. - *

- * The display name used to refer to the module. It is used for the table of contents, navigation, logging, etc. - * - * @param moduleName the project/module name - * @return this operation instance - */ - public DokkaOperation moduleName(String moduleName) { - moduleName_ = moduleName; - return this; - } - - /** - * Set the documented version. - * - * @param version the version - * @return this operation instance - */ - public DokkaOperation moduleVersion(String version) { - moduleVersion_ = version; - return this; - } - - /** - * Sets whether to suppress obvious functions such as inherited from - * kotlin.Any and {@link java.lang.Object}. - *

- * A function is considered to be obvious if it is: - *

    - *
  • Inherited from kotlin.Any, - * Kotlin.Enum, {@link java.lang.Object} - * or {@link java.lang.Enum}, such as {@code equals}, {@code hashCode}, {@code toString}. - *
  • Synthetic (generated by the compiler) and does not have any documentation, such as - * {@code dataClass.componentN} or {@code dataClass.copy}. - *
- * - * @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. - *

- * This includes package-lists used for generating external documentation links. For example, to make classes from - * the standard library clickable. - *

- * Setting this to true can significantly speed up build times in certain cases, but can also worsen documentation - * quality and user experience. For example, by not resolving class/member links from your dependencies, including - * the standard library. - *

- * Note: You can cache fetched files locally and provide them to Dokka as local paths. - * - * @param offlineMode the offline mode - * @return this operation instance - * @see SourceSet#externalDocumentationLinks(String, String) - */ - public DokkaOperation offlineMode(Boolean offlineMode) { - offlineMode_ = offlineMode; - return this; - } - - /** - * Sets the output directory path, {@code ./dokka} by default. - *

- * The directory to where documentation is generated, regardless of output format. - * - * @param outputDir the output directory - * @return this operation instance - */ - public DokkaOperation outputDir(File outputDir) { - outputDir_ = outputDir; - return this; - } - - /** - * Sets the output directory path, {@code ./dokka} by default. - *

- * The directory to where documentation is generated, regardless of output format. - * - * @param outputDir the output directory - * @return this operation instance - */ - public DokkaOperation outputDir(String outputDir) { - outputDir_ = new File(outputDir); - return this; - } - - /** - * Sets the Dokka {@link OutputFormat output format}. - * - * @param format The {@link OutputFormat output format} - * @return this operation instance - */ - public DokkaOperation outputFormat(OutputFormat format) { - pluginsClasspath_.clear(); - if (format.equals(OutputFormat.JAVADOC)) { - pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(), - JAVADOC_PLUGIN_REGEXP)); - } else if (format.equals(OutputFormat.HTML)) { - pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(), - HTML_PLUGIN_REGEXP)); - } else if (format.equals(OutputFormat.MARKDOWN)) { - pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(), - GFM_PLUGIN_REGEXP)); - } else if (format.equals(OutputFormat.JEKYLL)) { - pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(), - JEKYLL_PLUGIN_REGEXP)); - } - return this; - } - - /** - * Sets the configuration for Dokka plugins. - * - * @param name The fully-qualified plugin name - * @param jsonConfiguration The plugin JSON configuration - * @return this operation instance - */ - public DokkaOperation pluginConfigurations(String name, String jsonConfiguration) { - pluginsConfiguration_.put(name, jsonConfiguration); - return this; - } - - /** - * Sets the configuration for Dokka plugins. - * - * @param pluginConfiguratione the map of configurations - * @return this operation instance - * @see #pluginConfigurations(String, String) - */ - public DokkaOperation pluginConfigurations(Map 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 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. - *

- * Individual and additional configuration of Kotlin source sets. - * - * @param sourceSet the source set configurations - * @return this operation instance - */ - public DokkaOperation sourceSet(SourceSet sourceSet) { - sourceSet_ = sourceSet; - return this; - } - - /** - * Sets whether to suppress inherited members that aren't explicitly overridden in a given class. - * - * @param suppressInheritedMembers {@code true} or {@code false} - * @return this operation instance - */ - public DokkaOperation suppressInheritedMembers(Boolean suppressInheritedMembers) { - suppressInheritedMembers_ = suppressInheritedMembers; - return this; - } -} diff --git a/src/main/java/rife/bld/extension/dokka/LoggingLevel.java b/src/main/java/rife/bld/extension/dokka/LoggingLevel.java deleted file mode 100644 index b493e11..0000000 --- a/src/main/java/rife/bld/extension/dokka/LoggingLevel.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rife.bld.extension.dokka; - -/** - * Dokka logging levels. - * - * @author Erik C. Thauvin - * @since 1.0 - */ -public enum LoggingLevel { - DEBUG, PROGRESS, INFO, WARN, ERROR -} diff --git a/src/main/java/rife/bld/extension/dokka/OutputFormat.java b/src/main/java/rife/bld/extension/dokka/OutputFormat.java deleted file mode 100644 index 0d4a2c0..0000000 --- a/src/main/java/rife/bld/extension/dokka/OutputFormat.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rife.bld.extension.dokka; - -/** - * Dokka output formats. - * - * @author Erik C. Thauvin - * @since 1.0 - */ -public enum OutputFormat { - JAVADOC, JEKYLL, HTML, MARKDOWN -} diff --git a/src/main/java/rife/bld/extension/dokka/SourceSet.java b/src/main/java/rife/bld/extension/dokka/SourceSet.java deleted file mode 100644 index e9457b5..0000000 --- a/src/main/java/rife/bld/extension/dokka/SourceSet.java +++ /dev/null @@ -1,680 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rife.bld.extension.dokka; - -import java.io.File; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Configuration for a Dokka source set. - * - * @author Erik C. Thauvin - * @since 1.0 - */ -public class SourceSet { - private static final String SEMICOLON = ";"; - private final Collection classpath_ = new ArrayList<>(); - private final Map dependentSourceSets_ = new ConcurrentHashMap<>(); - private final Collection documentedVisibilities_ = new ArrayList<>(); - private final Map externalDocumentationLinks_ = new ConcurrentHashMap<>(); - private final Collection includes_ = new ArrayList<>(); - private final Collection perPackageOptions_ = new ArrayList<>(); - private final Collection samples_ = new ArrayList<>(); - private final Map srcLinks_ = new ConcurrentHashMap<>(); - private final Collection src_ = new ArrayList<>(); - private final Collection 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} - *

- * 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 args() { - var args = new ArrayList(); - - // -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(); - 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(); - 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(); - 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(); - 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. - *

- * This is useful if some types that come from dependencies are not resolved/picked up automatically. - *

- * This option accepts both {@code .jar} and {@code .klib} files. - * - * @param files one or more file - * @return this operation instance - */ - public SourceSet classpath(String... files) { - Collections.addAll(classpath_, files); - return this; - } - - /** - * Sets classpath for analysis and interactive samples. - *

- * This is useful if some types that come from dependencies are not resolved/picked up automatically. - *

- * This option accepts both {@code .jar} and {@code .klib} files. - * - * @param files the list of files - * @return this operation instance - */ - public SourceSet classpath(Collection files) { - classpath_.addAll(files); - return this; - } - - /** - * Sets classpath for analysis and interactive samples. - *

- * This is useful if some types that come from dependencies are not resolved/picked up automatically. - *

- * This option accepts both {@code .jar} and {@code .klib} files. - * - * @param files the list of files - * @return this operation instance - */ - public SourceSet classpath(List 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 dependentSourceSets) { - dependentSourceSets_.putAll(dependentSourceSets); - return this; - } - - /** - * Sets the display name of the source set, used both internally and externally. - *

- * The name is used both externally (for example, the source set name is visible to documentation readers) and - * internally (for example, for logging messages of {@link #reportUndocumented reportUndocumented}). - *

- * The platform name can be used if you don't have a better alternative. - * - * @param displayName the display name - * @return this operation instance - */ - public SourceSet displayName(String displayName) { - displayName_ = displayName; - return this; - } - - /** - * Sets visibilities to be documented. - *

- * This can be used if you want to document protected/internal/private declarations, as well as if you want to - * exclude public declarations and only document internal API. - *

- * This can be configured on per-package basis. - * - * @param visibilities one or more visibilities - * @return this operation instance - */ - public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) { - documentedVisibilities_.addAll(Arrays.asList(visibilities)); - return this; - } - - /** - * Sets the external documentation links. - *

- * A set of parameters for external documentation links that is applied only for this source set. - * - * @param url the external documentation URL - * @param packageListUrl the external documentation package list URL - * @return this operation instance - */ - public SourceSet externalDocumentationLinks(String url, String packageListUrl) { - externalDocumentationLinks_.put(url, packageListUrl); - return this; - } - - /** - * Sets the external documentation links. - *

- * A set of parameters for external documentation links that is applied only for this source set. - * - * @param externalDocumentationLinks the map of external documentation links - * @return this operation instance - * @see #externalDocumentationLinks(String, String) - */ - public SourceSet externalDocumentationLinks(Map externalDocumentationLinks) { - externalDocumentationLinks_.putAll(externalDocumentationLinks); - return this; - } - - /** - * Sets the Markdown files that contain module and package documentation. - *

- * A list of Markdown files that contain module and package documentation. - *

- * The contents of the specified files are parsed and embedded into documentation as module and package - * descriptions. - * - * @param files 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. - *

- * A list of Markdown files that contain module and package documentation. - *

- * The contents of the specified files are parsed and embedded into documentation as module and package - * descriptions. - * - * @param files the list of files - * @return this operation instance - */ - public SourceSet includes(Collection files) { - includes_.addAll(files); - return this; - } - - /** - * Sets the version of JDK to use for linking to JDK Javadocs. - *

- * The JDK version to use when generating external documentation links for Java types. - *

- * For example, if you use {@link java.util.UUID} in some public declaration signature, and this option is set to 8, - * Dokka generates an external documentation link to JDK 8 Javadocs for it. - * - * @param jdkVersion the JDK version - * @return this operation instance - */ - public SourceSet jdkVersion(String jdkVersion) { - jdkVersion_ = jdkVersion; - return this; - } - - /** - * Sets the version of JDK to use for linking to JDK Javadocs. - *

- * The JDK version to use when generating external documentation links for Java types. - *

- * For example, if you use {@link java.util.UUID} in some public declaration signature, and this option is set to 8, - * Dokka generates an external documentation link to JDK 8 Javadocs for it. - * - * @param jdkVersion the JDK version - * @return this operation instance - */ - public SourceSet jdkVersion(int jdkVersion) { - jdkVersion_ = String.valueOf(jdkVersion); - return this; - } - - /** - * Sets the language version used for setting up analysis and samples. - * - * @param languageVersion the language version - * @return this operation instance - */ - public SourceSet languageVersion(String languageVersion) { - languageVersion_ = languageVersion; - return this; - } - - /** - * Sets the language version used for setting up analysis and samples. - * - * @param languageVersion the language version - * @return this operation instance - */ - public SourceSet languageVersion(int languageVersion) { - languageVersion_ = String.valueOf(languageVersion); - return this; - } - - /** - * Sets whether to generate links to JDK Javadocs. - *

- * Whether to generate external documentation links to JDK's Javadocs. - *

- * The version of JDK Javadocs is determined by the {@link #jdkVersion jdkVersion} option. - *

- * Note: Links are generated when noJdkLink is set to false. - * - * @param noJdkLink {@code true} or {@code false} - * @return this operation instance - */ - public SourceSet noJdkLink(Boolean noJdkLink) { - noJdkLink_ = noJdkLink; - return this; - } - - /** - * Sets whether to create pages for empty packages. - *

- * Whether to skip packages that contain no visible declarations after various filters have been applied. - * - * @param noSkipEmptyPackages {@code true} or {@code false} - * @return this operation instance - */ - public SourceSet noSkipEmptyPackages(boolean noSkipEmptyPackages) { - noSkipEmptyPackages_ = noSkipEmptyPackages; - return this; - } - - /** - * Sets whether to generate links to Standard library. - *

- * Whether to generate external documentation links that lead to the API reference documentation of Kotlin's - * standard library. - *

- * Note: Links are generated when noStdLibLink is set to {@code false}. - * - * @param noStdlibLink {@code true} or {@code false} - * @return this operation instance - */ - public SourceSet noStdlibLink(Boolean noStdlibLink) { - noStdlibLink_ = noStdlibLink; - return this; - } - - /** - * Set the list of package source set configuration. - *

- * A set of parameters specific to matched packages within this source set. - *

- * Using format: - *

    - *
  • matchingRegexp
  • - *
  • -deprecated
  • - *
  • -privateApi
  • - *
  • +warnUndocumented
  • - *
  • +suppress
  • - *
  • +visibility:PUBLIC
  • - *
  • ...
  • - *
- * - * @param perPackageOptions the list of per package options - * @return this operation instance - */ - public SourceSet perPackageOptions(Collection perPackageOptions) { - perPackageOptions_.addAll(perPackageOptions); - return this; - } - - /** - * Set the list of package source set configuration. - *

- * A set of parameters specific to matched packages within this source set. - *

- * Using format: - *

    - *
  • matchingRegexp
  • - *
  • -deprecated
  • - *
  • -privateApi
  • - *
  • +warnUndocumented
  • - *
  • +suppress
  • - *
  • +visibility:PUBLIC
  • - *
  • ...
  • - *
- * - * @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. - *

- * Whether to emit warnings about visible undocumented declarations, that is declarations without KDocs after they - * have been filtered by documentedVisibilities and other filters. - *

- * This setting works well with {@link DokkaOperation#failOnWarning}. - *

- * This can be configured on per-package basis. - * - * @param reportUndocumented {@code true} or {@code false} - * @return this operation instance - */ - public SourceSet reportUndocumented(Boolean reportUndocumented) { - reportUndocumented_ = reportUndocumented; - return this; - } - - /** - * Set the list of directories or files that contain sample functions. - *

- * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc - * tag. - * - * @param samples the list of samples - * @return this operation instance - */ - public SourceSet samples(Collection samples) { - samples_.addAll(samples); - return this; - } - - /** - * Set the list of directories or files that contain sample functions. - *

- * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc - * tag. - * - * @param samples 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. - *

- * Whether to document declarations annotated with {@code @Deprecated}. - *

- * This can be configured on per-package basis. - * - * @param skipDeprecated {@code true} or {@code false} - * @return this operation instance - */ - public SourceSet skipDeprecated(boolean skipDeprecated) { - skipDeprecated_ = skipDeprecated; - return this; - } - - /** - * Sets the name of the source set. Default is {@code main}. - * - * @param sourceSetName the source set name. - * @return this operation instance - */ - public SourceSet sourceSetName(String sourceSetName) { - sourceSetName_ = sourceSetName; - return this; - } - - /** - * Sets the source code roots to be analyzed and documented. - *

- * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual - * {@code .kt} / {@code .java} files. - * - * @param src the list of source code roots - * @return this operation instance - */ - public SourceSet src(Collection src) { - src_.addAll(src); - return this; - } - - /** - * Sets the source code roots to be analyzed and documented. - *

- * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual - * {@code .kt} / {@code .java} files. - * - * @param src 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. - *

- * The files to be suppressed when generating documentation. - * - * @param suppressedFiles the list of suppressed files - * @return this operation instance - */ - public SourceSet suppressedFiles(Collection suppressedFiles) { - suppressedFiles_.addAll(suppressedFiles); - return this; - } - - /** - * Sets the paths to files to be suppressed. - *

- * The files to be suppressed when generating documentation. - * - * @param suppressedFiles one or moe suppressed files - * @return this operation instance - */ - public SourceSet suppressedFiles(String... suppressedFiles) { - suppressedFiles_.addAll(Arrays.asList(suppressedFiles)); - return this; - } -} diff --git a/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java b/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java deleted file mode 100644 index 0e089ee..0000000 --- a/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java +++ /dev/null @@ -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)); - } - }); - } -} diff --git a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java b/src/test/java/rife/bld/extension/dokka/SourceSetTest.java deleted file mode 100644 index b503335..0000000 --- a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java +++ /dev/null @@ -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))); - } -} diff --git a/src/test/resources/dokka-args.txt b/src/test/resources/dokka-args.txt deleted file mode 100644 index 4c9f29c..0000000 --- a/src/test/resources/dokka-args.txt +++ /dev/null @@ -1,16 +0,0 @@ --delayTemplateSubstitution --failOnWarning --globalLinks --globalPackageOptions --globalSrcLink --includes --loggingLevel --moduleName --moduleVersion --noSuppressObviousFunctions --offlineMode --outputDir --pluginsClasspath --pluginsConfiguration --sourceSet --suppressInheritedMembers diff --git a/src/test/resources/dokka-sourceset-args.txt b/src/test/resources/dokka-sourceset-args.txt deleted file mode 100644 index 0699eb7..0000000 --- a/src/test/resources/dokka-sourceset-args.txt +++ /dev/null @@ -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