Initial commit (split from bld-kotlin)
Some checks failed
bld-ci / build-bld-project (17) (push) Has been cancelled
bld-ci / build-bld-project (21) (push) Has been cancelled
bld-ci / build-bld-project (22) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled

This commit is contained in:
Erik C. Thauvin 2024-06-15 16:36:35 -07:00
commit a46ed2c012
Signed by: erik
GPG key ID: 776702A6A2DA330E
67 changed files with 3428 additions and 0 deletions

50
.github/workflows/bld.yml vendored Normal file
View file

@ -0,0 +1,50 @@
name: bld-ci
on: [push, pull_request, workflow_dispatch]
jobs:
build-bld-project:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [17, 21, 22]
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: ${{ matrix.java-version }}
- name: Download the examples dependencies
working-directory: examples
run: |
chmod +x bld
./bld download
- name: Run examples tests
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
- name: Download the dependencies
run: ./bld download
- name: Run tests
run: ./bld compile test

57
.github/workflows/pages.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: javadocs-pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: 17
- name: Build Javadocs
run: ./bld download clean javadoc
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload generated Javadocs repository
path: "build/javadoc/"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1

57
.gitignore vendored Normal file
View file

@ -0,0 +1,57 @@
.gradle
.DS_Store
build
lib/bld/**
!lib/bld/bld-wrapper.jar
!lib/bld/bld-wrapper.properties
lib/compile/
lib/runtime/
lib/standalone/
lib/test/
# IDEA ignores
# User-specific
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Editor-based Rest Client
.idea/httpRequests
local.properties

3
.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

28
.idea/app.iml generated Normal file
View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/main" />
<output-test url="file://$MODULE_DIR$/build/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" relativeOutputPath="resources" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="RUNTIME">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="compile" level="project" />
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
<orderEntry type="library" scope="TEST" name="test" level="project" />
</component>
</module>

14
.idea/bld.iml generated Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/bld" />
<output-test url="file://$MODULE_DIR$/build/bld" />
<exclude-output />
<content url="file://$MODULE_DIR$/src/bld">
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="bld" level="project" />
</component>
</module>

6
.idea/copyright/Apache_License.xml generated Normal file
View file

@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="Copyright 2023-Copyright &amp;#36;today.yearamp;#36;today.year the original author or authors.&#10; &#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10; https://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
<option name="myName" value="Apache License" />
</copyright>
</component>

3
.idea/copyright/profiles_settings.xml generated Normal file
View file

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="Apache License" />
</component>

View file

@ -0,0 +1,8 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ADDITIONAL_TAGS" value="created" />
</inspection_tool>
</profile>
</component>

204
.idea/intellij-javadocs-4.0.1.xml generated Normal file
View file

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaDocConfiguration">
<GENERAL>
<MODE>UPDATE</MODE>
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
<LEVELS>
<LEVEL>FIELD</LEVEL>
<LEVEL>TYPE</LEVEL>
<LEVEL>METHOD</LEVEL>
</LEVELS>
<VISIBILITIES>
<VISIBILITY>DEFAULT</VISIBILITY>
<VISIBILITY>PUBLIC</VISIBILITY>
<VISIBILITY>PROTECTED</VISIBILITY>
</VISIBILITIES>
</GENERAL>
<TEMPLATES>
<CLASSES>
<CLASS>
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
<VALUE>/**\n
* The interface ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
<VALUE>/**\n
* The enum ${name}.\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
<VALUE>/**\n
* The type ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>.+</KEY>
<VALUE>/**\n
* The type ${name}.\n
*/</VALUE>
</CLASS>
</CLASSES>
<CONSTRUCTORS>
<CONSTRUCTOR>
<KEY>.+</KEY>
<VALUE>/**\n
* Instantiates a new ${name}.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</CONSTRUCTOR>
</CONSTRUCTORS>
<METHODS>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*&lt;.+&gt;)*)+\s+get\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Gets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*&lt;.+&gt;)*)+\s+set\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Sets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
<VALUE>/**\n
* The entry point of application.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
* @param ${element.parameterList.parameters[0].name} the input arguments\n
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>.+</KEY>
<VALUE>/**\n
* ${name}&lt;#if isNotVoid&gt; ${return}&lt;/#if&gt;.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${return}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
</METHODS>
<FIELDS>
<FIELD>
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
* The constant ${element.getName()}.\n
*/</VALUE>
</FIELD>
<FIELD>
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isInterface()&gt;
* The constant ${element.getName()}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt; */</VALUE>
</FIELD>
<FIELD>
<KEY>.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isEnum()&gt;
*${name} ${typeName}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt;*/</VALUE>
</FIELD>
</FIELDS>
</TEMPLATES>
</component>
</project>

20
.idea/libraries/bld.xml generated Normal file
View file

@ -0,0 +1,20 @@
<component name="libraryTable">
<library name="bld">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1.jar!/" />
<root url="file://$PROJECT_DIR$/lib/bld" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1-sources.jar!/" />
<root url="file://$PROJECT_DIR$/lib/bld" />
</SOURCES>
<excluded>
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
</excluded>
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
</library>
</component>

13
.idea/libraries/compile.xml generated Normal file
View file

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="compile">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/compile" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/compile" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
</library>
</component>

14
.idea/libraries/runtime.xml generated Normal file
View file

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="runtime">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/runtime" />
<root url="file://$PROJECT_DIR$/src/main/resources" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
</library>
</component>

14
.idea/libraries/test.xml generated Normal file
View file

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="test">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/src/test/resources" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/test" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
</library>
</component>

9
.idea/misc.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<pattern value="rife.bld.extension.CompileKotlinOperationBuild" method="pmd" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build" />
</component>
</project>

9
.idea/modules.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
</modules>
</component>
</project>

9
.idea/runConfigurations/Run Tests.xml generated Normal file
View file

@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="rife.bld.extension.CompileKotlinOperationTest" />
<module name="app" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

6
.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

18
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Tests",
"request": "launch",
"mainClass": "org.junit.platform.console.ConsoleLauncher",
"args": [
"--details=verbose",
"--scan-classpath",
"--disable-banner",
"--disable-ansi-colors",
"--exclude-engine=junit-platform-suite",
"--exclude-engine=junit-vintage"]
}
]
}

15
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,15 @@
{
"java.project.sourcePaths": [
"src/main/java",
"src/main/resources",
"src/test/java",
"src/test/resources",
"src/bld/java",
"src/bld/resources"
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-1.9.1.jar",
"lib/**/*.jar"
]
}

177
LICENSE.txt Normal file
View file

@ -0,0 +1,177 @@
Apache License
Version 2.0, January 2004
https://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

80
README.md Normal file
View file

@ -0,0 +1,80 @@
# [bld](https://rife2.com/bld) Extension to Generate API Documentation with [Dokka](https://github.com/Kotlin/dokka) for [Kotlin](https://kotlinlang.org/)
[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
[![bld](https://img.shields.io/badge/1.9.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
[![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-dokka/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-dokka)
[![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-dokka/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-dokka)
[![GitHub CI](https://github.com/rife2/bld-dokka/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-dokka/actions/workflows/bld.yml)
To install, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) and [support](https://github.com/rife2/bld/wiki/Kotlin-Support)
documentation.
## Generate API Documentation
To generate a project's documentation in various formats:
```java
@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();
}
```
```console
./bld javadoc
./bld dokka-html
./bld dokka-gfm
./bld dokka-jekyll
```
- [View Examples Project](https://github.com/rife2/bld-dokka/tree/main/examples/)
Please check the [Dokka Operation documentation](https://rife2.github.io/bld-dokka/rife/bld/extension/DokkaOperation.html#method-summary)
for all available configuration options.
## Template Project
There is also a [Kotlin Template Project](https://github.com/rife2/kotlin-bld-example) with support for Dokka and the
[Detekt](https://github.com/rife2/bld-detekt) extensions.

2
bld Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env sh
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build rife.bld.extension.DokkaOperationBuild "$@"

4
bld.bat Normal file
View file

@ -0,0 +1,4 @@
@echo off
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build rife.bld.extension.DokkaOperationBuild %*

109
config/pmd.xml Normal file
View file

@ -0,0 +1,109 @@
<?xml version="1.0"?>
<ruleset name="erik"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Erik's Ruleset</description>
<!-- BEST PRACTICES -->
<rule ref="category/java/bestpractices.xml">
<exclude name="AvoidPrintStackTrace"/>
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
<exclude name="JUnitTestContainsTooManyAsserts"/>
<exclude name="GuardLogStatement"/>
</rule>
<rule ref="category/java/bestpractices.xml/MissingOverride">
<properties>
<property name="violationSuppressXPath"
value="//MethodDeclaration[@Name='hashCode' or @Name='equals' or @Name='toString']"/>
</properties>
</rule>
<!-- CODE STYLE -->
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/>
<exclude name="ClassNamingConventions"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="ConfusingTernary"/>
<exclude name="FieldNamingConventions"/>
<exclude name="LocalVariableCouldBeFinal"/>
<exclude name="LongVariable"/>
<exclude name="MethodArgumentCouldBeFinal"/>
<exclude name="OnlyOneReturn"/>
<exclude name="PackageCase"/>
<exclude name="ShortClassName"/>
<exclude name="ShortMethodName"/>
<exclude name="ShortVariable"/>
<exclude name="UseExplicitTypes"/>
<exclude name="UseUnderscoresInNumericLiterals"/>
<exclude name="UselessParentheses"/>
</rule>
<rule ref="category/java/codestyle.xml/UnnecessaryImport">
<properties>
<property name="violationSuppressRegex" value="Unused (static|.*\.\*).*"/>
</properties>
</rule>
<!-- DESIGN -->
<rule ref="category/java/design.xml">
<exclude name="AvoidCatchingGenericException"/>
<exclude name="AvoidDeeplyNestedIfStmts"/>
<exclude name="AvoidUncheckedExceptionsInSignatures"/>
<exclude name="CognitiveComplexity"/>
<exclude name="CyclomaticComplexity"/>
<exclude name="ExcessiveParameterList"/>
<exclude name="ExcessivePublicCount"/>
<exclude name="GodClass"/>
<exclude name="LawOfDemeter"/>
<exclude name="LoosePackageCoupling"/>
<exclude name="NPathComplexity"/>
<exclude name="NcssCount"/>
<exclude name="TooManyFields"/>
<exclude name="TooManyMethods"/>
<exclude name="UseObjectForClearerAPI"/>
</rule>
<!-- DOCUMENTATION -->
<rule ref="category/java/documentation.xml">
<exclude name="CommentRequired"/>
<exclude name="CommentSize"/>
</rule>
<!-- ERROR PRONE -->
<rule ref="category/java/errorprone.xml">
<exclude name="AssignmentInOperand"/>
<exclude name="AvoidCatchingNPE"/>
<exclude name="AvoidDuplicateLiterals"/>
<exclude name="AvoidFieldNameMatchingMethodName"/>
<exclude name="AvoidFieldNameMatchingTypeName"/>
<exclude name="AvoidLiteralsInIfCondition"/>
<exclude name="NullAssignment"/>
</rule>
<rule ref="category/java/errorprone.xml/AssignmentInOperand">
<properties>
<property name="allowWhile" value="true"/>
<property name="allowFor" value="true"/>
<property name="allowIf" value="true"/>
</properties>
</rule>
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
<properties>
<property name="skipAnnotations" value="true"/>
</properties>
</rule>
<!-- MULTITHREADING -->
<rule ref="category/java/multithreading.xml">
</rule>
<!-- PERFORMANCE -->
<rule ref="category/java/performance.xml">
</rule>
<!-- SECURITY -->
<rule ref="category/java/security.xml">
</rule>
</ruleset>

55
examples/.gitignore vendored Normal file
View file

@ -0,0 +1,55 @@
.gradle
.DS_Store
build
lib/bld/**
!lib/bld/bld-wrapper.jar
!lib/bld/bld-wrapper.properties
lib/compile/
lib/runtime/
lib/standalone/
lib/test/
# IDEA ignores
# User-specific
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Editor-based Rest Client
.idea/httpRequests

3
examples/.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

1
examples/.idea/.name generated Normal file
View file

@ -0,0 +1 @@
bld-dokka-examples

29
examples/.idea/app.iml generated Normal file
View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/main" />
<output-test url="file://$MODULE_DIR$/build/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" relativeOutputPath="resources" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="RUNTIME">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="compile" level="project" />
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
<orderEntry type="library" scope="TEST" name="test" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>

15
examples/.idea/bld.iml generated Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/bld" />
<output-test url="file://$MODULE_DIR$/build/bld" />
<exclude-output />
<content url="file://$MODULE_DIR$/src/bld">
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="bld" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>

View file

@ -0,0 +1,8 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ADDITIONAL_TAGS" value="created" />
</inspection_tool>
</profile>
</component>

141
examples/.idea/intellij-javadocs-4.0.1.xml generated Normal file
View file

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaDocConfiguration">
<GENERAL>
<MODE>UPDATE</MODE>
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
<LEVELS>
<LEVEL>METHOD</LEVEL>
<LEVEL>FIELD</LEVEL>
<LEVEL>TYPE</LEVEL>
</LEVELS>
<VISIBILITIES>
<VISIBILITY>PROTECTED</VISIBILITY>
<VISIBILITY>DEFAULT</VISIBILITY>
<VISIBILITY>PUBLIC</VISIBILITY>
</VISIBILITIES>
</GENERAL>
<TEMPLATES>
<CLASSES>
<CLASS>
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
<VALUE>/**\n
* The interface ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;&lt;#list element.typeParameters as typeParameter&gt; * @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt; */</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
<VALUE>/**\n
* The enum ${name}.\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
<VALUE>/**\n
* The type ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;&lt;#list element.typeParameters as typeParameter&gt; * @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt; */</VALUE>
</CLASS>
<CLASS>
<KEY>.+</KEY>
<VALUE>/**\n
* The type ${name}.\n
*/</VALUE>
</CLASS>
</CLASSES>
<CONSTRUCTORS>
<CONSTRUCTOR>
<KEY>.+</KEY>
<VALUE>/**\n
* Instantiates a new ${name}.\n
&lt;#if element.parameterList.parameters?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.parameterList.parameters as parameter&gt; * @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;&lt;#if element.throwsList.referenceElements?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.throwsList.referenceElements as exception&gt; * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt; */</VALUE>
</CONSTRUCTOR>
</CONSTRUCTORS>
<METHODS>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*&lt;.+&gt;)*)+\s+get\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Gets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;&lt;#list element.typeParameters as typeParameter&gt; * @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;&lt;#if element.parameterList.parameters?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.parameterList.parameters as parameter&gt; * @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;&lt;#if isNotVoid&gt; *\n
* @return the ${partName}\n
&lt;/#if&gt;&lt;#if element.throwsList.referenceElements?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.throwsList.referenceElements as exception&gt; * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt; */</VALUE>
</METHOD>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*&lt;.+&gt;)*)+\s+set\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Sets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;&lt;#list element.typeParameters as typeParameter&gt; * @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;&lt;#if element.parameterList.parameters?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.parameterList.parameters as parameter&gt; * @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;&lt;#if isNotVoid&gt; *\n
* @return the ${partName}\n
&lt;/#if&gt;&lt;#if element.throwsList.referenceElements?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.throwsList.referenceElements as exception&gt; * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt; */</VALUE>
</METHOD>
<METHOD>
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
<VALUE>/**\n
* The entry point of application.\n
&lt;#if element.parameterList.parameters?has_content&gt; *\n
&lt;/#if&gt; * @param ${element.parameterList.parameters[0].name} the input arguments\n
&lt;#if element.throwsList.referenceElements?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.throwsList.referenceElements as exception&gt; * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt; */</VALUE>
</METHOD>
<METHOD>
<KEY>.+</KEY>
<VALUE>/**\n
* ${name}&lt;#if isNotVoid&gt; ${return}&lt;/#if&gt;.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;&lt;#list element.typeParameters as typeParameter&gt; * @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;&lt;#if element.parameterList.parameters?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.parameterList.parameters as parameter&gt; * @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;&lt;#if isNotVoid&gt; *\n
* @return the ${return}\n
&lt;/#if&gt;&lt;#if element.throwsList.referenceElements?has_content&gt; *\n
&lt;/#if&gt;&lt;#list element.throwsList.referenceElements as exception&gt; * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt; */</VALUE>
</METHOD>
</METHODS>
<FIELDS>
<FIELD>
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
* The constant ${element.getName()}.\n
*/</VALUE>
</FIELD>
<FIELD>
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isInterface()&gt; * The constant ${element.getName()}.\n
&lt;#else&gt; * The ${name}.\n
&lt;/#if&gt; */</VALUE>
</FIELD>
<FIELD>
<KEY>.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isEnum()&gt; *${name} ${typeName}.\n
&lt;#else&gt; * The ${name}.\n
&lt;/#if&gt;*/</VALUE>
</FIELD>
</FIELDS>
</TEMPLATES>
</component>
</project>

6
examples/.idea/kotlinc.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Kotlin2JvmCompilerArguments">
<option name="jvmTarget" value="1.8" />
</component>
</project>

View file

@ -0,0 +1,23 @@
<component name="libraryTable">
<library name="KotlinJavaRuntime" type="repository">
<properties maven-id="org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.20/kotlin-stdlib-jdk8-1.9.20.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.20/kotlin-stdlib-1.9.20.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.20/kotlin-stdlib-jdk7-1.9.20.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.20/kotlin-stdlib-jdk8-1.9.20-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.20/kotlin-stdlib-1.9.20-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.20/kotlin-stdlib-jdk7-1.9.20-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.20/kotlin-stdlib-jdk8-1.9.20-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.20/kotlin-stdlib-1.9.20-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.20/kotlin-stdlib-jdk7-1.9.20-sources.jar!/" />
</SOURCES>
</library>
</component>

18
examples/.idea/libraries/bld.xml generated Normal file
View file

@ -0,0 +1,18 @@
<component name="libraryTable">
<library name="bld">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1-sources.jar!/" />
</SOURCES>
<excluded>
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
</excluded>
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
</library>
</component>

13
examples/.idea/libraries/compile.xml generated Normal file
View file

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="compile">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/compile" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/compile" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
</library>
</component>

14
examples/.idea/libraries/runtime.xml generated Normal file
View file

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="runtime">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/runtime" />
<root url="file://$PROJECT_DIR$/src/main/resources" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
</library>
</component>

14
examples/.idea/libraries/test.xml generated Normal file
View file

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="test">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/src/test/resources" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/test" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
</library>
</component>

27
examples/.idea/misc.xml generated Normal file
View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<pattern value="com.example.ExampleBuild" />
<pattern value="com.example.ExampleBuild" method="javadoc" />
<pattern value="com.example.ExampleBuild" method="dokkaHtml" />
<pattern value="com.example.ExampleBuild" method="dokkaGfm" />
<pattern value="com.example.ExampleBuild" method="dokkaJekyll" />
</component>
<component name="PDMPlugin">
<option name="customRuleSets">
<list>
<option value="K:\java\semver\config\pmd.xml" />
<option value="$PROJECT_DIR$/../../bld-testng/config/pmd.xml" />
<option value="$PROJECT_DIR$/../../bld-checkstyle/config/pmd.xml" />
<option value="$PROJECT_DIR$/../../bld-jacoco-report/config/pmd.xml" />
<option value="$PROJECT_DIR$/../../bld-generated-version/config/pmd.xml" />
<option value="$PROJECT_DIR$/../../bld-pitest/config/pmd.xml" />
<option value="$PROJECT_DIR$/../../bld-exec/config/pmd.xml" />
</list>
</option>
<option name="skipTestSources" value="false" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build" />
</component>
</project>

9
examples/.idea/modules.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.example.ExampleTest" />
<module name="app" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

6
examples/.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

15
examples/.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Tests",
"request": "launch",
"mainClass": "com.example.ExampleBuild",
"args": [
"compile",
"test"
]
}
]
}

15
examples/.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,15 @@
{
"java.project.sourcePaths": [
"src/main/java",
"src/main/resources",
"src/test/java",
"src/test/resources",
"src/bld/java",
"src/bld/resources"
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-1.9.1.jar",
"lib/**/*.jar"
]
}

27
examples/README.md Normal file
View file

@ -0,0 +1,27 @@
## Compile the Example
```console
./bld compile
```
## Run the Example
```console
./bld run
```
## Run the Tests
```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
```

2
examples/bld Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env sh
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.ExampleBuild "$@"

4
examples/bld.bat Normal file
View file

@ -0,0 +1,4 @@
@echo off
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.ExampleBuild %*

Binary file not shown.

View file

@ -0,0 +1,8 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.downloadLocation=
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.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories=
bld.version=1.9.1

View file

@ -0,0 +1,116 @@
package com.example;
import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.extension.CompileKotlinOperation;
import rife.bld.extension.DokkaOperation;
import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat;
import rife.bld.operations.exceptions.ExitStatusException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.compile;
import static rife.bld.dependencies.Scope.test;
public class ExampleBuild extends Project {
public ExampleBuild() {
pkg = "com.example";
name = "Example";
mainClass = "com.example.Example";
version = version(0, 1, 0);
javaRelease = 17;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
final var kotlin = version(2, 0, 0);
scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin));
scope(test)
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)));
// Include the Kotlin source directory when creating or publishing sources Java Archives
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
}
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);
new ExampleBuild().start(args);
}
@BuildCommand(summary = "Compiles the Kotlin project")
@Override
public void compile() throws IOException {
new CompileKotlinOperation()
.fromProject(this)
.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();
}
}

View file

@ -0,0 +1,28 @@
package com.example
/**
* Example class.
*/
class Example {
/**
* Message property.
*/
val message: String
/**
* Returns the message property.
*/
get() = "Hello World!"
/**
* Companion object.
*/
companion object {
/**
* Main function.
*/
@JvmStatic
fun main(args: Array<String>) {
println(Example().message)
}
}
}

View file

@ -0,0 +1,11 @@
package com.example
import kotlin.test.Test
import kotlin.test.assertEquals
class ExampleTest {
@Test
fun verifyHello() {
assertEquals("Hello World!", Example().message)
}
}

BIN
lib/bld/bld-wrapper.jar Normal file

Binary file not shown.

View file

@ -0,0 +1,8 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
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

15
scripts/checkcliargs.sh Executable file
View file

@ -0,0 +1,15 @@
#!/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

13
scripts/cliargs.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
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"

View file

@ -0,0 +1,114 @@
/*
* 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;
import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.publish.PublishDeveloper;
import rife.bld.publish.PublishLicense;
import rife.bld.publish.PublishScm;
import java.util.List;
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.compile;
import static rife.bld.dependencies.Scope.test;
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
public class DokkaOperationBuild extends Project {
public DokkaOperationBuild() {
pkg = "rife.bld.extension";
name = "bld-dokka";
version = version(1, 0, 0, "SNAPSHOT");
javaRelease = 17;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
var dokka = version(1, 9, 20);
scope(compile)
.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("com.uwyn.rife2", "bld", version(1, 9, 1)));
scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)))
.include(dependency("org.assertj", "assertj-core", version(3, 26, 0)));
javadocOperation()
.javadocOptions()
.author()
.docLint(NO_MISSING)
.link("https://rife2.github.io/bld/");
publishOperation()
.repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2"))
.info()
.groupId("com.uwyn.rife2")
.artifactId(name)
.description("bld Dokka Extension")
.url("https://github.com/rife2/bld-dokka")
.developer(
new PublishDeveloper()
.id("ethauvin")
.name("Erik C. Thauvin")
.email("erik@thauvin.net")
.url("https://erik.thauvin.net/")
)
.license(
new PublishLicense()
.name("The Apache License, Version 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0.txt")
)
.scm(
new PublishScm()
.connection("scm:git:https://github.com/rife2/bld-dokka.git")
.developerConnection("scm:git:git@github.com:rife2/bld-dokka.git")
.url("https://github.com/rife2/bld-dokka")
)
.signKey(property("sign.key"))
.signPassphrase(property("sign.passphrase"));
}
public static void main(String[] args) {
new DokkaOperationBuild().start(args);
}
@BuildCommand(summary = "Runs PMD analysis")
public void pmd() {
new PmdOperation()
.fromProject(this)
.failOnViolation(true)
.ruleSets("config/pmd.xml")
.execute();
}
@Override
public void test() throws Exception {
new ExecOperation()
.fromProject(this)
.command("scripts/cliargs.sh")
.execute();
super.test();
}
}

View file

@ -0,0 +1,644 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension;
import rife.bld.BaseProject;
import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat;
import rife.bld.extension.dokka.SourceSet;
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;
/**
* Builds documentation (javadoc, HTML, etc.) using Dokka.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
private final static String GFM_PLUGIN_REGEXP =
"^.*(dokka-base|analysis-kotlin-descriptors|gfm-plugin|freemarker).*\\.jar$";
private final static String HTML_PLUGIN_REGEXP =
"^.*(dokka-base|analysis-kotlin-descriptors|kotlinx-html-jvm|freemarker).*\\.jar$";
private final static String JAVADOC_PLUGIN_REGEXP =
"^.*(dokka-base|analysis-kotlin-descriptors|javadoc-plugin|kotlin-as-java-plugin|korte-jvm).*\\.jar$";
private final static String JEKYLL_PLUGIN_REGEXP =
"^.*(dokka-base|analysis-kotlin-descriptors|jekyll-plugin|gfm-plugin|freemarker).*\\.jar$";
private final Logger LOGGER = Logger.getLogger(DokkaOperation.class.getName());
private final Map<String, String> globalLinks_ = new ConcurrentHashMap<>();
private final Collection<String> globalPackageOptions_ = new ArrayList<>();
private final Collection<String> globalSrcLinks_ = new ArrayList<>();
private final Collection<String> includes_ = new ArrayList<>();
private final Collection<String> pluginsClasspath_ = new ArrayList<>();
private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>();
private boolean delayTemplateSubstitution_;
private boolean failOnWarning_;
private File json;
private LoggingLevel loggingLevel_;
private String moduleName_;
private String moduleVersion_;
private boolean noSuppressObviousFunctions_;
private boolean offlineMode_;
private File outputDir_;
private BaseProject project_;
private SourceSet sourceSet_;
private boolean suppressInheritedMembers_;
// Encodes to JSON adding braces as needed
private static String encodeJson(final String json) {
var sb = new StringBuilder(json);
if (!json.startsWith("{") || !json.endsWith("}")) {
sb.insert(0, "{").append('}');
}
return StringUtils.encodeJson(sb.toString());
}
/**
* Returns the list of JARs contained in a given directory.
*
* @param directory the directory
* @param regex the regular expression to match
* @return the list of JARs
*/
public static List<String> getJarList(File directory, String regex) {
var jars = new ArrayList<String>();
if (directory.isDirectory()) {
var files = directory.listFiles();
if (files != null) {
for (var f : files) {
if (!f.getName().endsWith("-sources.jar") && (!f.getName().endsWith("-javadoc.jar")) &&
f.getName().matches(regex)) {
jars.add(f.getAbsolutePath());
}
}
}
}
return jars;
}
/**
* Determines if the given string is not blank.
*
* @param s the string
* @return {@code true} if not blank, {@code false} otherwise.
*/
public static boolean isNotBlank(String s) {
return s != null && !s.isBlank();
}
/**
* Sets the delay substitution of some elements.
* <p>
* Used in incremental builds of multimodule projects.
*
* @param delayTemplateSubstitution the delay
* @return this operation instance
*/
public DokkaOperation delayTemplateSubstitution(Boolean delayTemplateSubstitution) {
delayTemplateSubstitution_ = delayTemplateSubstitution;
return this;
}
/**
* Part of the {@link #execute execute} operation, constructs the command list to use for building the process.
*
* @since 1.5
*/
@Override
protected List<String> executeConstructProcessCommandList() {
if (project_ == null) {
throw new IllegalArgumentException("A project must be specified.");
}
final List<String> args = new ArrayList<>();
// java
args.add(javaTool());
var cli = getJarList(project_.libBldDirectory(), "^.*dokka-cli.*\\.jar$");
if (cli.size() != 1) {
throw new RuntimeException("The dokka-cli JAR could not be found.");
}
// -jar dokka-cli
args.add("-jar");
args.add(cli.get(0));
// -pluginClasspath
if (!pluginsClasspath_.isEmpty()) {
args.add("-pluginsClasspath");
args.add(String.join(";", pluginsClasspath_));
}
// -sourceSet
var sourceSetArgs = sourceSet_.args();
if (sourceSetArgs.isEmpty()) {
throw new IllegalArgumentException("At least one sourceSet is required.");
} else {
args.add("-sourceSet");
args.add(String.join(" ", sourceSet_.args()));
}
// -outputDir
if (outputDir_ != null) {
if (!outputDir_.exists() && !outputDir_.mkdirs()) {
throw new RuntimeException("Could not create: " + outputDir_.getAbsolutePath());
}
args.add("-outputDir");
args.add(outputDir_.getAbsolutePath());
}
// -delayTemplateSubstitution
if (delayTemplateSubstitution_) {
args.add("-delayTemplateSubstitution");
}
// -failOnWarning
if (failOnWarning_) {
args.add("-failOnWarning");
}
// -globalLinks_
if (!globalLinks_.isEmpty()) {
args.add("-globalLinks");
var links = new ArrayList<String>();
globalLinks_.forEach((k, v) ->
links.add(String.format("%s^%s", k, v)));
args.add(String.join("^^", links));
}
// -globalPackageOptions
if (!globalPackageOptions_.isEmpty()) {
args.add("-globalPackageOptions");
args.add(String.join(";", globalPackageOptions_));
}
// -globalSrcLinks
if (!globalSrcLinks_.isEmpty()) {
args.add("-globalSrcLinks_");
args.add(String.join(";", globalSrcLinks_));
}
// -includes
if (!includes_.isEmpty()) {
args.add("-includes");
args.add(String.join(";", includes_));
}
// -loggingLevel
if (loggingLevel_ != null) {
args.add("-loggingLevel");
args.add(loggingLevel_.name().toLowerCase());
}
// -moduleName
if (isNotBlank(moduleName_)) {
args.add("-moduleName");
args.add(moduleName_);
}
// -moduleVersion
if (isNotBlank(moduleVersion_)) {
args.add("-moduleVersion");
args.add(moduleVersion_);
}
// -noSuppressObviousFunctions
if (noSuppressObviousFunctions_) {
args.add("-noSuppressObviousFunctions");
}
// -offlineMode
if (offlineMode_) {
args.add("-offlineMode");
}
// -pluginConfiguration
if (!pluginsConfiguration_.isEmpty()) {
args.add("-pluginsConfiguration");
var confs = new ArrayList<String>();
pluginsConfiguration_.forEach((k, v) ->
confs.add(String.format("%s=%s", encodeJson(k), encodeJson(v))));
args.add(String.join("^^", confs));
}
// -suppressInheritedMembers
if (suppressInheritedMembers_) {
args.add("-suppressInheritedMembers");
}
// json
if (json != null) {
args.add(json.getAbsolutePath());
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine(String.join(" ", args));
}
return args;
}
/**
* Configures the operation from a {@link BaseProject}.
* <p>
* Sets the {@link #sourceSet sourceSet}, {@link SourceSet#jdkVersion jdkVersion}, {@link #moduleName moduleName}
* and {@link SourceSet#classpath(String...) classpath} from the project.
*
* @param project the project to configure the operation from
*/
@Override
public DokkaOperation fromProject(BaseProject project) {
project_ = project;
sourceSet_ = new SourceSet()
.src(new File(project.srcMainDirectory(), "kotlin").getAbsolutePath())
.classpath(project.compileClasspathJars())
.classpath(project.providedClasspathJars());
if (project.javaRelease() != null) {
sourceSet_ = sourceSet_.jdkVersion(project.javaRelease());
}
moduleName_ = project.name();
return this;
}
/**
* Sets whether to fail documentation generation if Dokka has emitted a warning or an error.
* <p>
* Whether to fail documentation generation if Dokka has emitted a warning or an error. The process waits until all
* errors and warnings have been emitted first.
* <p>
* This setting works well with {@link SourceSet#reportUndocumented}
*
* @param failOnWarning {@code true} or {@code false}
* @return this operation instance
*/
public DokkaOperation failOnWarning(Boolean failOnWarning) {
failOnWarning_ = failOnWarning;
return this;
}
/**
* Set the global external documentation links.
*
* @param url the external documentation URL
* @param packageListUrl the external documentation package list URL
* @return this operation instance
*/
public DokkaOperation globalLinks(String url, String packageListUrl) {
globalLinks_.put(url, packageListUrl);
return this;
}
/**
* Set the global external documentation links.
*
* @param globalLinks the map of global links
* @return this operation instance
* @see #globalSrcLink(String...) #globalSrcLink(String...)#globalSrcLink(String...)
*/
public DokkaOperation globalLinks(Map<String, String> globalLinks) {
globalLinks_.putAll(globalLinks);
return this;
}
/**
* Sets the global list of package configurations.
* <p>
* Using format:
* <ul>
* <li>matchingRegexp</li>
* <li>-deprecated</li>
* <li>-privateApi</li>
* <li>+warnUndocumented</li>
* <li>+suppress</li>
* <li>+visibility:PUBLIC</li>
* <li>...</li>
* </ul>
*
* @param options ome pr more package configurations
* @return this operation instance
*/
public DokkaOperation globalPackageOptions(String... options) {
Collections.addAll(globalPackageOptions_, options);
return this;
}
/**
* Sets the global list of package configurations.
* <p>
* Using format:
* <ul>
* <li>matchingRegexp</li>
* <li>-deprecated</li>
* <li>-privateApi</li>
* <li>+warnUndocumented</li>
* <li>+suppress</li>
* <li>+visibility:PUBLIC</li>
* <li>...</li>
* </ul>
*
* @param options the list of package configurations
* @return this operation instance
*/
public DokkaOperation globalPackageOptions(Collection<String> options) {
globalPackageOptions_.addAll(options);
return this;
}
/**
* Sets the global mapping between a source directory and a Web service for browsing the code.
*
* @param links one or more links mapping
* @return this operation instance
*/
public DokkaOperation globalSrcLink(String... links) {
Collections.addAll(globalSrcLinks_, links);
return this;
}
/**
* Sets the global mapping between a source directory and a Web service for browsing the code.
*
* @param links the links mapping
* @return this operation instance
*/
public DokkaOperation globalSrcLink(Collection<String> links) {
globalSrcLinks_.addAll(links);
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* This can be configured on per-package basis.
*
* @param files one or more files
* @return this operation instance
*/
public DokkaOperation includes(String... files) {
Collections.addAll(includes_, files);
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* The contents of specified files are parsed and embedded into documentation as module and package descriptions.
* <p>
* This can be configured on per-package basis.
*
* @param files the list of files
* @return this operation instance
*/
public DokkaOperation includes(Collection<String> files) {
includes_.addAll(files);
return this;
}
/**
* JSON configuration file path.
*
* @param configuration the configuration file path
*/
public DokkaOperation json(File configuration) {
json = configuration;
return this;
}
/**
* Sets the logging level.
*
* @param loggingLevel the logging level
* @return this operation instance
*/
public DokkaOperation loggingLevel(LoggingLevel loggingLevel) {
loggingLevel_ = loggingLevel;
return this;
}
/**
* Sets the name of the project/module. Default is {@code root}.
* <p>
* The display name used to refer to the module. It is used for the table of contents, navigation, logging, etc.
*
* @param moduleName the project/module name
* @return this operation instance
*/
public DokkaOperation moduleName(String moduleName) {
moduleName_ = moduleName;
return this;
}
/**
* Set the documented version.
*
* @param version the version
* @return this operation instance
*/
public DokkaOperation moduleVersion(String version) {
moduleVersion_ = version;
return this;
}
/**
* Sets whether to suppress obvious functions such as inherited from
* <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/">kotlin.Any</a> and {@link java.lang.Object}.
* <p>
* A function is considered to be obvious if it is:
* <ul>
* <li>Inherited from <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/">kotlin.Any</a>,
* <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/">Kotlin.Enum</a>, {@link java.lang.Object}
* or {@link java.lang.Enum}, such as {@code equals}, {@code hashCode}, {@code toString}.
* <li>Synthetic (generated by the compiler) and does not have any documentation, such as
* {@code dataClass.componentN} or {@code dataClass.copy}.
* </ul>
*
* @param noSuppressObviousFunctions {@code true} or {@code false}
* @return this operation instance
*/
public DokkaOperation noSuppressObviousFunctions(Boolean noSuppressObviousFunctions) {
noSuppressObviousFunctions_ = noSuppressObviousFunctions;
return this;
}
/**
* Sets whether to resolve remote files/links over network.
* <p>
* This includes package-lists used for generating external documentation links. For example, to make classes from
* the standard library clickable.
* <p>
* Setting this to true can significantly speed up build times in certain cases, but can also worsen documentation
* quality and user experience. For example, by not resolving class/member links from your dependencies, including
* the standard library.
* <p>
* Note: You can cache fetched files locally and provide them to Dokka as local paths.
*
* @param offlineMode the offline mode
* @return this operation instance
* @see SourceSet#externalDocumentationLinks(String, String)
*/
public DokkaOperation offlineMode(Boolean offlineMode) {
offlineMode_ = offlineMode;
return this;
}
/**
* Sets the output directory path, {@code ./dokka} by default.
* <p>
* The directory to where documentation is generated, regardless of output format.
*
* @param outputDir the output directory
* @return this operation instance
*/
public DokkaOperation outputDir(File outputDir) {
outputDir_ = outputDir;
return this;
}
/**
* Sets the output directory path, {@code ./dokka} by default.
* <p>
* The directory to where documentation is generated, regardless of output format.
*
* @param outputDir the output directory
* @return this operation instance
*/
public DokkaOperation outputDir(String outputDir) {
outputDir_ = new File(outputDir);
return this;
}
/**
* Sets the Dokka {@link OutputFormat output format}.
*
* @param format The {@link OutputFormat output format}
* @return this operation instance
*/
public DokkaOperation outputFormat(OutputFormat format) {
pluginsClasspath_.clear();
if (format.equals(OutputFormat.JAVADOC)) {
pluginsClasspath_.addAll(getJarList(project_.libBldDirectory(),
JAVADOC_PLUGIN_REGEXP));
} else if (format.equals(OutputFormat.HTML)) {
pluginsClasspath_.addAll(getJarList(project_.libBldDirectory(),
HTML_PLUGIN_REGEXP));
} else if (format.equals(OutputFormat.MARKDOWN)) {
pluginsClasspath_.addAll(getJarList(project_.libBldDirectory(),
GFM_PLUGIN_REGEXP));
} else if (format.equals(OutputFormat.JEKYLL)) {
pluginsClasspath_.addAll(getJarList(project_.libBldDirectory(),
JEKYLL_PLUGIN_REGEXP));
}
return this;
}
/**
* Sets the configuration for Dokka plugins.
*
* @param name The fully-qualified plugin name
* @param jsonConfiguration The plugin JSON configuration
* @return this operation instance
*/
public DokkaOperation pluginConfigurations(String name, String jsonConfiguration) {
pluginsConfiguration_.put(name, jsonConfiguration);
return this;
}
/**
* Sets the configuration for Dokka plugins.
*
* @param pluginConfiguratione the map of configurations
* @return this operation instance
* @see #pluginConfigurations(String, String)
*/
public DokkaOperation pluginConfigurations(Map<String, String> pluginConfiguratione) {
pluginsConfiguration_.putAll(pluginConfiguratione);
return this;
}
/**
* Sets the list of jars with Dokka plugins and their dependencies.
*
* @param jars one or more jars
* @return this operation instance
*/
public DokkaOperation pluginsClasspath(String... jars) {
Collections.addAll(pluginsClasspath_, jars);
return this;
}
/**
* Sets the list of jars with Dokka plugins and their dependencies.
*
* @param jars the list of jars
* @return this operation instance
*/
public DokkaOperation pluginsClasspath(Collection<String> jars) {
pluginsClasspath_.addAll(jars);
return this;
}
/**
* Clears the list of Dokka plugins.
*
* @param clear set to clear the list
* @return this operation instance
*/
public DokkaOperation pluginsClasspath(boolean clear) {
if (clear) {
pluginsClasspath_.clear();
}
return this;
}
/**
* Sets the configurations for a source set.
* <p>
* Individual and additional configuration of Kotlin source sets.
*
* @param sourceSet the source set configurations
* @return this operation instance
*/
public DokkaOperation sourceSet(SourceSet sourceSet) {
sourceSet_ = sourceSet;
return this;
}
/**
* Sets whether to suppress inherited members that aren't explicitly overridden in a given class.
*
* @param suppressInheritedMembers {@code true} or {@code false}
* @return this operation instance
*/
public DokkaOperation suppressInheritedMembers(Boolean suppressInheritedMembers) {
suppressInheritedMembers_ = suppressInheritedMembers;
return this;
}
}

View file

@ -0,0 +1,27 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension.dokka;
/**
* Dokka's analysis platforms.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
public enum AnalysisPlatform {
JVM, JS, NATIVE, COMMON, ANDROID
}

View file

@ -0,0 +1,27 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension.dokka;
/**
* Dokka documented visibilities.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
public enum DocumentedVisibility {
PUBLIC, PRIVATE, PROTECTED, INTERNAL, PACKAGE
}

View file

@ -0,0 +1,27 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension.dokka;
/**
* Dokka logging levels.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
public enum LoggingLevel {
DEBUG, PROGRESS, INFO, WARN, ERROR
}

View file

@ -0,0 +1,27 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension.dokka;
/**
* Dokka output formats.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
public enum OutputFormat {
JAVADOC, JEKYLL, HTML, MARKDOWN
}

View file

@ -0,0 +1,682 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension.dokka;
import rife.bld.extension.DokkaOperation;
import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* Configuration for a Dokka source set.
*
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @since 1.0
*/
public class SourceSet {
private static final String SEMICOLON = ";";
private final Collection<String> classpath_ = new ArrayList<>();
private final Map<String, String> dependentSourceSets_ = new ConcurrentHashMap<>();
private final Collection<DocumentedVisibility> documentedVisibilities_ = new ArrayList<>();
private final Map<String, String> externalDocumentationLinks_ = new ConcurrentHashMap<>();
private final Collection<String> includes_ = new ArrayList<>();
private final Collection<String> perPackageOptions_ = new ArrayList<>();
private final Collection<String> samples_ = new ArrayList<>();
private final Map<String, String> srcLinks_ = new ConcurrentHashMap<>();
private final Collection<String> src_ = new ArrayList<>();
private final Collection<String> suppressedFiles_ = new ArrayList<>();
private AnalysisPlatform analysisPlatform_;
private String apiVersion_;
private String displayName_;
private String jdkVersion_;
private String languageVersion_;
private boolean noJdkLink_;
private boolean noSkipEmptyPackages_;
private boolean noStdlibLink_;
private boolean reportUndocumented_;
private boolean skipDeprecated_;
private String sourceSetName_;
/**
* Sets the platform used for setting up analysis. Default is {@link AnalysisPlatform#JVM JVM}
* <p>
* Platform to be used for setting up code analysis and {@code @sample} environment.
*
* @param analysisPlatform the analysis platform
* @return this operation instance
*/
public SourceSet analysisPlatform(AnalysisPlatform analysisPlatform) {
analysisPlatform_ = analysisPlatform;
return this;
}
/**
* Sets the Kotlin API version used for setting up analysis and samples.
*
* @param apiVersion the api version
* @return this operation instance
*/
public SourceSet apiVersion(String apiVersion) {
apiVersion_ = apiVersion;
return this;
}
/**
* Sets the Kotlin API version used for setting up analysis and samples.
*
* @param apiVersion the api version
* @return this operation instance
*/
public SourceSet apiVersion(int apiVersion) {
apiVersion_ = String.valueOf(apiVersion);
return this;
}
/**
* Returns the formatted arguments.
*
* @return the arguments
*/
public List<String> args() {
var args = new ArrayList<String>();
// -analysisPlatform
if (analysisPlatform_ != null) {
args.add("-analysisPlatform");
args.add(analysisPlatform_.name().toLowerCase());
}
// -apiVersion
if (apiVersion_ != null) {
args.add("-apiVersion");
args.add(apiVersion_);
}
// -classpath
if (!classpath_.isEmpty()) {
args.add("-classpath");
args.add(String.join(SEMICOLON, classpath_));
}
// -dependentSourceSets
if (!dependentSourceSets_.isEmpty()) {
args.add("-dependentSourceSets");
var deps = new ArrayList<String>();
dependentSourceSets_.forEach((k, v) -> deps.add(String.format("%s/%s", k, v)));
args.add(String.join(SEMICOLON, deps));
}
// -displayName
if (displayName_ != null) {
args.add("-displayName");
args.add(displayName_);
}
// -documentedVisibilities
if (!documentedVisibilities_.isEmpty()) {
args.add("-documentedVisibilities");
var vis = new ArrayList<String>();
documentedVisibilities_.forEach(d -> vis.add(d.name().toLowerCase()));
args.add(String.join(SEMICOLON, vis));
}
// -externalDocumentationLinks
if (!externalDocumentationLinks_.isEmpty()) {
args.add("-externalDocumentationLinks");
var links = new ArrayList<String>();
externalDocumentationLinks_.forEach((k, v) -> links.add(String.format("%s^%s", k, v)));
args.add(String.join("^^", links));
}
// -jdkVersion
if (jdkVersion_ != null) {
args.add("-jdkVersion");
args.add(jdkVersion_);
}
// -includes
if (!includes_.isEmpty()) {
args.add("-includes");
args.add(String.join(SEMICOLON, includes_));
}
// -languageVersion
if (languageVersion_ != null) {
args.add("-languageVersion");
args.add(languageVersion_);
}
// -noJdkLink
if (noJdkLink_) {
args.add("-noJdkLink");
args.add(String.valueOf(noJdkLink_));
}
// -noSkipEmptyPackages
if (noSkipEmptyPackages_) {
args.add("-noSkipEmptyPackages");
args.add(String.valueOf(noSkipEmptyPackages_));
}
// -noStdlibLink
if (noStdlibLink_) {
args.add("-noStdlibLink");
args.add(String.valueOf(noStdlibLink_));
}
// -reportUndocumented
if (reportUndocumented_) {
args.add("-reportUndocumented");
args.add(String.valueOf(reportUndocumented_));
}
// -perPackageOptions
if (!perPackageOptions_.isEmpty()) {
args.add("-perPackageOptions");
args.add(String.join(SEMICOLON, perPackageOptions_));
}
// -samples
if (!samples_.isEmpty()) {
args.add("-samples");
args.add(String.join(SEMICOLON, samples_));
}
// -skipDeprecated
if (skipDeprecated_) {
args.add("-skipDeprecated");
args.add(String.valueOf(skipDeprecated_));
}
// -src
if (!src_.isEmpty()) {
args.add("-src");
args.add(String.join(SEMICOLON, src_));
}
// -srcLink
if (!srcLinks_.isEmpty()) {
args.add("-srcLink");
var links = new ArrayList<String>();
srcLinks_.forEach((k, v) -> links.add(String.format("%s=%s", k, v)));
args.add(String.join(SEMICOLON, links));
}
// -sourceSetName
if (sourceSetName_ != null) {
args.add("-sourceSetName");
args.add(sourceSetName_);
}
// -suppressedFiles
if (!suppressedFiles_.isEmpty()) {
args.add("-suppressedFiles");
args.add(String.join(SEMICOLON, suppressedFiles_));
}
return args;
}
/**
* Sets classpath for analysis and interactive samples.
* <p>
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
* <p>
* This option accepts both {@code .jar} and {@code .klib} files.
*
* @param files one or more file
* @return this operation instance
*/
public SourceSet classpath(String... files) {
Collections.addAll(classpath_, files);
return this;
}
/**
* Sets classpath for analysis and interactive samples.
* <p>
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
* <p>
* This option accepts both {@code .jar} and {@code .klib} files.
*
* @param files the list of files
* @return this operation instance
*/
public SourceSet classpath(Collection<String> files) {
classpath_.addAll(files);
return this;
}
/**
* Sets classpath for analysis and interactive samples.
* <p>
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
* <p>
* This option accepts both {@code .jar} and {@code .klib} files.
*
* @param files the list of files
* @return this operation instance
*/
public SourceSet classpath(List<File> files) {
files.forEach(it -> classpath_.add(it.getAbsolutePath()));
return this;
}
/**
* Sets the names of dependent source sets.
*
* @param moduleName the module name
* @param sourceSetName the source set name
* @return this operation instance
*/
public SourceSet dependentSourceSets(String moduleName, String sourceSetName) {
dependentSourceSets_.put(moduleName, sourceSetName);
return this;
}
/**
* Sets the names of dependent source sets.
*
* @param dependentSourceSets the map of dependent source set names
* @return this operation instance
* @see #dependentSourceSets(String, String)
*/
public SourceSet dependentSourceSets(Map<String, String> dependentSourceSets) {
dependentSourceSets_.putAll(dependentSourceSets);
return this;
}
/**
* Sets the display name of the source set, used both internally and externally.
* <p>
* The name is used both externally (for example, the source set name is visible to documentation readers) and
* internally (for example, for logging messages of {@link #reportUndocumented reportUndocumented}).
* <p>
* The platform name can be used if you don't have a better alternative.
*
* @param displayName the display name
* @return this operation instance
*/
public SourceSet displayName(String displayName) {
displayName_ = displayName;
return this;
}
/**
* Sets visibilities to be documented.
* <p>
* This can be used if you want to document protected/internal/private declarations, as well as if you want to
* exclude public declarations and only document internal API.
* <p>
* This can be configured on per-package basis.
*
* @param visibilities one or more visibilities
* @return this operation instance
*/
public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) {
documentedVisibilities_.addAll(Arrays.asList(visibilities));
return this;
}
/**
* Sets the external documentation links.
* <p>
* A set of parameters for external documentation links that is applied only for this source set.
*
* @param url the external documentation URL
* @param packageListUrl the external documentation package list URL
* @return this operation instance
*/
public SourceSet externalDocumentationLinks(String url, String packageListUrl) {
externalDocumentationLinks_.put(url, packageListUrl);
return this;
}
/**
* Sets the external documentation links.
* <p>
* A set of parameters for external documentation links that is applied only for this source set.
*
* @param externalDocumentationLinks the map of external documentation links
* @return this operation instance
* @see #externalDocumentationLinks(String, String)
*/
public SourceSet externalDocumentationLinks(Map<String, String> externalDocumentationLinks) {
externalDocumentationLinks_.putAll(externalDocumentationLinks);
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* A list of Markdown files that contain module and package documentation.
* <p>
* The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions.
*
* @param files one or more files
* @return this operation instance
*/
public SourceSet includes(String... files) {
Collections.addAll(includes_, files);
return this;
}
/**
* Sets the Markdown files that contain module and package documentation.
* <p>
* A list of Markdown files that contain module and package documentation.
* <p>
* The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions.
*
* @param files the list of files
* @return this operation instance
*/
public SourceSet includes(Collection<String> files) {
includes_.addAll(files);
return this;
}
/**
* Sets the version of JDK to use for linking to JDK Javadocs.
* <p>
* The JDK version to use when generating external documentation links for Java types.
* <p>
* For example, if you use {@link java.util.UUID} in some public declaration signature, and this option is set to 8,
* Dokka generates an external documentation link to JDK 8 Javadocs for it.
*
* @param jdkVersion the JDK version
* @return this operation instance
*/
public SourceSet jdkVersion(String jdkVersion) {
jdkVersion_ = jdkVersion;
return this;
}
/**
* Sets the version of JDK to use for linking to JDK Javadocs.
* <p>
* The JDK version to use when generating external documentation links for Java types.
* <p>
* For example, if you use {@link java.util.UUID} in some public declaration signature, and this option is set to 8,
* Dokka generates an external documentation link to JDK 8 Javadocs for it.
*
* @param jdkVersion the JDK version
* @return this operation instance
*/
public SourceSet jdkVersion(int jdkVersion) {
jdkVersion_ = String.valueOf(jdkVersion);
return this;
}
/**
* Sets the language version used for setting up analysis and samples.
*
* @param languageVersion the language version
* @return this operation instance
*/
public SourceSet languageVersion(String languageVersion) {
languageVersion_ = languageVersion;
return this;
}
/**
* Sets the language version used for setting up analysis and samples.
*
* @param languageVersion the language version
* @return this operation instance
*/
public SourceSet languageVersion(int languageVersion) {
languageVersion_ = String.valueOf(languageVersion);
return this;
}
/**
* Sets whether to generate links to JDK Javadocs.
* <p>
* Whether to generate external documentation links to JDK's Javadocs.
* <p>
* The version of JDK Javadocs is determined by the {@link #jdkVersion jdkVersion} option.
* <p>
* Note: Links are generated when noJdkLink is set to false.
*
* @param noJdkLink {@code true} or {@code false}
* @return this operation instance
*/
public SourceSet noJdkLink(Boolean noJdkLink) {
noJdkLink_ = noJdkLink;
return this;
}
/**
* Sets whether to create pages for empty packages.
* <p>
* Whether to skip packages that contain no visible declarations after various filters have been applied.
*
* @param noSkipEmptyPackages {@code true} or {@code false}
* @return this operation instance
*/
public SourceSet noSkipEmptyPackages(boolean noSkipEmptyPackages) {
noSkipEmptyPackages_ = noSkipEmptyPackages;
return this;
}
/**
* Sets whether to generate links to Standard library.
* <p>
* Whether to generate external documentation links that lead to the API reference documentation of Kotlin's
* standard library.
* <p>
* Note: Links are generated when noStdLibLink is set to {@code false}.
*
* @param noStdlibLink {@code true} or {@code false}
* @return this operation instance
*/
public SourceSet noStdlibLink(Boolean noStdlibLink) {
noStdlibLink_ = noStdlibLink;
return this;
}
/**
* Set the list of package source set configuration.
* <p>
* A set of parameters specific to matched packages within this source set.
* <p>
* Using format:
* <ul>
* <li>matchingRegexp</li>
* <li>-deprecated</li>
* <li>-privateApi</li>
* <li>+warnUndocumented</li>
* <li>+suppress</li>
* <li>+visibility:PUBLIC</li>
* <li>...</li>
* </ul>
*
* @param perPackageOptions the list of per package options
* @return this operation instance
*/
public SourceSet perPackageOptions(Collection<String> perPackageOptions) {
perPackageOptions_.addAll(perPackageOptions);
return this;
}
/**
* Set the list of package source set configuration.
* <p>
* A set of parameters specific to matched packages within this source set.
* <p>
* Using format:
* <ul>
* <li>matchingRegexp</li>
* <li>-deprecated</li>
* <li>-privateApi</li>
* <li>+warnUndocumented</li>
* <li>+suppress</li>
* <li>+visibility:PUBLIC</li>
* <li>...</li>
* </ul>
*
* @param perPackageOptions the list of per package options
* @return this operation instance
*/
public SourceSet perPackageOptions(String... perPackageOptions) {
Collections.addAll(perPackageOptions_, perPackageOptions);
return this;
}
/**
* Sets whether to report undocumented declarations.
* <p>
* Whether to emit warnings about visible undocumented declarations, that is declarations without KDocs after they
* have been filtered by documentedVisibilities and other filters.
* <p>
* This setting works well with {@link DokkaOperation#failOnWarning}.
* <p>
* This can be configured on per-package basis.
*
* @param reportUndocumented {@code true} or {@code false}
* @return this operation instance
*/
public SourceSet reportUndocumented(Boolean reportUndocumented) {
reportUndocumented_ = reportUndocumented;
return this;
}
/**
* Set the list of directories or files that contain sample functions.
* <p>
* A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc
* tag.
*
* @param samples the list of samples
* @return this operation instance
*/
public SourceSet samples(Collection<String> samples) {
samples_.addAll(samples);
return this;
}
/**
* Set the list of directories or files that contain sample functions.
* <p>
* A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc
* tag.
*
* @param samples nne or more samples
* @return this operation instance
*/
public SourceSet samples(String... samples) {
Collections.addAll(samples_, samples);
return this;
}
/**
* Sets whether to skip deprecated declarations.
* <p>
* Whether to document declarations annotated with {@code @Deprecated}.
* <p>
* This can be configured on per-package basis.
*
* @param skipDeprecated {@code true} or {@code false}
* @return this operation instance
*/
public SourceSet skipDeprecated(boolean skipDeprecated) {
skipDeprecated_ = skipDeprecated;
return this;
}
/**
* Sets the name of the source set. Default is {@code main}.
*
* @param sourceSetName the source set name.
* @return this operation instance
*/
public SourceSet sourceSetName(String sourceSetName) {
sourceSetName_ = sourceSetName;
return this;
}
/**
* Sets the source code roots to be analyzed and documented.
* <p>
* The source code roots to be analyzed and documented. Acceptable inputs are directories and individual
* {@code .kt} / {@code .java} files.
*
* @param src the list of source code roots
* @return this operation instance
*/
public SourceSet src(Collection<String> src) {
src_.addAll(src);
return this;
}
/**
* Sets the source code roots to be analyzed and documented.
* <p>
* The source code roots to be analyzed and documented. Acceptable inputs are directories and individual
* {@code .kt} / {@code .java} files.
*
* @param src pne ore moe source code roots
* @return this operation instance
*/
public SourceSet src(String... src) {
Collections.addAll(src_, src);
return this;
}
/**
* Sets the mapping between a source directory and a Web service for browsing the code.
*
* @param srcPath the source path
* @param remotePath the remote path
* @param lineSuffix the line suffix
* @return this operation instance
*/
public SourceSet srcLink(String srcPath, String remotePath, String lineSuffix) {
srcLinks_.put(srcPath, remotePath + lineSuffix);
return this;
}
/**
* Sets the paths to files to be suppressed.
* <p>
* The files to be suppressed when generating documentation.
*
* @param suppressedFiles the list of suppressed files
* @return this operation instance
*/
public SourceSet suppressedFiles(Collection<String> suppressedFiles) {
suppressedFiles_.addAll(suppressedFiles);
return this;
}
/**
* Sets the paths to files to be suppressed.
* <p>
* The files to be suppressed when generating documentation.
*
* @param suppressedFiles one or moe suppressed files
* @return this operation instance
*/
public SourceSet suppressedFiles(String... suppressedFiles) {
suppressedFiles_.addAll(Arrays.asList(suppressedFiles));
return this;
}
}

View file

@ -0,0 +1,126 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension;
import org.junit.jupiter.api.Test;
import rife.bld.blueprints.BaseProjectBlueprint;
import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat;
import rife.bld.extension.dokka.SourceSet;
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));
}
});
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright 2023-Copyright $today.yearamp;#36;today.year the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rife.bld.extension;
import org.junit.jupiter.api.Test;
import rife.bld.extension.dokka.AnalysisPlatform;
import rife.bld.extension.dokka.DocumentedVisibility;
import rife.bld.extension.dokka.SourceSet;
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)));
}
}

View file

@ -0,0 +1,16 @@
-delayTemplateSubstitution
-failOnWarning
-globalLinks
-globalPackageOptions
-globalSrcLink
-includes
-loggingLevel
-moduleName
-moduleVersion
-noSuppressObviousFunctions
-offlineMode
-outputDir
-pluginsClasspath
-pluginsConfiguration
-sourceSet
-suppressInheritedMembers

View file

@ -0,0 +1,21 @@
-analysisPlatform
-apiVersion
-classpath
-dependentSourceSets
-displayName
-documentedVisibilities
-externalDocumentationLinks
-includes
-jdkVersion
-languageVersion
-noJdkLink
-noSkipEmptyPackages
-noStdlibLink
-perPackageOptions
-reportUndocumented
-samples
-skipDeprecated
-sourceSetName
-src
-srcLink
-suppressedFiles