Compare commits
130 commits
Author | SHA1 | Date | |
---|---|---|---|
574205d548 | |||
9c633116dc | |||
dfa9a6124e | |||
23a97601db | |||
2a406feb15 | |||
5a3c77a162 | |||
852e24bc18 | |||
8e2415eda4 | |||
bf82ea1920 | |||
b0ad8ad056 | |||
b5b6b40564 | |||
74a180e6fd | |||
0990e82f04 | |||
dc5b81e366 | |||
5d78963f1d | |||
e32ebf19d6 | |||
96b8139b97 | |||
a7a9b10f97 | |||
f4ff095297 | |||
8251473b05 | |||
bef5aed2e3 | |||
a2a5f284b6 | |||
b0d6a3ac3b | |||
125e9f7327 | |||
3a012bf012 | |||
a21938f7b5 | |||
b8927615ec | |||
e7d0ada68c | |||
a57ae52a1c | |||
9fcc5cc362 | |||
54228e3149 | |||
5ca06f4d81 | |||
779e6d4b79 | |||
3c5b1fde8f | |||
832447771d | |||
48c896f0df | |||
31e4208d7f | |||
d8c1049990 | |||
0f6385e3f3 | |||
323f96b54b | |||
048efcb810 | |||
80f00b41ed | |||
3a1ad6ae66 | |||
8dda26e7ef | |||
00299f685c | |||
b59f53ba8a | |||
21744cf2c8 | |||
e1eb395012 | |||
5d66266fa9 | |||
316390264e | |||
3d87280f9c | |||
0f6d190cc6 | |||
325599575c | |||
86d7351fec | |||
0572b64aed | |||
454ca22536 | |||
fb793e254a | |||
d658bcf0c4 | |||
fbaa0264e1 | |||
53df02fa71 | |||
6305dd3de4 | |||
fe46c87334 | |||
0aea2095cc | |||
6a508f1f68 | |||
09c324c8de | |||
27bc3a0997 | |||
61623728ff | |||
1b08f43392 | |||
a52ee51998 | |||
c1565e784b | |||
a1ded46894 | |||
9cda1e132f | |||
01b82ca71d | |||
0d26e700e3 | |||
5a069c315b | |||
6d7266c483 | |||
c51f7e0fa2 | |||
e5970bca18 | |||
7f3fc6ff95 | |||
53681aa2ba | |||
a1a2b2c16f | |||
60deb0f14d | |||
6fa3bdefdb | |||
c84019de2c | |||
1ad14d56c7 | |||
5de764b4b8 | |||
c952b980bb | |||
c901065b3a | |||
c54672a7a0 | |||
c595632732 | |||
c151a49935 | |||
19d662a81f | |||
2d754ffe64 | |||
41e60f606a | |||
dcc68afdf3 | |||
8d34f37af0 | |||
1623b902f9 | |||
b4c8952538 | |||
81ab2e829c | |||
b42190d9cf | |||
f363e7dcce | |||
749f43b6b2 | |||
1bdbe86519 | |||
10fd25ebf6 | |||
9de0095fbd | |||
e82810eaed | |||
6f5d20b2c0 | |||
d2560125d7 | |||
deb66a2d20 | |||
3a5f4f04bd | |||
9548f6150f | |||
9c99532298 | |||
79bce70680 | |||
01a41e0d46 | |||
37cdfd363d | |||
f8e4354e35 | |||
84c2474ffc | |||
cdf6294b39 | |||
619aa1fb9b | |||
cb072c3a87 | |||
18a1d40695 | |||
f5712972f1 | |||
ad7ddabe3b | |||
8fb0202e90 | |||
bafa4f4d74 | |||
b1592bc7c7 | |||
771b8bd464 | |||
719467f6bc | |||
4b9ab05cff | |||
36beda3fb3 |
56 changed files with 3160 additions and 2648 deletions
37
.github/workflows/bld.yml
vendored
37
.github/workflows/bld.yml
vendored
|
@ -4,47 +4,36 @@ on: [ push, pull_request, workflow_dispatch ]
|
|||
|
||||
jobs:
|
||||
build-bld-project:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
java-version: [ 17, 20 ]
|
||||
java-version: [ 17, 21, 24 ]
|
||||
kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ]
|
||||
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout source repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK ${{ matrix.java-version }}
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
distribution: "zulu"
|
||||
java-version: ${{ matrix.java-version }}
|
||||
|
||||
- name: Download the examples dependencies
|
||||
- name: Download dependencies [examples]
|
||||
working-directory: examples
|
||||
run: |
|
||||
chmod +x bld
|
||||
./bld download
|
||||
run: ./bld download
|
||||
|
||||
- name: Run examples tests
|
||||
- name: Run tests [examples]
|
||||
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
|
||||
- name: Download dependencies
|
||||
run: ./bld download
|
||||
|
||||
- name: Run tests
|
||||
run: ./bld compile pmd test
|
||||
run: ./bld compile test
|
14
.github/workflows/pages.yml
vendored
14
.github/workflows/pages.yml
vendored
|
@ -3,7 +3,7 @@ name: javadocs-pages
|
|||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["main"]
|
||||
branches: [ "main" ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
@ -30,14 +30,14 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout source repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
distribution: "zulu"
|
||||
java-version: 17
|
||||
|
||||
- name: Build Javadocs
|
||||
|
@ -47,11 +47,11 @@ jobs:
|
|||
uses: actions/configure-pages@v3
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
# Upload generated Javadocs repository
|
||||
path: 'build/javadoc/'
|
||||
path: "build/javadoc/"
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
||||
uses: actions/deploy-pages@v4
|
||||
|
|
6
.idea/bld.xml
generated
Normal file
6
.idea/bld.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BldConfiguration">
|
||||
<events />
|
||||
</component>
|
||||
</project>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Erik's Code Style" />
|
||||
</state>
|
||||
</component>
|
2
.idea/copyright/Apache_License.xml
generated
2
.idea/copyright/Apache_License.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="Copyright 2023-Copyright &#36;today.yearamp;#36;today.year the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." />
|
||||
<option name="notice" value="Copyright 2023-&#36;today.year the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." />
|
||||
<option name="myName" value="Apache License" />
|
||||
</copyright>
|
||||
</component>
|
13
.idea/icon.svg
generated
Normal file
13
.idea/icon.svg
generated
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 179 108" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(1,0,0,1,-210.511,-96.3382)">
|
||||
<g transform="matrix(1,0,0,1,-23.3386,-649.816)">
|
||||
<g transform="matrix(0.221288,0,0,0.24,73.9536,390.254)">
|
||||
<path d="M722.568,1482.92L722.568,1921.1L808.968,1921.1L808.968,1888.7C822.168,1907.9 846.168,1930.1 893.568,1930.1C933.168,1930.1 961.968,1917.5 985.368,1893.5C1012.97,1865.9 1027.37,1827.5 1027.37,1786.1C1027.37,1741.7 1011.17,1705.1 985.368,1680.5C961.968,1658.3 928.968,1644.5 892.368,1644.5C862.968,1644.5 830.568,1654.1 808.968,1683.5L808.968,1482.92L722.568,1482.92ZM871.368,1718.9C888.768,1718.9 903.768,1723.7 917.568,1736.9C930.168,1748.9 938.568,1766.3 938.568,1787.9C938.568,1807.7 930.168,1825.1 917.568,1837.1C904.368,1849.7 887.568,1855.7 872.568,1855.7C856.368,1855.7 837.168,1849.1 823.368,1835.9C813.168,1826.3 803.568,1810.1 803.568,1787.9C803.568,1765.1 812.568,1749.5 822.768,1738.7C836.568,1724.3 852.768,1718.9 871.368,1718.9Z" style="fill:rgb(35,146,255);fill-rule:nonzero;"/>
|
||||
<rect x="1083.77" y="1482.92" width="86.4" height="438.182" style="fill:rgb(250,144,82);fill-rule:nonzero;"/>
|
||||
<path d="M1531.37,1482.92L1444.97,1482.92L1444.97,1683.5C1423.37,1654.1 1390.97,1644.5 1361.57,1644.5C1324.97,1644.5 1291.97,1658.3 1268.57,1680.5C1242.77,1705.1 1226.57,1741.7 1226.57,1786.1C1226.57,1827.5 1240.97,1865.9 1268.57,1893.5C1291.97,1917.5 1320.77,1930.1 1360.37,1930.1C1407.77,1930.1 1431.77,1907.9 1444.97,1888.7L1444.97,1921.1L1531.37,1921.1L1531.37,1482.92ZM1382.57,1718.9C1401.17,1718.9 1417.37,1724.3 1431.17,1738.7C1441.37,1749.5 1450.37,1765.1 1450.37,1787.9C1450.37,1810.1 1440.77,1826.3 1430.57,1835.9C1416.77,1849.1 1397.57,1855.7 1381.37,1855.7C1366.37,1855.7 1349.57,1849.7 1336.37,1837.1C1323.77,1825.1 1315.37,1807.7 1315.37,1787.9C1315.37,1766.3 1323.77,1748.9 1336.37,1736.9C1350.17,1723.7 1365.17,1718.9 1382.57,1718.9Z" style="fill:rgb(35,146,255);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.4 KiB |
4
.idea/libraries/bld.xml
generated
4
.idea/libraries/bld.xml
generated
|
@ -2,12 +2,12 @@
|
|||
<library name="bld">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.8.0.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.8.0-sources.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||
</SOURCES>
|
||||
<excluded>
|
||||
|
|
4
.idea/libraries/compile.xml
generated
4
.idea/libraries/compile.xml
generated
|
@ -7,7 +7,7 @@
|
|||
<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" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
4
.idea/libraries/runtime.xml
generated
4
.idea/libraries/runtime.xml
generated
|
@ -8,7 +8,7 @@
|
|||
<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" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
4
.idea/libraries/test.xml
generated
4
.idea/libraries/test.xml
generated
|
@ -8,7 +8,7 @@
|
|||
<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" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
14
.idea/misc.xml
generated
14
.idea/misc.xml
generated
|
@ -1,7 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0">
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin ALL_OPEN" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin ASSIGNMENT" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin KOTLIN_SERIALIZATION" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin LOMBOK" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin NOARG" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin POWER_ASSERT" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin SAM_WITH_RECEIVER" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin COMPOSE" />
|
||||
<entry_point TYPE="field" FQNAME="rife.bld.extension.kotlin.CompilerPlugin KOTLIN_IMPORTS_DUMPER" />
|
||||
</entry_points>
|
||||
<pattern value="rife.bld.extension.CompileKotlinOperationBuild" method="pmd" />
|
||||
<pattern value="rife.bld.extension.kotlin.CompilerPlugin" />
|
||||
<pattern value="rife.bld.extension.kotlin.CompilerPlugin" method="CompilerPlugin" />
|
||||
<pattern value="rife.bld.extension.CompileKotlinOperationBuild" method="publishGitHub" />
|
||||
</component>
|
||||
<component name="PDMPlugin">
|
||||
<option name="customRuleSets">
|
||||
|
|
9
.idea/runConfigurations/Run Tests.xml
generated
9
.idea/runConfigurations/Run Tests.xml
generated
|
@ -1,9 +0,0 @@
|
|||
<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>
|
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
|
@ -5,7 +5,15 @@
|
|||
"type": "java",
|
||||
"name": "Run Tests",
|
||||
"request": "launch",
|
||||
"mainClass": "rife.bld.extension.CompileKotlinOperationTest"
|
||||
"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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
|
@ -3,13 +3,13 @@
|
|||
"src/main/java",
|
||||
"src/main/resources",
|
||||
"src/test/java",
|
||||
"src/bld/java"
|
||||
"src/test/resources",
|
||||
"src/bld/java",
|
||||
"src/bld/resources"
|
||||
],
|
||||
"java.configuration.updateBuildConfiguration": "automatic",
|
||||
"java.project.referencedLibraries": [
|
||||
"${HOME}/.bld/dist/bld-1.8.0.jar",
|
||||
"lib/compile/*.jar",
|
||||
"lib/runtime/*.jar",
|
||||
"lib/test/*.jar"
|
||||
"${HOME}/.bld/dist/bld-2.2.1.jar",
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
||||
|
|
67
README.md
67
README.md
|
@ -2,21 +2,28 @@
|
|||
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
|
||||
[](https://kotlinlang.org)
|
||||
[](https://rife2.com/bld)
|
||||
[](https://kotlinlang.org)
|
||||
[](https://rife2.com/bld)
|
||||
[](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-kotlin)
|
||||
[](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-kotlin)
|
||||
[](https://github.com/rife2/bld-kotlin/actions/workflows/bld.yml)
|
||||
|
||||
To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions).
|
||||
To install the latest version, add the following to the `lib/bld/bld-wrapper.properties` file:
|
||||
|
||||
```properties
|
||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin
|
||||
```
|
||||
|
||||
For more information, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) and [support](https://github.com/rife2/bld/wiki/Kotlin-Support) documentation.
|
||||
|
||||
## Compile Kotlin Source Code
|
||||
|
||||
To compile the source code located in `src/main/kotlin` and `src/test/kotlin` from the current project:
|
||||
To compile the source code located in `src/main/kotlin` and `src/test/kotlin` from the current project add the following to the build file:
|
||||
|
||||
```java
|
||||
|
||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||
public void compile() throws IOException {
|
||||
public void compile() throws Exception {
|
||||
new CompileKotlinOperation()
|
||||
.fromProject(this)
|
||||
.execute();
|
||||
|
@ -29,29 +36,53 @@ public void compile() throws IOException {
|
|||
|
||||
- [View Examples Project](https://github.com/rife2/bld-kotlin/tree/main/examples/)
|
||||
|
||||
Please check the [Compile Operation documentation](https://rife2.github.io/bld-kotlin/rife/bld/extension/CompileKotlinOperation.html#method-summary)
|
||||
Please check
|
||||
the [Compile Operation documentation](https://rife2.github.io/bld-kotlin/rife/bld/extension/CompileKotlinOperation.html#method-summary)
|
||||
for all available configuration options.
|
||||
|
||||
## Generate Javadoc
|
||||
## Kotlin Compiler Requirement
|
||||
|
||||
To generate the Javadoc using [Dokka](https://github.com/Kotlin/dokka):
|
||||
Please make sure the Kotlin compiler is [installed](https://kotlinlang.org/docs/command-line.html#install-the-compiler).
|
||||
|
||||
The extension will look in common locations such as:
|
||||
|
||||
- `KOTLIN_HOME`
|
||||
- `PATH`
|
||||
- [SDKMAN!](https://sdkman.io/)
|
||||
- [Homebrew](https://brew.sh/)
|
||||
- [JetBrains Toolbox](https://www.jetbrains.com/toolbox-app/) (IntelliJ IDEA, Android Studio)
|
||||
- etc.
|
||||
|
||||
You can also manually configure the Kotlin home location as follows:
|
||||
|
||||
```java
|
||||
@BuildCommand(summary = "Generates Javadoc for the project")
|
||||
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
|
||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||
public void compile() throws Exception {
|
||||
new CompileKotlinOperation()
|
||||
.fromProject(this)
|
||||
.outputDir(new File(buildDirectory(), "javadoc"))
|
||||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.kotlinHome("path/to/kotlin")
|
||||
.execute();
|
||||
}
|
||||
```
|
||||
|
||||
```console
|
||||
./bld javadoc
|
||||
The Kotlin compiler executable can also be specified directly:
|
||||
|
||||
```java
|
||||
|
||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||
public void compile() throws Exception {
|
||||
new CompileKotlinOperation()
|
||||
.fromProject(this)
|
||||
.kotlinc("/usr/bin/kotlinc")
|
||||
.execute();
|
||||
}
|
||||
```
|
||||
|
||||
- [View Examples Project](https://github.com/rife2/bld-kotlin/tree/main/examples/)
|
||||
While older version of Kotlin are likely working with the extension, only version 1.9.25 or higher are officially
|
||||
supported.
|
||||
|
||||
Please check the [Dokka Operation documentation](https://rife2.github.io/bld-kotlin/rife/bld/extension/dokka/DokkaOperation.html#method-summary)
|
||||
for all available configuration options.
|
||||
## Template Project
|
||||
|
||||
There is also a [Template Project](https://github.com/rife2/kotlin-bld-example) with support for
|
||||
the [Dokka](https://github.com/rife2/bld-dokka) and [Detekt](https://github.com/rife2/bld-detekt) extensions.
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
TMPNEW=/tmp/checkcliargs-new
|
||||
TMPOLD=/tmp/checkcliargs-old
|
||||
|
||||
cd lib/compile
|
||||
java -cp "*" -jar dokka-cli-*.jar -h >$TMPNEW
|
||||
|
||||
cd ../../examples/lib/bld
|
||||
java -cp "*" -jar dokka-cli-*.jar -h >$TMPOLD
|
||||
|
||||
diff $TMPOLD $TMPNEW
|
||||
|
||||
rm -rf $TMPNEW $TMPOLD
|
|
@ -7,9 +7,9 @@
|
|||
<!-- BEST PRACTICES -->
|
||||
<rule ref="category/java/bestpractices.xml">
|
||||
<exclude name="AvoidPrintStackTrace"/>
|
||||
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
|
||||
<exclude name="JUnitTestContainsTooManyAsserts"/>
|
||||
<exclude name="GuardLogStatement"/>
|
||||
<exclude name="UnitTestContainsTooManyAsserts"/>
|
||||
<exclude name="UnitTestShouldUseTestAnnotation"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="category/java/bestpractices.xml/MissingOverride">
|
||||
|
@ -19,15 +19,15 @@
|
|||
</properties>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- CODE STYLE -->
|
||||
<rule ref="category/java/codestyle.xml">
|
||||
<exclude name="AtLeastOneConstructor"/>
|
||||
<exclude name="ClassNamingConventions"/>
|
||||
<exclude name="ConfusingTernary"/>
|
||||
<exclude name="CommentDefaultAccessModifier"/>
|
||||
<exclude name="ConfusingTernary"/>
|
||||
<exclude name="FieldNamingConventions"/>
|
||||
<exclude name="LocalVariableCouldBeFinal"/>
|
||||
<exclude name="LocalVariableNamingConventions"/>
|
||||
<exclude name="LongVariable"/>
|
||||
<exclude name="MethodArgumentCouldBeFinal"/>
|
||||
<exclude name="OnlyOneReturn"/>
|
||||
|
@ -35,8 +35,9 @@
|
|||
<exclude name="ShortClassName"/>
|
||||
<exclude name="ShortMethodName"/>
|
||||
<exclude name="ShortVariable"/>
|
||||
<exclude name="UselessParentheses"/>
|
||||
<exclude name="UseExplicitTypes"/>
|
||||
<exclude name="UseUnderscoresInNumericLiterals"/>
|
||||
<exclude name="UselessParentheses"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryImport">
|
||||
|
@ -52,8 +53,6 @@
|
|||
<exclude name="AvoidUncheckedExceptionsInSignatures"/>
|
||||
<exclude name="CognitiveComplexity"/>
|
||||
<exclude name="CyclomaticComplexity"/>
|
||||
<exclude name="ExcessiveClassLength"/>
|
||||
<exclude name="ExcessiveMethodLength"/>
|
||||
<exclude name="ExcessiveParameterList"/>
|
||||
<exclude name="ExcessivePublicCount"/>
|
||||
<exclude name="GodClass"/>
|
||||
|
|
6
examples/.idea/bld.xml
generated
Normal file
6
examples/.idea/bld.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BldConfiguration">
|
||||
<events />
|
||||
</component>
|
||||
</project>
|
3
examples/.idea/kotlinc.xml
generated
3
examples/.idea/kotlinc.xml
generated
|
@ -3,4 +3,7 @@
|
|||
<component name="Kotlin2JvmCompilerArguments">
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</component>
|
||||
<component name="KotlinCommonCompilerArguments">
|
||||
<option name="suppressWarnings" value="true" />
|
||||
</component>
|
||||
</project>
|
4
examples/.idea/libraries/bld.xml
generated
4
examples/.idea/libraries/bld.xml
generated
|
@ -2,12 +2,12 @@
|
|||
<library name="bld">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.8.0.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.8.0-sources.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.bld/dist/bld-2.2.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
<excluded>
|
||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||
|
|
4
examples/.idea/libraries/compile.xml
generated
4
examples/.idea/libraries/compile.xml
generated
|
@ -7,7 +7,7 @@
|
|||
<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" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="true" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
4
examples/.idea/libraries/runtime.xml
generated
4
examples/.idea/libraries/runtime.xml
generated
|
@ -8,7 +8,7 @@
|
|||
<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" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="true" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
4
examples/.idea/libraries/test.xml
generated
4
examples/.idea/libraries/test.xml
generated
|
@ -8,7 +8,7 @@
|
|||
<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" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="true" type="SOURCES" />
|
||||
</library>
|
||||
</component>
|
4
examples/.idea/misc.xml
generated
4
examples/.idea/misc.xml
generated
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<pattern value="com.example.ExampleBuild" />
|
||||
|
@ -24,4 +23,7 @@
|
|||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build" />
|
||||
</component>
|
||||
<component name="SuppressKotlinCodeStyleNotification">
|
||||
<option name="disableForAll" value="true" />
|
||||
</component>
|
||||
</project>
|
6
examples/.vscode/launch.json
vendored
6
examples/.vscode/launch.json
vendored
|
@ -5,7 +5,11 @@
|
|||
"type": "java",
|
||||
"name": "Run Tests",
|
||||
"request": "launch",
|
||||
"mainClass": "com.example.ExampleTest"
|
||||
"mainClass": "com.example.ExampleBuild",
|
||||
"args": [
|
||||
"compile",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
10
examples/.vscode/settings.json
vendored
10
examples/.vscode/settings.json
vendored
|
@ -3,13 +3,13 @@
|
|||
"src/main/java",
|
||||
"src/main/resources",
|
||||
"src/test/java",
|
||||
"src/bld/java"
|
||||
"src/test/resources",
|
||||
"src/bld/java",
|
||||
"src/bld/resources"
|
||||
],
|
||||
"java.configuration.updateBuildConfiguration": "automatic",
|
||||
"java.project.referencedLibraries": [
|
||||
"${HOME}/.bld/dist/bld-1.8.0.jar",
|
||||
"lib/compile/*.jar",
|
||||
"lib/runtime/*.jar",
|
||||
"lib/test/*.jar"
|
||||
"${HOME}/.bld/dist/bld-2.2.1.jar",
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
## Compile the Kotlin Example
|
||||
|
||||
```console
|
||||
|
@ -17,11 +16,6 @@
|
|||
./bld test
|
||||
```
|
||||
|
||||
## Build the documentation with [Dokka](https://github.com/Kotlin/dokka)
|
||||
## Requirements
|
||||
|
||||
```console
|
||||
./bld javadoc
|
||||
./bld dokka-html
|
||||
./bld dokka-gfm
|
||||
./bld dokka-jekyll
|
||||
```
|
||||
- A Kotlin compiler must be [installed](https://github.com/rife2/bld-kotlin?tab=readme-ov-file#kotlin-compiler-requirement).
|
||||
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
bld.downloadExtensionJavadoc=false
|
||||
bld.downloadExtensionSources=true
|
||||
bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0
|
||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||
bld.downloadLocation=
|
||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||
bld.sourceDirectories=
|
||||
bld.version=1.8.0
|
||||
bld.version=2.2.1
|
||||
|
|
|
@ -3,14 +3,10 @@ package com.example;
|
|||
import rife.bld.BuildCommand;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
import rife.bld.extension.dokka.DokkaOperation;
|
||||
import rife.bld.extension.dokka.LoggingLevel;
|
||||
import rife.bld.extension.dokka.OutputFormat;
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
import rife.bld.extension.kotlin.CompileOptions;
|
||||
import rife.bld.extension.kotlin.JvmOptions;
|
||||
|
||||
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;
|
||||
|
@ -28,17 +24,20 @@ public class ExampleBuild extends Project {
|
|||
version = version(0, 1, 0);
|
||||
|
||||
javaRelease = 17;
|
||||
|
||||
downloadSources = true;
|
||||
autoDownloadPurge = true;
|
||||
|
||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||
|
||||
final var kotlin = version(1, 9, 22);
|
||||
final var kotlin = version(2, 1, 20);
|
||||
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, 1)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)));
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-launcher", version(1, 12, 2)));
|
||||
|
||||
// Include the Kotlin source directory when creating or publishing sources Java Archives
|
||||
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
|
||||
|
@ -46,73 +45,27 @@ public class ExampleBuild extends Project {
|
|||
|
||||
public static void main(String[] args) {
|
||||
// Enable detailed logging for the Kotlin extension
|
||||
// var level = Level.ALL;
|
||||
// var logger = Logger.getLogger("rife.bld.extension");
|
||||
// var consoleHandler = new ConsoleHandler();
|
||||
var level = Level.ALL;
|
||||
var logger = Logger.getLogger("rife.bld.extension");
|
||||
var consoleHandler = new ConsoleHandler();
|
||||
|
||||
// consoleHandler.setLevel(level);
|
||||
// logger.addHandler(consoleHandler);
|
||||
// logger.setLevel(level);
|
||||
// logger.setUseParentHandlers(false);
|
||||
consoleHandler.setLevel(level);
|
||||
logger.addHandler(consoleHandler);
|
||||
logger.setLevel(level);
|
||||
logger.setUseParentHandlers(false);
|
||||
|
||||
new ExampleBuild().start(args);
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||
@Override
|
||||
public void compile() throws IOException {
|
||||
public void compile() throws Exception {
|
||||
// The source code located in src/main/kotlin and src/test/kotlin will be compiled
|
||||
new CompileKotlinOperation()
|
||||
// .kotlinHome("path/to/kotlin")
|
||||
// .kotlinc("path/to/kotlinc")
|
||||
.compileOptions(new CompileOptions().verbose(true))
|
||||
.fromProject(this)
|
||||
.execute();
|
||||
|
||||
// var op = new CompileKotlinOperation().fromProject(this);
|
||||
// op.compileOptions().verbose(true);
|
||||
// op.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "dokka-gfm", summary = "Generates documentation in GitHub flavored markdown format")
|
||||
public void dokkaGfm() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/dokka/gfm
|
||||
.outputDir(Path.of(buildDirectory().getAbsolutePath(), "dokka", "gfm").toFile())
|
||||
.outputFormat(OutputFormat.MARKDOWN)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "dokka-html", summary = "Generates documentation in HTML format")
|
||||
public void dokkaHtml() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/dokka/html
|
||||
.outputDir(Path.of(buildDirectory().getAbsolutePath(), "dokka", "html").toFile())
|
||||
.outputFormat(OutputFormat.HTML)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(value = "dokka-jekyll", summary = "Generates documentation in Jekyll flavored markdown format")
|
||||
public void dokkaJekyll() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/dokka/jekyll
|
||||
.outputDir(Path.of(buildDirectory().getAbsolutePath(), "dokka", "jekkyl").toFile())
|
||||
.outputFormat(OutputFormat.JEKYLL)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Generates Javadoc for the project")
|
||||
@Override
|
||||
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
|
||||
new DokkaOperation()
|
||||
.fromProject(this)
|
||||
.loggingLevel(LoggingLevel.INFO)
|
||||
// Create build/javadoc
|
||||
.outputDir(new File(buildDirectory(), "javadoc"))
|
||||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.execute();
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,7 +1,10 @@
|
|||
bld.downloadExtensionJavadoc=false
|
||||
bld.downloadExtensionSources=true
|
||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.5
|
||||
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
|
||||
bld.downloadLocation=
|
||||
bld.javaOptions=
|
||||
bld.javacOptions=
|
||||
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
|
||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.2
|
||||
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||
bld.sourceDirectories=
|
||||
bld.version=1.8.0
|
||||
bld.version=2.2.1
|
||||
|
|
11
scripts/checkcliargs.sh
Executable file
11
scripts/checkcliargs.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
new=/tmp/checkcliargs-new
|
||||
old=/tmp/checkcliargs-old
|
||||
|
||||
kotlinc -h 2>$new
|
||||
~/.sdkman/candidates/kotlin/2.1.10/bin/kotlinc -h 2>$old
|
||||
|
||||
code --diff --wait $old $new
|
||||
|
||||
rm -rf $new $old
|
5
scripts/cliargs.sh
Executable file
5
scripts/cliargs.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
kotlinc -h 2> >(grep "^ ") |
|
||||
sed -e "s/^ //" -e "s/ .*//" -e "s/<.*//" -e '/-help/d' -e '/^-version/d' -e '/^$/d' |
|
||||
sort >"src/test/resources/kotlinc-args.txt"
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,6 +23,7 @@ import rife.bld.publish.PublishLicense;
|
|||
import rife.bld.publish.PublishScm;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static rife.bld.dependencies.Repository.*;
|
||||
import static rife.bld.dependencies.Scope.compile;
|
||||
|
@ -33,30 +34,21 @@ public class CompileKotlinOperationBuild extends Project {
|
|||
public CompileKotlinOperationBuild() {
|
||||
pkg = "rife.bld.extension";
|
||||
name = "bld-kotlin";
|
||||
version = version(0, 9, 0);
|
||||
version = version(1, 1, 0, "SNAPSHOT");
|
||||
|
||||
javaRelease = 17;
|
||||
|
||||
downloadSources = true;
|
||||
autoDownloadPurge = true;
|
||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||
|
||||
var dokka = version(1, 9, 10);
|
||||
var kotlin = version(1, 9, 22);
|
||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
|
||||
|
||||
scope(compile)
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-compiler", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-annotation-processing", kotlin))
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-scripting-compiler", kotlin))
|
||||
.include(dependency("org.jetbrains.dokka", "dokka-cli", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "dokka-base", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "analysis-kotlin-descriptors", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "javadoc-plugin", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "gfm-plugin", dokka))
|
||||
.include(dependency("org.jetbrains.dokka", "jekyll-plugin", dokka))
|
||||
.include(dependency("com.uwyn.rife2", "bld", version(1, 8, 0)));
|
||||
.include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1)));
|
||||
scope(test)
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)))
|
||||
.include(dependency("org.assertj", "assertj-core", version(3, 25, 2)));
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)))
|
||||
.include(dependency("org.assertj", "assertj-core", version(3, 27, 3)));
|
||||
|
||||
javadocOperation()
|
||||
.javadocOptions()
|
||||
|
@ -66,25 +58,23 @@ public class CompileKotlinOperationBuild extends Project {
|
|||
|
||||
publishOperation()
|
||||
.repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2"))
|
||||
.repository(repository("github"))
|
||||
.info()
|
||||
.groupId("com.uwyn.rife2")
|
||||
.artifactId("bld-kotlin")
|
||||
.description("bld Kotlin Extension")
|
||||
.url("https://github.com/rife2/bld-kotlin")
|
||||
.developer(
|
||||
new PublishDeveloper()
|
||||
.developer(new PublishDeveloper()
|
||||
.id("ethauvin")
|
||||
.name("Erik C. Thauvin")
|
||||
.email("erik@thauvin.net")
|
||||
.url("https://erik.thauvin.net/")
|
||||
)
|
||||
.license(
|
||||
new PublishLicense()
|
||||
.license(new PublishLicense()
|
||||
.name("The Apache License, Version 2.0")
|
||||
.url("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
.url("https://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
)
|
||||
.scm(
|
||||
new PublishScm()
|
||||
.scm(new PublishScm()
|
||||
.connection("scm:git:https://github.com/rife2/bld-kotlin.git")
|
||||
.developerConnection("scm:git:git@github.com:rife2/bld-kotlin.git")
|
||||
.url("https://github.com/rife2/bld-kotlin")
|
||||
|
@ -98,11 +88,23 @@ public class CompileKotlinOperationBuild extends Project {
|
|||
}
|
||||
|
||||
@BuildCommand(summary = "Runs PMD analysis")
|
||||
public void pmd() {
|
||||
public void pmd() throws Exception {
|
||||
new PmdOperation()
|
||||
.fromProject(this)
|
||||
.failOnViolation(true)
|
||||
.ruleSets("config/pmd.xml")
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test() throws Exception {
|
||||
var os = System.getProperty("os.name");
|
||||
if (os != null && os.toLowerCase(Locale.US).contains("linux")) {
|
||||
new ExecOperation()
|
||||
.fromProject(this)
|
||||
.command("scripts/cliargs.sh")
|
||||
.execute();
|
||||
}
|
||||
super.test();
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,581 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
|
||||
|
||||
/**
|
||||
* Configuration for the Kotlin compiler options.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public class CompileKotlinOptions {
|
||||
private final List<String> argFile_ = new ArrayList<>();
|
||||
private final List<String> classpath_ = new ArrayList<>();
|
||||
private final List<String> optIn_ = new ArrayList<>();
|
||||
private final List<String> options_ = new ArrayList<>();
|
||||
private final List<String> plugin_ = new ArrayList<>();
|
||||
private final List<String> scriptTemplates_ = new ArrayList<>();
|
||||
private String apiVersion_;
|
||||
private boolean includeRuntime_;
|
||||
private boolean javaParameters_;
|
||||
private String jdkHome_;
|
||||
private String jdkRelease_;
|
||||
private String jvmTarget_;
|
||||
private String kotlinHome_;
|
||||
private String languageVersion_;
|
||||
private String moduleName_;
|
||||
private boolean noJdk_;
|
||||
private boolean noReflect_;
|
||||
private boolean noStdLib_;
|
||||
private boolean noWarn_;
|
||||
private String path_;
|
||||
private boolean progressive_;
|
||||
private boolean verbose_;
|
||||
private boolean wError_;
|
||||
|
||||
/**
|
||||
* Allow using declarations only from the specified version of Kotlin bundled libraries.
|
||||
*
|
||||
* @param version the api version
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions apiVersion(String version) {
|
||||
apiVersion_ = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the compiler options from the given files.
|
||||
* <p>
|
||||
* Such a file can contain compiler options with values and paths to the source files.
|
||||
* Options and paths should be separated by whitespaces. For example:
|
||||
* <ul>
|
||||
* <li>{@code -include-runtime -d hello.jar hello.kt}</li>
|
||||
* </ul>
|
||||
* To pass values that contain whitespaces, surround them with single ({@code '}) or double ({@code "}) quotes.
|
||||
* If a value contains quotation marks in it, escape them with a backslash (\).
|
||||
* <ul>
|
||||
* <li>{@code -include-runtime -d 'My folder'}</li>
|
||||
* </ul>
|
||||
* If the files reside in locations different from the current directory, use relative paths.
|
||||
*
|
||||
* @param files one or more files
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions argFile(String... files) {
|
||||
argFile_.addAll(List.of(files));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the compiler options from the given files.
|
||||
*
|
||||
* @param files the list of files
|
||||
* @return this operation instance
|
||||
* @see #argFile(String...)
|
||||
*/
|
||||
public CompileKotlinOptions argFile(Collection<String> files) {
|
||||
argFile_.addAll(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the formatted arguments.
|
||||
*
|
||||
* @return the arguments
|
||||
*/
|
||||
public List<String> args() {
|
||||
var args = new ArrayList<String>();
|
||||
|
||||
// api-isNotBlankversion
|
||||
if (isNotBlank(apiVersion_)) {
|
||||
args.add("-api-version");
|
||||
args.add(apiVersion_);
|
||||
}
|
||||
|
||||
// @argfile
|
||||
if (!argFile_.isEmpty()) {
|
||||
argFile_.forEach(f -> args.add("@" + f));
|
||||
}
|
||||
|
||||
// classpath
|
||||
if (!classpath_.isEmpty()) {
|
||||
args.add("-classpath");
|
||||
args.add(String.join(File.pathSeparator, classpath_));
|
||||
}
|
||||
|
||||
// java-parameters
|
||||
if (javaParameters_) {
|
||||
args.add("-java-parameters");
|
||||
}
|
||||
|
||||
// jvm-target
|
||||
if (isNotBlank(jvmTarget_)) {
|
||||
args.add("-jvm-target");
|
||||
args.add(jvmTarget_);
|
||||
}
|
||||
|
||||
// include-runtime
|
||||
if (includeRuntime_) {
|
||||
args.add("-include-runtime");
|
||||
}
|
||||
|
||||
// jdk-home
|
||||
if (isNotBlank(jdkHome_)) {
|
||||
args.add("-jdk-home");
|
||||
args.add(jdkHome_);
|
||||
}
|
||||
|
||||
// jdk-release
|
||||
if (isNotBlank(jdkRelease_)) {
|
||||
args.add("-Xjdk-release=" + jdkRelease_);
|
||||
}
|
||||
|
||||
// kotlin-home
|
||||
if (isNotBlank(kotlinHome_)) {
|
||||
args.add("-kotlin-home");
|
||||
args.add(kotlinHome_);
|
||||
}
|
||||
|
||||
// language-version
|
||||
if (isNotBlank(languageVersion_)) {
|
||||
args.add("-language-version");
|
||||
args.add(languageVersion_);
|
||||
}
|
||||
|
||||
// module-name
|
||||
if (isNotBlank(moduleName_)) {
|
||||
args.add("-module-name");
|
||||
args.add(moduleName_);
|
||||
}
|
||||
|
||||
// no-jdk
|
||||
if (noJdk_) {
|
||||
args.add("-no-jdk");
|
||||
}
|
||||
|
||||
// no-reflect
|
||||
if (noReflect_) {
|
||||
args.add("-no-reflect");
|
||||
}
|
||||
|
||||
// no-std-lib
|
||||
if (noStdLib_) {
|
||||
args.add("-no-stdlib");
|
||||
}
|
||||
|
||||
// no-warn
|
||||
if (noWarn_) {
|
||||
args.add("-no-warn");
|
||||
}
|
||||
|
||||
// opt-in
|
||||
optIn_.stream().filter(CompileKotlinOperation::isNotBlank).forEach(o -> {
|
||||
args.add("-opt-in");
|
||||
args.add(o);
|
||||
});
|
||||
|
||||
// options
|
||||
if (!options_.isEmpty()) {
|
||||
args.addAll(options_);
|
||||
}
|
||||
|
||||
// path
|
||||
if (isNotBlank(path_)) {
|
||||
args.add("-d");
|
||||
args.add(path_);
|
||||
}
|
||||
|
||||
// plugin
|
||||
plugin_.stream().filter(CompileKotlinOperation::isNotBlank).forEach(p -> {
|
||||
args.add("-P");
|
||||
args.add("plugin:" + p);
|
||||
});
|
||||
|
||||
// progressive
|
||||
if (progressive_) {
|
||||
args.add("-progressive");
|
||||
}
|
||||
|
||||
// script-templates
|
||||
if (!scriptTemplates_.isEmpty()) {
|
||||
args.add("-script-templates");
|
||||
args.add(String.join(",", scriptTemplates_));
|
||||
}
|
||||
|
||||
// verbose
|
||||
if (verbose_) {
|
||||
args.add("-verbose");
|
||||
}
|
||||
|
||||
// Werror
|
||||
if (wError_) {
|
||||
args.add("-Werror");
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for class files in the specified paths.
|
||||
* <p>
|
||||
* The classpath can contain file and directory paths, ZIP, or JAR files.
|
||||
*
|
||||
* @param paths one pr more paths
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions classpath(String... paths) {
|
||||
classpath_.addAll(List.of(paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for class files in the specified paths.
|
||||
* <p>
|
||||
* The classpath can contain file and directory paths, ZIP, or JAR files.
|
||||
*
|
||||
* @param paths the list of paths
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions classpath(Collection<String> paths) {
|
||||
classpath_.addAll(paths);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the {@link #jdkRelease(String) jdkRelease} was set.
|
||||
*
|
||||
* @return {@code true} if the release was set; or {@code false} otherwise
|
||||
*/
|
||||
public boolean hasRelease() {
|
||||
return jdkRelease_ != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include the Kotlin runtime into the resulting JAR file. Makes the resulting archive runnable on any Java-enabled
|
||||
* environment.
|
||||
*
|
||||
* @param includeRuntime {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions includeRuntime(boolean includeRuntime) {
|
||||
includeRuntime_ = includeRuntime;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate metadata for Java 1.8 reflection on method parameters.
|
||||
*
|
||||
* @param javaParameters {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions javaParameters(boolean javaParameters) {
|
||||
javaParameters_ = javaParameters;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a custom JDK home directory to include into the classpath if it differs from the default {@code JAVA_HOME}.
|
||||
*
|
||||
* @param jdkHome the JDK home path
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions jdkHome(String jdkHome) {
|
||||
jdkHome_ = jdkHome;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the target version of the generated JVM bytecode.
|
||||
* <p>
|
||||
* Limit the API of the JDK in the classpath to the specified Java version. Automatically sets
|
||||
* {@link #jvmTarget(String) JVM target} version.
|
||||
* <p>
|
||||
* Possible values are 1.8, 9, 10, ..., 21. The default value is 1.8.
|
||||
*
|
||||
* @param version the target version
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions jdkRelease(String version) {
|
||||
jdkRelease_ = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the target version of the generated JVM bytecode.
|
||||
*
|
||||
* @param version the target version
|
||||
* @return this operation instance
|
||||
* @see #jdkRelease(String)
|
||||
*/
|
||||
public CompileKotlinOptions jdkRelease(int version) {
|
||||
jdkRelease_ = String.valueOf(version);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the target version of the generated JVM bytecode.
|
||||
* <p>
|
||||
* Possible values are 1.8, 9, 10, ..., 21. The default value is 1.8.
|
||||
*
|
||||
* @param target the target version
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions jvmTarget(String target) {
|
||||
jvmTarget_ = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the target version of the generated JVM bytecode.
|
||||
*
|
||||
* @param target the target version
|
||||
* @return this operation instance
|
||||
* @see #jvmTarget(String)
|
||||
*/
|
||||
public CompileKotlinOptions jvmTarget(int target) {
|
||||
jvmTarget_ = String.valueOf(target);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a custom path to the Kotlin compiler used for the discovery of runtime libraries.
|
||||
*
|
||||
* @param path the Kotlin home path
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions kotlinHome(String path) {
|
||||
kotlinHome_ = path;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide source compatibility with the specified version of Kotlin.
|
||||
*
|
||||
* @param version the language version
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions languageVersion(String version) {
|
||||
languageVersion_ = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom name for the generated {@code .kotlin_module} file.
|
||||
*
|
||||
* @param name the module name
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions moduleName(String name) {
|
||||
moduleName_ = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't automatically include the Java runtime into the classpath.
|
||||
*
|
||||
* @param noJdk {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions noJdk(boolean noJdk) {
|
||||
noJdk_ = noJdk;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't automatically include the Kotlin reflection ({@code kotlin-reflect.jar}) into the classpath.
|
||||
*
|
||||
* @param noReflect {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions noReflect(boolean noReflect) {
|
||||
noReflect_ = noReflect;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't automatically include the Kotlin/JVM stdlib ({@code kotlin-stdlib.jar}) and Kotlin reflection
|
||||
* ({@code kotlin-reflect.jar}) into the classpath.
|
||||
*
|
||||
* @param noStdLib {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions noStdLib(boolean noStdLib) {
|
||||
noStdLib_ = noStdLib;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppress the compiler from displaying warnings during compilation.
|
||||
*
|
||||
* @param noWarn {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions noWarn(boolean noWarn) {
|
||||
noWarn_ = noWarn;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable usages of API that requires opt-in with a requirement annotation with the given fully qualified name.
|
||||
*
|
||||
* @param annotations one or more annotation names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions optIn(String... annotations) {
|
||||
optIn_.addAll(List.of(annotations));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable usages of API that requires opt-in with a requirement annotation with the given fully qualified name.
|
||||
*
|
||||
* @param annotations list of annotation names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions optIn(Collection<String> annotations) {
|
||||
optIn_.addAll(annotations);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify additional compiler options.
|
||||
*
|
||||
* @param options one or more compiler options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions options(String... options) {
|
||||
options_.addAll(List.of(options));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify additional compiler options.
|
||||
*
|
||||
* @param options list of compiler options
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions options(Collection<String> options) {
|
||||
options_.addAll(options);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Place the generated class files into the specified location.
|
||||
* <p>
|
||||
* The location can be a directory, a ZIP, or a JAR file.
|
||||
*
|
||||
* @param path the location path
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions path(File path) {
|
||||
path_ = path.getAbsolutePath();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Place the generated class files into the specified location.
|
||||
* <p>
|
||||
* The location can be a directory, a ZIP, or a JAR file.
|
||||
*
|
||||
* @param path the location path
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions path(String path) {
|
||||
path_ = path;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass an option to a plugin.
|
||||
*
|
||||
* @param id the plugin ID
|
||||
* @param optionName the plugin option name
|
||||
* @param value the plugin option value
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions plugin(String id, String optionName, String value) {
|
||||
plugin_.add(id + ':' + optionName + ':' + value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow using declarations only from the specified version of Kotlin bundled libraries.
|
||||
*
|
||||
* @param progressive {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions progressive(boolean progressive) {
|
||||
progressive_ = progressive;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Script definition template classes.
|
||||
* <p>
|
||||
* Use fully qualified class names.
|
||||
*
|
||||
* @param classNames one or more class names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions scriptTemplates(String... classNames) {
|
||||
scriptTemplates_.addAll(List.of(classNames));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Script definition template classes.
|
||||
* <p>
|
||||
* Use fully qualified class names.
|
||||
*
|
||||
* @param classNames the list class names
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions scriptTemplates(Collection<String> classNames) {
|
||||
scriptTemplates_.addAll(classNames);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable verbose logging output which includes details of the compilation process.
|
||||
*
|
||||
* @param verbose {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions verbose(boolean verbose) {
|
||||
verbose_ = verbose;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn any warnings into a compilation error.
|
||||
*
|
||||
* @param wError {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public CompileKotlinOptions wError(boolean wError) {
|
||||
wError_ = wError;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension;
|
||||
|
||||
/**
|
||||
* Defines the known Kotlin compiler plugins match (regex) strings.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum CompileKotlinPlugin {
|
||||
ALL_OPEN("^allopen-compiler-plugin-.*$"),
|
||||
ASSIGNMENT("^assignment-compiler-plugin-.*$"),
|
||||
KOTLIN_IMPORTS_DUMPER("^kotlin-imports-dumper-compiler-plugin-.*$"),
|
||||
KOTLIN_SERIALIZATION("^kotlin-serialization-compiler-plugin-.*$"),
|
||||
KOTLINX_SERIALIZATION("^kotlinx-serialization-compiler-plugin-.*$"),
|
||||
LOMBOK("^lombok-compiler-plugin-.*$"),
|
||||
NOARG("^noarg-compiler-plugin-.*$"),
|
||||
SAM_WITH_RECEIVER("^sam-with-receiver-compiler-plugin-.*$");
|
||||
|
||||
public final String label;
|
||||
|
||||
CompileKotlinPlugin(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
/**
|
||||
* Dokka's analysis platforms.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum AnalysisPlatform {
|
||||
JVM, JS, NATIVE, COMMON, ANDROID
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
/**
|
||||
* Dokka documented visibilities.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum DocumentedVisibility {
|
||||
PUBLIC, PRIVATE, PROTECTED, INTERNAL, PACKAGE
|
||||
}
|
|
@ -1,584 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
import rife.bld.BaseProject;
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
import rife.bld.operations.AbstractProcessOperation;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static rife.bld.extension.CompileKotlinOperation.isNotBlank;
|
||||
|
||||
/**
|
||||
* Builds documentation (javadoc, HTML, etc.) using Dokka.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
|
||||
public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||
private final static String GFM_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|gfm-plugin|freemarker).*\\.jar$";
|
||||
private final static String HTML_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|kotlinx-html-jvm|freemarker).*\\.jar$";
|
||||
private final static String JAVADOC_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|javadoc-plugin|kotlin-as-java-plugin|korte-jvm).*\\.jar$";
|
||||
private final static String JEKYLL_PLUGIN_REGEXP =
|
||||
"^.*(dokka-base|analysis-kotlin-descriptors|jekyll-plugin|gfm-plugin|freemarker).*\\.jar$";
|
||||
private final Logger LOGGER = Logger.getLogger(DokkaOperation.class.getName());
|
||||
private final Map<String, String> globalLinks_ = new ConcurrentHashMap<>();
|
||||
private final Collection<String> globalPackageOptions_ = new ArrayList<>();
|
||||
private final Collection<String> globalSrcLinks_ = new ArrayList<>();
|
||||
private final Collection<String> includes_ = new ArrayList<>();
|
||||
private final Map<String, String> pluginConfiguration_ = new ConcurrentHashMap<>();
|
||||
private final Collection<String> pluginsClasspath_ = new ArrayList<>();
|
||||
private boolean delayTemplateSubstitution_;
|
||||
private boolean failOnWarning_;
|
||||
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_;
|
||||
|
||||
/**
|
||||
* Sets the delay substitution of some elements.
|
||||
* <p>
|
||||
* Used in incremental builds of multimodule projects.
|
||||
*
|
||||
* @param delayTemplateSubstitution the delay
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation delayTemplateSubstitution(Boolean delayTemplateSubstitution) {
|
||||
delayTemplateSubstitution_ = delayTemplateSubstitution;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the {@link #execute execute} operation, constructs the command list to use for building the process.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
protected List<String> executeConstructProcessCommandList() {
|
||||
if (project_ == null) {
|
||||
throw new IllegalArgumentException("A project must be specified.");
|
||||
}
|
||||
|
||||
final List<String> args = new ArrayList<>();
|
||||
|
||||
// java
|
||||
args.add(javaTool());
|
||||
|
||||
var cli = CompileKotlinOperation.getJarList(project_.libBldDirectory(), "^.*dokka-cli.*\\.jar$");
|
||||
|
||||
if (cli.size() != 1) {
|
||||
throw new RuntimeException("The dokka-cli JAR could not be found.");
|
||||
}
|
||||
|
||||
// -jar dokka-cli
|
||||
args.add("-jar");
|
||||
args.add(cli.get(0));
|
||||
|
||||
// -pluginClasspath
|
||||
if (!pluginsClasspath_.isEmpty()) {
|
||||
args.add("-pluginsClasspath");
|
||||
args.add(String.join(";", pluginsClasspath_));
|
||||
}
|
||||
|
||||
// -sourceSet
|
||||
var sourceSetArgs = sourceSet_.args();
|
||||
if (sourceSetArgs.isEmpty()) {
|
||||
throw new IllegalArgumentException("At least one sourceSet is required.");
|
||||
} else {
|
||||
args.add("-sourceSet");
|
||||
args.add(String.join(" ", sourceSet_.args()));
|
||||
}
|
||||
|
||||
// -outputDir
|
||||
if (outputDir_ != null) {
|
||||
if (!outputDir_.exists() && !outputDir_.mkdirs()) {
|
||||
throw new RuntimeException("Could not create: " + outputDir_.getAbsolutePath());
|
||||
}
|
||||
|
||||
args.add("-outputDir");
|
||||
args.add(outputDir_.getAbsolutePath());
|
||||
}
|
||||
|
||||
// -delayTemplateSubstitution
|
||||
if (delayTemplateSubstitution_) {
|
||||
args.add("-delayTemplateSubstitution");
|
||||
args.add(String.valueOf(delayTemplateSubstitution_));
|
||||
}
|
||||
|
||||
// -failOnWarning
|
||||
if (failOnWarning_) {
|
||||
args.add("-failOnWarning");
|
||||
args.add(String.valueOf(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");
|
||||
args.add(String.valueOf(noSuppressObviousFunctions_));
|
||||
}
|
||||
|
||||
// -offlineMode
|
||||
if (offlineMode_) {
|
||||
args.add("-offlineMode");
|
||||
args.add(String.valueOf(offlineMode_));
|
||||
}
|
||||
|
||||
// -pluginConfiguration
|
||||
if (!pluginConfiguration_.isEmpty()) {
|
||||
args.add("-pluginConfiguration");
|
||||
var confs = new ArrayList<String>();
|
||||
pluginConfiguration_.forEach((k, v) ->
|
||||
confs.add(String.format("{%s}={%s}", StringUtils.encodeJson(k), StringUtils.encodeJson(v))));
|
||||
args.add(String.join("^^", confs));
|
||||
}
|
||||
|
||||
// -suppressInheritedMembers
|
||||
if (suppressInheritedMembers_) {
|
||||
args.add("-suppressInheritedMembers");
|
||||
args.add(String.valueOf(suppressInheritedMembers_));
|
||||
}
|
||||
|
||||
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} and {@link #moduleName moduleName}
|
||||
* 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());
|
||||
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) {
|
||||
globalPackageOptions_.addAll(Arrays.asList(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) {
|
||||
globalSrcLinks_.addAll(Arrays.asList(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) {
|
||||
includes_.addAll(Arrays.asList(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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param outputDir the output directory
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation outputDir(String outputDir) {
|
||||
outputDir_ = new File(outputDir);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Dokka {@link OutputFormat output format}.
|
||||
*
|
||||
* @param format The {@link OutputFormat output format}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation outputFormat(OutputFormat format) {
|
||||
pluginsClasspath_.clear();
|
||||
if (format.equals(OutputFormat.JAVADOC)) {
|
||||
pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
|
||||
JAVADOC_PLUGIN_REGEXP));
|
||||
} else if (format.equals(OutputFormat.HTML)) {
|
||||
pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
|
||||
HTML_PLUGIN_REGEXP));
|
||||
} else if (format.equals(OutputFormat.MARKDOWN)) {
|
||||
pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
|
||||
GFM_PLUGIN_REGEXP));
|
||||
} else if (format.equals(OutputFormat.JEKYLL)) {
|
||||
pluginsClasspath_.addAll(CompileKotlinOperation.getJarList(project_.libBldDirectory(),
|
||||
JEKYLL_PLUGIN_REGEXP));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration for Dokka plugins.
|
||||
*
|
||||
* @param name The fully-qualified plugin name
|
||||
* @param jsonConfiguration The plugin JSON configuration
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation pluginConfiguration(String name, String jsonConfiguration) {
|
||||
pluginConfiguration_.put(name, jsonConfiguration);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configuration for Dokka plugins.
|
||||
*
|
||||
* @param pluginConfiguration the map of configurations
|
||||
* @return this operation instance
|
||||
* @see #pluginConfiguration(String, String)
|
||||
*/
|
||||
public DokkaOperation pluginConfiguration(Map<String, String> pluginConfiguration) {
|
||||
pluginConfiguration_.putAll(pluginConfiguration);
|
||||
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) {
|
||||
pluginsClasspath_.addAll(Arrays.asList(jars));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of jars with Dokka plugins and their dependencies.
|
||||
*
|
||||
* @param jars the list of jars
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation pluginsClasspath(Collection<String> jars) {
|
||||
pluginsClasspath_.addAll(jars);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the list of Dokka plugins.
|
||||
*
|
||||
* @param clear set to clear the list
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation pluginsClasspath(boolean clear) {
|
||||
if (clear) {
|
||||
pluginsClasspath_.clear();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the configurations for a source set.
|
||||
* <p>
|
||||
* Individual and additional configuration of Kotlin source sets.
|
||||
*
|
||||
* @param sourceSet the source set configurations
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation sourceSet(SourceSet sourceSet) {
|
||||
sourceSet_ = sourceSet;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to suppress inherited members that aren't explicitly overridden in a given class.
|
||||
*
|
||||
* @param suppressInheritedMembers {@code true} or {@code false}
|
||||
* @return this operation instance
|
||||
*/
|
||||
public DokkaOperation suppressInheritedMembers(Boolean suppressInheritedMembers) {
|
||||
suppressInheritedMembers_ = suppressInheritedMembers;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
/**
|
||||
* Dokka logging levels.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum LoggingLevel {
|
||||
DEBUG, PROGRESS, INFO, WARN, ERROR
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
/**
|
||||
* Dokka output formats.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum OutputFormat {
|
||||
JAVADOC, JEKYLL, HTML, MARKDOWN
|
||||
}
|
|
@ -1,626 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
import java.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 int 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_ > 0) {
|
||||
args.add("-jdkVersion");
|
||||
args.add(String.valueOf(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 classpath one or more classpath
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet classpath(String... classpath) {
|
||||
classpath_.addAll(Arrays.asList(classpath));
|
||||
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 classpath the list of classpath
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet classpath(Collection<String> classpath) {
|
||||
classpath_.addAll(classpath);
|
||||
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) {
|
||||
includes_.addAll(Arrays.asList(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(int jdkVersion) {
|
||||
jdkVersion_ = 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 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) {
|
||||
perPackageOptions_.addAll(List.of(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) {
|
||||
samples_.addAll(List.of(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) {
|
||||
src_.addAll(List.of(src));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mapping between a source directory and a Web service for browsing the code.
|
||||
*
|
||||
* @param srcPath the source path
|
||||
* @param remotePath the remote path
|
||||
* @param lineSuffix the line suffix
|
||||
* @return this operation instance
|
||||
*/
|
||||
public SourceSet srcLink(String srcPath, String remotePath, String lineSuffix) {
|
||||
srcLinks_.put(srcPath, remotePath + lineSuffix);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the paths to files to be suppressed.
|
||||
* <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;
|
||||
}
|
||||
}
|
1087
src/main/java/rife/bld/extension/kotlin/CompileOptions.java
Normal file
1087
src/main/java/rife/bld/extension/kotlin/CompileOptions.java
Normal file
File diff suppressed because it is too large
Load diff
43
src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java
Normal file
43
src/main/java/rife/bld/extension/kotlin/CompilerPlugin.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.kotlin;
|
||||
|
||||
/**
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* Defines the known Kotlin compiler plugin JARs.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum CompilerPlugin {
|
||||
ALL_OPEN("allopen-compiler-plugin.jar"),
|
||||
ASSIGNMENT("assignment-compiler-plugin.jar"),
|
||||
COMPOSE("compose-compiler-plugin.jar"),
|
||||
KOTLIN_IMPORTS_DUMPER("kotlin-imports-dumper-compiler-plugin.jar"),
|
||||
KOTLINX_SERIALIZATION("kotlinx-serialization-compiler-plugin.jar"),
|
||||
KOTLIN_SERIALIZATION("kotlin-serialization-compiler-plugin.jar"),
|
||||
LOMBOK("lombok-compiler-plugin.jar"),
|
||||
NOARG("noarg-compiler-plugin.jar"),
|
||||
POWER_ASSERT("power-assert-compiler-plugin.jar"),
|
||||
SAM_WITH_RECEIVER("sam-with-receiver-compiler-plugin.jar");
|
||||
|
||||
public final String jar;
|
||||
|
||||
CompilerPlugin(String jar) {
|
||||
this.jar = jar;
|
||||
}
|
||||
}
|
90
src/main/java/rife/bld/extension/kotlin/JvmOptions.java
Normal file
90
src/main/java/rife/bld/extension/kotlin/JvmOptions.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.kotlin;
|
||||
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Java Virtual Machine options.
|
||||
*
|
||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@SuppressWarnings("PMD.LooseCoupling")
|
||||
public class JvmOptions extends ArrayList<String> {
|
||||
/**
|
||||
* Keyword to enable native access for all code on the class path.
|
||||
*/
|
||||
public final static String ALL_UNNAMED = "ALL-UNNAMED";
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Modules that are permitted to perform restricted native operations.
|
||||
* The module name can also be {@link #ALL_UNNAMED}.
|
||||
*
|
||||
* @param modules the module names
|
||||
* @return this list of options
|
||||
*/
|
||||
public JvmOptions enableNativeAccess(String... modules) {
|
||||
return enableNativeAccess(List.of(modules));
|
||||
}
|
||||
|
||||
/**
|
||||
* Modules that are permitted to perform restricted native operations.
|
||||
* The module name can also be {@link #ALL_UNNAMED}.
|
||||
*
|
||||
* @param modules the module names
|
||||
* @return this list of options
|
||||
*/
|
||||
public JvmOptions enableNativeAccess(Collection<String> modules) {
|
||||
add("--enable-native-access=" + StringUtils.join(modules, ","));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls what action the Java runtime takes when native access is not enabled for a module.
|
||||
*
|
||||
* @param access the access mode
|
||||
* @return this list of options
|
||||
*/
|
||||
public JvmOptions illegalNativeAccess(NativeAccess access) {
|
||||
add("--illegal-native-access=" + access.mode);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Illegal native access modes.
|
||||
*/
|
||||
public enum NativeAccess {
|
||||
ALLOW("allow"),
|
||||
DENY("deny"),
|
||||
WARN("warn");
|
||||
|
||||
public final String mode;
|
||||
|
||||
NativeAccess(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,17 +16,22 @@
|
|||
|
||||
package rife.bld.extension;
|
||||
|
||||
import org.assertj.core.api.AutoCloseableSoftAssertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.BaseProject;
|
||||
import rife.bld.blueprints.BaseProjectBlueprint;
|
||||
import rife.bld.extension.kotlin.CompileOptions;
|
||||
import rife.bld.extension.kotlin.CompilerPlugin;
|
||||
import rife.bld.extension.kotlin.JvmOptions;
|
||||
import rife.tools.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
|
@ -34,7 +39,11 @@ import java.util.logging.Logger;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
class CompileKotlinOperationTest {
|
||||
private static final String FILE_1 = "file1";
|
||||
private static final String FILE_2 = "file2";
|
||||
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
var level = Level.ALL;
|
||||
|
@ -47,7 +56,98 @@ class CompileKotlinOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testExecute() throws IOException {
|
||||
void testBuildMainDirectory() {
|
||||
var foo = new File("foo");
|
||||
var bar = new File("bar");
|
||||
|
||||
var op = new CompileKotlinOperation().buildMainDirectory(foo);
|
||||
assertThat(op.buildMainDirectory()).as("as file").isEqualTo(foo);
|
||||
|
||||
op = op.buildMainDirectory(bar.toPath());
|
||||
assertThat(op.buildMainDirectory()).as("as path").isEqualTo(bar);
|
||||
|
||||
op = new CompileKotlinOperation().buildMainDirectory("foo");
|
||||
assertThat(op.buildMainDirectory()).as("as string").isEqualTo(foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBuildTestDirectory() {
|
||||
var foo = new File("foo");
|
||||
var bar = new File("bar");
|
||||
|
||||
var op = new CompileKotlinOperation().buildTestDirectory(foo);
|
||||
assertThat(op.buildTestDirectory()).as("as file").isEqualTo(foo);
|
||||
|
||||
op = op.buildTestDirectory(bar.toPath());
|
||||
assertThat(op.buildTestDirectory()).as("as path").isEqualTo(bar);
|
||||
|
||||
op = new CompileKotlinOperation().buildTestDirectory("foo");
|
||||
assertThat(op.buildTestDirectory()).as("as string").isEqualTo(foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCollections() {
|
||||
var op = new CompileKotlinOperation()
|
||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example", "Example"))
|
||||
.kotlinHome("/kotlin_home")
|
||||
.kotlinc("kotlinc")
|
||||
.workDir("work_dir")
|
||||
.compileMainClasspath("path1", "path2")
|
||||
.compileOptions(new CompileOptions().jdkRelease("17").verbose(true))
|
||||
.mainSourceDirectories("dir1", "dir2")
|
||||
.mainSourceDirectories(List.of(new File("dir3"), new File("dir4")))
|
||||
.mainSourceFiles("file1", "file2")
|
||||
.mainSourceFiles(List.of(new File("file3"), new File("file4")))
|
||||
.mainSourceFiles(new File("file5"), new File("file6"))
|
||||
.testSourceDirectories("tdir1", "tdir2")
|
||||
.testSourceDirectories(List.of(new File("tdir3"), new File("tdir4")))
|
||||
.testSourceFiles("tfile1", "tfile2")
|
||||
.testSourceFiles(List.of(new File("tfile3"), new File("tfile4")))
|
||||
.testSourceFiles(new File("tfile5"), new File("tfile6"))
|
||||
.plugins("plugin1", "plugin2")
|
||||
.plugins(CompilerPlugin.KOTLIN_SERIALIZATION, CompilerPlugin.ASSIGNMENT, CompilerPlugin.COMPOSE)
|
||||
.plugins(new File("lib/compile"), CompilerPlugin.LOMBOK, CompilerPlugin.POWER_ASSERT)
|
||||
.plugins(Path.of("lib/compile"), CompilerPlugin.NOARG, CompilerPlugin.ALL_OPEN,
|
||||
CompilerPlugin.KOTLIN_IMPORTS_DUMPER)
|
||||
.plugins("lib/compile", CompilerPlugin.KOTLINX_SERIALIZATION, CompilerPlugin.SAM_WITH_RECEIVER)
|
||||
.plugins(List.of("plugin3", "plugin4"));
|
||||
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
softly.assertThat(op.kotlinHome().getName()).as("kotlin_home").isEqualTo("kotlin_home");
|
||||
softly.assertThat(op.kotlinc().getName()).as("kotlinc").isEqualTo("kotlinc");
|
||||
softly.assertThat(op.workDir().getName()).as("work_dir").isEqualTo("work_dir");
|
||||
softly.assertThat(op.compileMainClasspath()).as("compileMainClassPath")
|
||||
.containsAll(List.of("path1", "path2"));
|
||||
softly.assertThat(op.compileOptions().hasRelease()).as("hasRelease").isTrue();
|
||||
softly.assertThat(op.compileOptions().isVerbose()).as("isVerbose").isTrue();
|
||||
softly.assertThat(op.mainSourceDirectories()).as("mainSourceDirectories").containsExactly(
|
||||
Path.of("examples", "src", "main", "kotlin").toFile(), new File("dir1"),
|
||||
new File("dir2"), new File("dir3"), new File("dir4"));
|
||||
softly.assertThat(op.testSourceDirectories()).as("testSourceDirectories").containsOnly(
|
||||
Path.of("examples", "src", "test", "kotlin").toFile(), new File("tdir1"),
|
||||
new File("tdir2"), new File("tdir3"), new File("tdir4"));
|
||||
softly.assertThat(op.mainSourceFiles()).as("mainSourceFiles").containsOnly(
|
||||
new File("file1"), new File("file2"), new File("file3"),
|
||||
new File("file4"), new File("file5"), new File("file6"));
|
||||
softly.assertThat(op.testSourceFiles()).as("testSourceFiles").containsOnly(
|
||||
new File("tfile1"), new File("tfile2"), new File("tfile3"),
|
||||
new File("tfile4"), new File("tfile5"), new File("tfile6"));
|
||||
softly.assertThat(op.plugins()).as("plugins").contains("plugin1", "plugin2", "plugin3", "plugin4",
|
||||
new File("/kotlin_home/lib/kotlin-serialization-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("/kotlin_home/lib/assignment-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("/kotlin_home/lib/compose-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("lib/compile", "lombok-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("lib/compile", "power-assert-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("lib/compile", "noarg-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("lib/compile", "allopen-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("lib/compile", "kotlin-imports-dumper-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("lib/compile", "kotlinx-serialization-compiler-plugin.jar").getAbsolutePath(),
|
||||
new File("lib/compile", "sam-with-receiver-compiler-plugin.jar").getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute() throws Exception {
|
||||
var tmpDir = Files.createTempDirectory("bld-kotlin").toFile();
|
||||
|
||||
try {
|
||||
|
@ -55,8 +155,10 @@ class CompileKotlinOperationTest {
|
|||
var mainDir = new File(buildDir, "main");
|
||||
var testDir = new File(buildDir, "test");
|
||||
|
||||
assertThat(mainDir.mkdirs()).isTrue();
|
||||
assertThat(testDir.mkdirs()).isTrue();
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
softly.assertThat(mainDir.mkdirs()).as("make mainDir").isTrue();
|
||||
softly.assertThat(testDir.mkdirs()).as("make testDir").isTrue();
|
||||
}
|
||||
|
||||
var compileJars = new ArrayList<String>();
|
||||
for (var f : Objects.requireNonNull(new File("examples/lib/compile").listFiles())) {
|
||||
|
@ -69,8 +171,7 @@ class CompileKotlinOperationTest {
|
|||
}
|
||||
|
||||
var op = new CompileKotlinOperation()
|
||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
||||
"Example"))
|
||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example", "Example"))
|
||||
.buildMainDirectory(mainDir)
|
||||
.buildTestDirectory(testDir)
|
||||
.compileMainClasspath(compileJars)
|
||||
|
@ -79,26 +180,268 @@ class CompileKotlinOperationTest {
|
|||
.compileTestClasspath(mainDir.getAbsolutePath());
|
||||
|
||||
op.compileOptions().verbose(true);
|
||||
op.compileOptions().jdkRelease("17");
|
||||
op.compileOptions().argFile("src/test/resources/argfile.txt", "src/test/resources/argfile2.txt");
|
||||
|
||||
if (!CompileKotlinOperation.isWindows()) {
|
||||
op.jvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED);
|
||||
assertThat(op.jvmOptions()).containsExactly("--enable-native-access=ALL-UNNAMED");
|
||||
}
|
||||
|
||||
var args = op.compileOptions().args();
|
||||
var matches = List.of("-Xjdk-release=17", "-no-stdlib", "-verbose");
|
||||
assertThat(args).isEqualTo(matches);
|
||||
var matches = List.of("-Xjdk-release=17", "-no-reflect", "-progressive", "-include-runtime", "-no-stdlib",
|
||||
"-verbose");
|
||||
assertThat(args).as(args + " == " + matches).isEqualTo(matches);
|
||||
|
||||
op.execute();
|
||||
|
||||
assertThat(tmpDir).isNotEmptyDirectory();
|
||||
assertThat(mainDir).isNotEmptyDirectory();
|
||||
assertThat(testDir).isNotEmptyDirectory();
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
softly.assertThat(tmpDir).as("tmpDir").isNotEmptyDirectory();
|
||||
softly.assertThat(mainDir).as("mainDir").isNotEmptyDirectory();
|
||||
softly.assertThat(testDir).as("testDir").isNotEmptyDirectory();
|
||||
}
|
||||
|
||||
var mainOut = Path.of(mainDir.getAbsolutePath(), "com", "example").toFile();
|
||||
assertThat(new File(mainOut, "Example.class")).exists();
|
||||
assertThat(new File(mainOut, "Example$Companion.class")).exists();
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
softly.assertThat(new File(mainOut, "Example.class")).as("Example.class").exists();
|
||||
softly.assertThat(new File(mainOut, "Example$Companion.class"))
|
||||
.as("ExampleCompanion.class").exists();
|
||||
}
|
||||
|
||||
var testOut = Path.of(testDir.getAbsolutePath(), "com", "example").toFile();
|
||||
assertThat(new File(testOut, "ExampleTest.class")).exists();
|
||||
assertThat(new File(testOut, "ExampleTest.class")).as("ExampleTest.class").exists();
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmpDir);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindKotlincPath() {
|
||||
assertThat(CompileKotlinOperation.findKotlincPath()).doesNotStartWith("kotlinc");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFromProject() {
|
||||
var examples = new File("examples");
|
||||
var op = new CompileKotlinOperation().fromProject(
|
||||
new BaseProjectBlueprint(examples, "com.example", "examples", "examples"));
|
||||
assertThat(op.mainSourceDirectories()).containsExactly(new File(examples, "src/main/kotlin"));
|
||||
assertThat(op.testSourceDirectories()).containsExactly(new File(examples, "src/test/kotlin"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFromProjectNoKotlin() {
|
||||
var op = new CompileKotlinOperation().fromProject(
|
||||
new BaseProjectBlueprint(new File("foo"), "org.example", "foo", "foo"));
|
||||
assertThat(op.mainSourceDirectories()).isEmpty();
|
||||
assertThat(op.testSourceDirectories()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsOS() {
|
||||
var osName = System.getProperty("os.name");
|
||||
if (osName != null) {
|
||||
var os = osName.toLowerCase(Locale.US);
|
||||
if (os.contains("win")) {
|
||||
assertThat(CompileKotlinOperation.isWindows()).isTrue();
|
||||
} else if (os.contains("linux") || os.contains("unix")) {
|
||||
assertThat(CompileKotlinOperation.isLinux()).isTrue();
|
||||
} else if (os.contains("mac") || os.contains("darwin")) {
|
||||
assertThat(CompileKotlinOperation.isMacOS()).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKotlinHome() {
|
||||
var foo = new File("foo");
|
||||
var bar = new File("bar");
|
||||
|
||||
var op = new CompileKotlinOperation().kotlinHome(foo);
|
||||
assertThat(op.kotlinHome()).as("as file").isEqualTo(foo);
|
||||
|
||||
op = op.kotlinHome(bar.toPath());
|
||||
assertThat(op.kotlinHome()).as("as path").isEqualTo(bar);
|
||||
|
||||
op = new CompileKotlinOperation().kotlinHome("foo");
|
||||
assertThat(op.kotlinHome()).as("as string").isEqualTo(foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKotlinc() {
|
||||
var foo = new File("foo");
|
||||
var bar = new File("bar");
|
||||
|
||||
var op = new CompileKotlinOperation().kotlinc(foo);
|
||||
assertThat(op.kotlinc()).as("as file").isEqualTo(foo);
|
||||
|
||||
op = op.kotlinc(bar.toPath());
|
||||
assertThat(op.kotlinc()).as("as path").isEqualTo(bar);
|
||||
|
||||
op = new CompileKotlinOperation().kotlinc("foo");
|
||||
assertThat(op.kotlinc()).as("as string").isEqualTo(foo);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMainSourceDirectories() {
|
||||
var op = new CompileKotlinOperation();
|
||||
|
||||
op.mainSourceDirectories(List.of(new File(FILE_1), new File(FILE_2)));
|
||||
assertThat(op.mainSourceDirectories()).as("List(File...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceDirectories().clear();
|
||||
|
||||
op.mainSourceDirectories(new File(FILE_1), new File(FILE_2));
|
||||
assertThat(op.mainSourceDirectories()).as("File...").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceDirectories().clear();
|
||||
|
||||
op.mainSourceDirectories(FILE_1, FILE_2);
|
||||
assertThat(op.mainSourceDirectories()).as("String...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceDirectories().clear();
|
||||
|
||||
op = op.mainSourceDirectories(Path.of(FILE_1), Path.of(FILE_2));
|
||||
assertThat(op.mainSourceDirectories()).as("Path...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceDirectories().clear();
|
||||
|
||||
op.mainSourceDirectoriesPaths(List.of(new File(FILE_1).toPath(), new File(FILE_2).toPath()));
|
||||
assertThat(op.mainSourceDirectories()).as("List(Path...)")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceDirectories().clear();
|
||||
|
||||
op.mainSourceDirectoriesStrings(List.of(FILE_1, FILE_2));
|
||||
assertThat(op.mainSourceDirectories()).as("List(String...)")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceDirectories().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMainSourceFiles() {
|
||||
var op = new CompileKotlinOperation();
|
||||
|
||||
op.mainSourceFiles(List.of(new File(FILE_1), new File(FILE_2)));
|
||||
assertThat(op.mainSourceFiles()).as("List(File...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceFiles().clear();
|
||||
|
||||
op.mainSourceFiles(new File(FILE_1), new File(FILE_2));
|
||||
assertThat(op.mainSourceFiles()).as("File...").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceFiles().clear();
|
||||
|
||||
op.mainSourceFiles(FILE_1, FILE_2);
|
||||
assertThat(op.mainSourceFiles()).as("String...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceFiles().clear();
|
||||
|
||||
op = op.mainSourceFiles(Path.of(FILE_1), Path.of(FILE_2));
|
||||
assertThat(op.mainSourceFiles()).as("Path...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceFiles().clear();
|
||||
|
||||
op.mainSourceFilesPaths(List.of(new File(FILE_1).toPath(), new File(FILE_2).toPath()));
|
||||
assertThat(op.mainSourceFiles()).as("List(Path...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceFiles().clear();
|
||||
|
||||
op.mainSourceFilesStrings(List.of(FILE_1, FILE_2));
|
||||
assertThat(op.mainSourceFiles()).as("List(String...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.mainSourceFiles().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
void testPlugins() {
|
||||
var op = new CompileKotlinOperation()
|
||||
.fromProject(new BaseProject())
|
||||
.plugins(CompilerPlugin.ALL_OPEN,
|
||||
CompilerPlugin.ASSIGNMENT,
|
||||
CompilerPlugin.COMPOSE,
|
||||
CompilerPlugin.KOTLIN_IMPORTS_DUMPER,
|
||||
CompilerPlugin.KOTLINX_SERIALIZATION,
|
||||
CompilerPlugin.KOTLIN_SERIALIZATION,
|
||||
CompilerPlugin.LOMBOK,
|
||||
CompilerPlugin.NOARG,
|
||||
CompilerPlugin.POWER_ASSERT,
|
||||
CompilerPlugin.SAM_WITH_RECEIVER);
|
||||
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
for (var p : op.plugins()) {
|
||||
softly.assertThat(new File(p)).as(p).exists();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTestSourceDirectories() {
|
||||
var op = new CompileKotlinOperation();
|
||||
|
||||
op.testSourceDirectories(List.of(new File(FILE_1), new File(FILE_2)));
|
||||
assertThat(op.testSourceDirectories()).as("List(File...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceDirectories().clear();
|
||||
|
||||
op.testSourceDirectories(new File(FILE_1), new File(FILE_2));
|
||||
assertThat(op.testSourceDirectories()).as("File...").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceDirectories().clear();
|
||||
|
||||
op.testSourceDirectories(FILE_1, FILE_2);
|
||||
assertThat(op.testSourceDirectories()).as("String...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceDirectories().clear();
|
||||
|
||||
op = op.testSourceDirectories(Path.of(FILE_1), Path.of(FILE_2));
|
||||
assertThat(op.testSourceDirectories()).as("Path...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceDirectories().clear();
|
||||
|
||||
op.testSourceDirectoriesPaths(List.of(new File(FILE_1).toPath(), new File(FILE_2).toPath()));
|
||||
assertThat(op.testSourceDirectories()).as("List(Path...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceDirectories().clear();
|
||||
|
||||
op.testSourceDirectoriesStrings(List.of(FILE_1, FILE_2));
|
||||
assertThat(op.testSourceDirectories()).as("List(String...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceDirectories().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTestSourceFiles() {
|
||||
var op = new CompileKotlinOperation();
|
||||
|
||||
op.testSourceFiles(List.of(new File(FILE_1), new File(FILE_2)));
|
||||
assertThat(op.testSourceFiles()).as("List(File...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceFiles().clear();
|
||||
|
||||
op.testSourceFiles(new File(FILE_1), new File(FILE_2));
|
||||
assertThat(op.testSourceFiles()).as("File...").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceFiles().clear();
|
||||
|
||||
op.testSourceFiles(FILE_1, FILE_2);
|
||||
assertThat(op.testSourceFiles()).as("String...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceFiles().clear();
|
||||
|
||||
op = op.testSourceFiles(Path.of(FILE_1), Path.of(FILE_2));
|
||||
assertThat(op.testSourceFiles()).as("Path...")
|
||||
.containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceFiles().clear();
|
||||
|
||||
op.testSourceFilesPaths(List.of(new File(FILE_1).toPath(), new File(FILE_2).toPath()));
|
||||
assertThat(op.testSourceFiles()).as("List(Path...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceFiles().clear();
|
||||
|
||||
op.testSourceFilesStrings(List.of(FILE_1, FILE_2));
|
||||
assertThat(op.testSourceFiles()).as("List(String...)").containsExactly(new File(FILE_1), new File(FILE_2));
|
||||
op.testSourceFiles().clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWorkDir() {
|
||||
var foo = new File("foo");
|
||||
var bar = new File("bar");
|
||||
|
||||
var op = new CompileKotlinOperation().workDir(foo);
|
||||
assertThat(op.workDir()).as("as file").isEqualTo(foo);
|
||||
|
||||
op = op.workDir(bar.toPath());
|
||||
assertThat(op.workDir()).as("as path").isEqualTo(bar);
|
||||
|
||||
op = new CompileKotlinOperation().workDir("foo");
|
||||
assertThat(op.workDir()).as("as string").isEqualTo(foo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
class CompileKotlinOptionsTest {
|
||||
@Test
|
||||
void argsCollectionTest() {
|
||||
var args = new CompileKotlinOptions()
|
||||
.argFile(List.of("arg1.txt", "arg2.txt"))
|
||||
.classpath(List.of("path1", "path2"))
|
||||
.noStdLib(false)
|
||||
.optIn(List.of("opt1", "opt2"))
|
||||
.options(List.of("-foo", "-bar"))
|
||||
.scriptTemplates(List.of("temp1", "temp2"))
|
||||
.args();
|
||||
var matches = List.of(
|
||||
"@arg1.txt", "@arg2.txt",
|
||||
"-classpath", "path1:path2",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
"-foo",
|
||||
"-bar",
|
||||
"-script-templates", "temp1,temp2");
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void argsTest() {
|
||||
var args = new CompileKotlinOptions()
|
||||
.apiVersion("11")
|
||||
.argFile("file.txt", "file2.txt")
|
||||
.classpath("path1", "path2")
|
||||
.javaParameters(true)
|
||||
.jvmTarget("11")
|
||||
.includeRuntime(true)
|
||||
.jdkHome("path")
|
||||
.jdkRelease("11")
|
||||
.kotlinHome("path")
|
||||
.languageVersion("1.0")
|
||||
.moduleName("module")
|
||||
.noJdk(true)
|
||||
.noReflect(true)
|
||||
.noWarn(true)
|
||||
.optIn("opt1", "opt2")
|
||||
.options("-foo", "-bar")
|
||||
.path("path")
|
||||
.plugin("id", "name", "value")
|
||||
.progressive(true)
|
||||
.scriptTemplates("name", "name2")
|
||||
.verbose(true)
|
||||
.wError(true)
|
||||
.args();
|
||||
|
||||
var matches = List.of(
|
||||
"-api-version", "11",
|
||||
"@file.txt", "@file2.txt",
|
||||
"-classpath", "path1" + File.pathSeparator + "path2",
|
||||
"-java-parameters",
|
||||
"-jvm-target", "11",
|
||||
"-include-runtime",
|
||||
"-jdk-home", "path",
|
||||
"-Xjdk-release=11",
|
||||
"-kotlin-home", "path",
|
||||
"-language-version", "1.0",
|
||||
"-module-name", "module",
|
||||
"-no-jdk",
|
||||
"-no-reflect",
|
||||
"-no-warn",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
"-foo",
|
||||
"-bar",
|
||||
"-d", "path",
|
||||
"-P", "plugin:id:name:value",
|
||||
"-progressive",
|
||||
"-script-templates", "name,name2",
|
||||
"-verbose",
|
||||
"-Werror");
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.blueprints.BaseProjectBlueprint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class DokkaOperationTest {
|
||||
@Test
|
||||
@SuppressWarnings({"ExtractMethodRecommender", "PMD.AvoidDuplicateLiterals"})
|
||||
void executeConstructProcessCommandListTest() {
|
||||
var examples = new File("examples");
|
||||
var args = new DokkaOperation()
|
||||
.fromProject(new BaseProjectBlueprint(examples, "com.example", "Example"))
|
||||
.globalLinks("s", "link")
|
||||
.globalLinks(Map.of("s2", "link2"))
|
||||
.globalPackageOptions("option1", "option2")
|
||||
.globalPackageOptions(List.of("option3", "option4"))
|
||||
.globalSrcLink("link1", "link2")
|
||||
.globalSrcLink(List.of("link3", "link4"))
|
||||
.includes("file1", "file2")
|
||||
.pluginConfiguration("name", "\"json\"")
|
||||
.pluginConfiguration(Map.of("\"name2\"", "json2"))
|
||||
.pluginsClasspath("path1", "path2")
|
||||
.pluginsClasspath(List.of("path3", "path4"))
|
||||
.delayTemplateSubstitution(true)
|
||||
.failOnWarning(true)
|
||||
.loggingLevel(LoggingLevel.DEBUG)
|
||||
.moduleName("name")
|
||||
.moduleVersion("1.0")
|
||||
.noSuppressObviousFunctions(true)
|
||||
.offlineMode(true)
|
||||
.outputDir(new File(examples, "build"))
|
||||
.outputFormat(OutputFormat.JAVADOC)
|
||||
.suppressInheritedMembers(true)
|
||||
.executeConstructProcessCommandList();
|
||||
|
||||
var path = examples.getAbsolutePath();
|
||||
var matches = List.of("java",
|
||||
"-jar", path + "/lib/bld/dokka-cli-1.9.10.jar",
|
||||
"-pluginsClasspath", path + "/lib/bld/dokka-base-1.9.10.jar;" +
|
||||
path + "/lib/bld/analysis-kotlin-descriptors-1.9.10.jar;" +
|
||||
path + "/lib/bld/javadoc-plugin-1.9.10.jar;" +
|
||||
path + "/lib/bld/korte-jvm-2.7.0.jar;" +
|
||||
path + "/lib/bld/kotlin-as-java-plugin-1.9.10.jar;path1;path2;path3;path4",
|
||||
"-sourceSet", "-src " + path + "/src/main/kotlin",
|
||||
"-outputDir", path + "/build",
|
||||
"-delayTemplateSubstitution", "true",
|
||||
"-failOnWarning", "true",
|
||||
"-globalLinks", "s^link^^s2^link2",
|
||||
"-globalPackageOptions", "option1;option2;option3;option4",
|
||||
"-globalSrcLinks_", "link1;link2;link3;link4",
|
||||
"-includes", "file1;file2",
|
||||
"-loggingLevel", "debug",
|
||||
"-moduleName", "name",
|
||||
"-moduleVersion", "1.0",
|
||||
"-noSuppressObviousFunctions", "true",
|
||||
"-offlineMode", "true",
|
||||
"-pluginConfiguration", "{name}={\\\"json\\\"}^^{\\\"name2\\\"}={json2}",
|
||||
"-suppressInheritedMembers", "true");
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, args.size()).forEach(i -> {
|
||||
if (args.get(i).contains(".jar;")) {
|
||||
var jars = args.get(i).split(";");
|
||||
Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).contains(jar));
|
||||
} else {
|
||||
assertThat(args.get(i)).isEqualTo(matches.get(i));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.dokka;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class SourceSetTest {
|
||||
@Test
|
||||
void sourceSetCollectionsTest() {
|
||||
var args = new SourceSet()
|
||||
.classpath(List.of("path1", "path2"))
|
||||
.dependentSourceSets(Map.of("set1", "set2", "set3", "set4"))
|
||||
.externalDocumentationLinks(Map.of("link1", "link2", "link3", "link4"))
|
||||
.perPackageOptions(List.of("option1", "option2"))
|
||||
.samples(List.of("samples1", "samples1"))
|
||||
.suppressedFiles(List.of("sup1", "sup2"))
|
||||
.args();
|
||||
|
||||
var matches = List.of(
|
||||
"-classpath", "path1;path2",
|
||||
"-dependentSourceSets", "set1/set2;set3/set4",
|
||||
"-externalDocumentationLinks", "link3^link4^^link1^link2",
|
||||
"-perPackageOptions", "option1;option2",
|
||||
"-samples", "samples1;samples1",
|
||||
"-suppressedFiles", "sup1;sup2"
|
||||
);
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
void sourceSetTest() {
|
||||
var args = new SourceSet()
|
||||
.classpath("classpath1", "classpath2")
|
||||
.dependentSourceSets("moduleName", "sourceSetName")
|
||||
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
||||
.externalDocumentationLinks("url1", "packageListUrl1")
|
||||
.externalDocumentationLinks("url2", "packageListUrl2")
|
||||
.includes("includes1", "includes2")
|
||||
.perPackageOptions("options1", "options2")
|
||||
.samples("samples1", "sample2")
|
||||
.srcLink("path1", "remote1", "#suffix1")
|
||||
.srcLink("path2", "remote2", "#suffix2")
|
||||
.src("src1", "src2")
|
||||
.suppressedFiles("sup1", "sup2")
|
||||
.analysisPlatform(AnalysisPlatform.JVM)
|
||||
.apiVersion("1.0")
|
||||
.displayName("name")
|
||||
.jdkVersion(18)
|
||||
.languageVersion("2.0")
|
||||
.noJdkLink(true)
|
||||
.noSkipEmptyPackages(true)
|
||||
.noStdlibLink(true)
|
||||
.reportUndocumented(true)
|
||||
.skipDeprecated(true)
|
||||
.sourceSetName("setName")
|
||||
.args();
|
||||
|
||||
var matches = List.of(
|
||||
"-analysisPlatform", "jvm",
|
||||
"-apiVersion", "1.0",
|
||||
"-classpath", "classpath1;classpath2",
|
||||
"-dependentSourceSets", "moduleName/sourceSetName",
|
||||
"-displayName", "name",
|
||||
"-documentedVisibilities", "package;private",
|
||||
"-externalDocumentationLinks", "url1^packageListUrl1^^url2^packageListUrl2",
|
||||
"-jdkVersion", "18",
|
||||
"-includes", "includes1;includes2",
|
||||
"-languageVersion", "2.0",
|
||||
"-noJdkLink", "true",
|
||||
"-noSkipEmptyPackages", "true",
|
||||
"-noStdlibLink", "true",
|
||||
"-reportUndocumented", "true",
|
||||
"-perPackageOptions", "options1;options2",
|
||||
"-samples", "samples1;sample2",
|
||||
"-skipDeprecated", "true",
|
||||
"-src", "src1;src2",
|
||||
"-srcLink", "path1=remote1#suffix1;path2=remote2#suffix2",
|
||||
"-sourceSetName", "setName",
|
||||
"-suppressedFiles", "sup1;sup2");
|
||||
|
||||
assertThat(args).hasSize(matches.size());
|
||||
|
||||
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
||||
}
|
||||
}
|
393
src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java
Normal file
393
src/test/java/rife/bld/extension/kotlin/CompileOptionsTest.java
Normal file
|
@ -0,0 +1,393 @@
|
|||
/*
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.kotlin;
|
||||
|
||||
import org.assertj.core.api.AutoCloseableSoftAssertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
class CompileOptionsTest {
|
||||
/**
|
||||
* Returns the local path of the given file names.
|
||||
*
|
||||
* @param fileNames The file names
|
||||
* @return the local path
|
||||
*/
|
||||
private String localPath(String... fileNames) {
|
||||
return Arrays.stream(fileNames).map(it -> new File(it).getAbsolutePath())
|
||||
.collect(Collectors.joining(File.pathSeparator));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("PMD.UnitTestShouldIncludeAssert")
|
||||
void testArgs() {
|
||||
var options = new CompileOptions()
|
||||
.apiVersion("11")
|
||||
.javaParameters(true)
|
||||
.jvmTarget("11")
|
||||
.includeRuntime(true)
|
||||
.jdkHome(new File("path"))
|
||||
.jdkRelease("11")
|
||||
.kotlinHome(new File("path"))
|
||||
.languageVersion("1.0")
|
||||
.moduleName("module")
|
||||
.noJdk(true)
|
||||
.noReflect(true)
|
||||
.noWarn(true)
|
||||
.optIn("opt1", "opt2")
|
||||
.options("-foo", "-bar")
|
||||
.path("path")
|
||||
.plugin("id", "name", "value")
|
||||
.progressive(true)
|
||||
.scriptTemplates("name", "name2")
|
||||
.verbose(true)
|
||||
.wError(true)
|
||||
.wExtra(true);
|
||||
|
||||
var matches = List.of(
|
||||
"-api-version", "11",
|
||||
"-java-parameters",
|
||||
"-jvm-target", "11",
|
||||
"-include-runtime",
|
||||
"-jdk-home", localPath("path"),
|
||||
"-Xjdk-release=11",
|
||||
"-kotlin-home", localPath("path"),
|
||||
"-language-version", "1.0",
|
||||
"-module-name", "module",
|
||||
"-no-jdk",
|
||||
"-no-reflect",
|
||||
"-nowarn",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
"-foo",
|
||||
"-bar",
|
||||
"-d", localPath("path"),
|
||||
"-P", "plugin:id:name:value",
|
||||
"-progressive",
|
||||
"-script-templates", "name,name2",
|
||||
"-verbose",
|
||||
"-Werror",
|
||||
"-Wextra");
|
||||
|
||||
var args = new ArrayList<List<String>>();
|
||||
args.add(options.args());
|
||||
args.add(options.apiVersion(11).jvmTarget(11).args());
|
||||
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
for (var a : args) {
|
||||
IntStream.range(0, a.size()).forEach(i -> softly.assertThat(a.get(i))
|
||||
.as(a.get(i) + " == " + matches.get(i)).isEqualTo(matches.get(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArgsCollections() {
|
||||
var advanceOptions = List.of("-Xoption1", "option=2");
|
||||
var argFile = List.of(new File("arg1.txt"), new File("arg2.txt"));
|
||||
var classpath = List.of(new File("path1"), new File("path2"));
|
||||
var optIn = List.of("opt1", "opt2");
|
||||
var options = List.of("-foo", "-bar");
|
||||
var plugin = List.of("id:name:value", "id2:name2:value2");
|
||||
var scriptTemplates = List.of("temp1", "temp2");
|
||||
|
||||
var op = new CompileOptions()
|
||||
.advancedOptions(advanceOptions)
|
||||
.argFile(argFile)
|
||||
.classpath(classpath)
|
||||
.noStdLib(false)
|
||||
.optIn(optIn)
|
||||
.options(options)
|
||||
.scriptTemplates(scriptTemplates);
|
||||
|
||||
plugin.forEach(it -> {
|
||||
var p = it.split(":");
|
||||
op.plugin(p[0], p[1], p[2]);
|
||||
});
|
||||
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
softly.assertThat(op.advancedOptions()).as("advancedOptions")
|
||||
.hasSize(advanceOptions.size()).containsAll(advanceOptions);
|
||||
softly.assertThat(op.argFile()).as("argFile")
|
||||
.hasSize(argFile.size()).containsAll(argFile);
|
||||
softly.assertThat(op.classpath()).as("classpath")
|
||||
.hasSize(classpath.size()).containsAll(classpath);
|
||||
softly.assertThat(op.optIn()).as("optIn")
|
||||
.hasSize(optIn.size()).containsAll(optIn);
|
||||
softly.assertThat(op.options()).as("options")
|
||||
.hasSize(options.size()).containsAll(options);
|
||||
softly.assertThat(op.plugin()).as("plugin")
|
||||
.hasSize(plugin.size()).containsAll(plugin);
|
||||
softly.assertThat(op.scriptTemplates()).as("scriptTemplates")
|
||||
.hasSize(scriptTemplates.size()).containsAll(scriptTemplates);
|
||||
}
|
||||
|
||||
var matches = List.of(
|
||||
'@' + localPath("arg1.txt"), '@' + localPath("arg2.txt"),
|
||||
"-classpath", localPath("path1", "path2"),
|
||||
"-Joption1", "-Joption2",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
"-foo", "-bar",
|
||||
"-script-templates",
|
||||
"temp1,temp2",
|
||||
"-Xoption1", "-Xoption=2",
|
||||
"-P", "plugin:id:name:value",
|
||||
"-P", "plugin:id2:name2:value2");
|
||||
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
var args = op.args();
|
||||
for (var arg : args) {
|
||||
var found = false;
|
||||
for (var match : matches) {
|
||||
if (match.equals(arg)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
softly.assertThat(found).as(arg + " not found.").isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testArgsFile() {
|
||||
var foo = new File("foo.txt");
|
||||
var bar = new File("bar.txt");
|
||||
var options = new CompileOptions();
|
||||
|
||||
options = options.argFile(foo);
|
||||
assertThat(options.argFile()).contains(foo);
|
||||
options.argFile().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
options.argFile(foo, bar);
|
||||
assertThat(options.argFile()).contains(foo, bar);
|
||||
options.argFile().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
options = options.argFile(foo.toPath(), bar.toPath());
|
||||
assertThat(options.argFile()).contains(foo, bar);
|
||||
options.argFile().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
options = options.argFile(foo.getAbsolutePath(), bar.getAbsolutePath());
|
||||
assertThat(options.argFile()).contains(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(OS.LINUX)
|
||||
void testCheckAllParams() throws IOException {
|
||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "kotlinc-args.txt"));
|
||||
|
||||
assertThat(args).isNotEmpty();
|
||||
|
||||
var params = new CompileOptions()
|
||||
.advancedOptions("Xoption")
|
||||
.apiVersion("11")
|
||||
.expression("expression")
|
||||
.includeRuntime(true)
|
||||
.javaParameters(true)
|
||||
.jdkHome("jdkhome")
|
||||
.jvmTarget(12)
|
||||
.kotlinHome("kotlin")
|
||||
.languageVersion("1.0")
|
||||
.moduleName("moduleName")
|
||||
.noJdk(true)
|
||||
.noReflect(true)
|
||||
.noStdLib(true)
|
||||
.noWarn(true)
|
||||
.optIn("annotation")
|
||||
.options("option")
|
||||
.path(new File("path"))
|
||||
.plugin("id", "option", "value")
|
||||
.progressive(true)
|
||||
.scriptTemplates("template")
|
||||
.verbose(true)
|
||||
.wError(true)
|
||||
.wExtra(true);
|
||||
|
||||
var skipArgs = List.of("-J", "-classpath", "@");
|
||||
assertThat(args).as(skipArgs + " not found.").containsAll(skipArgs);
|
||||
args.removeAll(skipArgs);
|
||||
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
for (var p : args) {
|
||||
var found = false;
|
||||
for (var a : params.args()) {
|
||||
if (a.startsWith(p)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
softly.assertThat(found).as(p + " not found.").isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClasspath() {
|
||||
var foo = new File("foo.txt");
|
||||
var bar = new File("bar.txt");
|
||||
var options = new CompileOptions();
|
||||
|
||||
options = options.classpath(foo);
|
||||
assertThat(options.classpath()).as("File").containsExactly(foo);
|
||||
options.classpath().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
|
||||
options.classpath(foo, bar);
|
||||
assertThat(options.classpath()).as("File...").containsExactly(foo, bar);
|
||||
options.classpath().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
|
||||
options.classpath(List.of(foo, bar));
|
||||
assertThat(options.classpath()).as("List(File...)").containsExactly(foo, bar);
|
||||
options.classpath().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
|
||||
options = options.classpath(foo.toPath(), bar.toPath());
|
||||
assertThat(options.classpath()).as("Path...").containsExactly(foo, bar);
|
||||
options.classpath().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
|
||||
options = options.classpathPaths(List.of(foo.toPath(), bar.toPath()));
|
||||
assertThat(options.classpath()).as("List(Path...)").containsExactly(foo, bar);
|
||||
options.classpath().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
|
||||
options.classpath(foo.getAbsolutePath(), bar.getAbsolutePath());
|
||||
assertThat(options.classpath()).as("String...")
|
||||
.containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
|
||||
options.classpath().clear();
|
||||
assertThat(options.argFile()).isEmpty();
|
||||
|
||||
options.classpathStrings(List.of(foo.getAbsolutePath(), bar.getAbsolutePath()));
|
||||
assertThat(options.classpath()).as("List(String...)")
|
||||
.containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJdkHome() {
|
||||
var foo = new File("foo.txt");
|
||||
var options = new CompileOptions();
|
||||
|
||||
options.jdkHome(foo);
|
||||
assertThat(options.jdkHome()).isEqualTo(foo);
|
||||
|
||||
options = options.jdkHome(foo.toPath());
|
||||
assertThat(options.jdkHome()).isEqualTo(foo);
|
||||
|
||||
options.jdkHome(foo.getAbsolutePath());
|
||||
assertThat(options.jdkHome().getAbsolutePath()).isEqualTo(foo.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKotlinHome() {
|
||||
var foo = new File("foo.txt");
|
||||
var options = new CompileOptions();
|
||||
|
||||
options.kotlinHome(foo);
|
||||
assertThat(options.kotlinHome()).isEqualTo(foo);
|
||||
|
||||
options = options.kotlinHome(foo.toPath());
|
||||
assertThat(options.kotlinHome()).isEqualTo(foo);
|
||||
|
||||
options.kotlinHome(foo.getAbsolutePath());
|
||||
assertThat(options.kotlinHome().getAbsolutePath()).isEqualTo(foo.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOptions() {
|
||||
var options = new CompileOptions()
|
||||
.advancedOptions("xopt1", "xopt2")
|
||||
.apiVersion("11")
|
||||
.argFile(Path.of("args.txt"))
|
||||
.classpath("classpath")
|
||||
.expression("expression")
|
||||
.includeRuntime(true)
|
||||
.javaParameters(true)
|
||||
.jdkHome("jdk-home")
|
||||
.jdkRelease(22)
|
||||
.jvmTarget("9")
|
||||
.kotlinHome("kotlin-home")
|
||||
.languageVersion("1.0")
|
||||
.moduleName("module")
|
||||
.noJdk(true)
|
||||
.noReflect(true)
|
||||
.noStdLib(true)
|
||||
.noWarn(true)
|
||||
.optIn("opt1", "opt2")
|
||||
.options("-foo", "-bar")
|
||||
.path(Path.of("path"))
|
||||
.plugin("id", "name", "value")
|
||||
.progressive(true)
|
||||
.scriptTemplates("name", "name2")
|
||||
.verbose(true)
|
||||
.wError(true)
|
||||
.wExtra(true);
|
||||
|
||||
try (var softly = new AutoCloseableSoftAssertions()) {
|
||||
softly.assertThat(options.advancedOptions()).containsExactly("xopt1", "xopt2");
|
||||
softly.assertThat(options.apiVersion()).isEqualTo("11");
|
||||
softly.assertThat(options.argFile()).containsExactly(new File("args.txt"));
|
||||
softly.assertThat(options.classpath()).containsExactly(new File("classpath"));
|
||||
softly.assertThat(options.expression()).isEqualTo("expression");
|
||||
softly.assertThat(options.isIncludeRuntime()).isTrue();
|
||||
softly.assertThat(options.isJavaParameters()).isTrue();
|
||||
softly.assertThat(options.isNoJdk()).isTrue();
|
||||
softly.assertThat(options.isNoReflect()).isTrue();
|
||||
softly.assertThat(options.isNoStdLib()).isTrue();
|
||||
softly.assertThat(options.isNoWarn()).isTrue();
|
||||
softly.assertThat(options.isProgressive()).isTrue();
|
||||
softly.assertThat(options.isVerbose()).isTrue();
|
||||
softly.assertThat(options.jdkHome()).isEqualTo(new File("jdk-home"));
|
||||
softly.assertThat(options.jdkRelease()).isEqualTo("22");
|
||||
softly.assertThat(options.jvmTarget()).isEqualTo("9");
|
||||
softly.assertThat(options.kotlinHome()).isEqualTo(new File("kotlin-home"));
|
||||
softly.assertThat(options.languageVersion()).isEqualTo("1.0");
|
||||
softly.assertThat(options.moduleName()).isEqualTo("module");
|
||||
softly.assertThat(options.optIn()).containsExactly("opt1", "opt2");
|
||||
softly.assertThat(options.options()).containsExactly("-foo", "-bar");
|
||||
softly.assertThat(options.path()).isEqualTo(new File("path"));
|
||||
softly.assertThat(options.plugin()).containsExactly("id:name:value");
|
||||
softly.assertThat(options.scriptTemplates()).containsExactly("name", "name2");
|
||||
softly.assertThat(options.isWError()).isTrue();
|
||||
softly.assertThat(options.isWExtra()).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
78
src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java
Normal file
78
src/test/java/rife/bld/extension/kotlin/JvmOptionsTest.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright 2023-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package rife.bld.extension.kotlin;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
class JvmOptionsTest {
|
||||
@Test
|
||||
void testop() {
|
||||
var op = new CompileKotlinOperation().jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED));
|
||||
assertThat(op.jvmOptions()).as(JvmOptions.ALL_UNNAMED).containsExactly("--enable-native-access=ALL-UNNAMED");
|
||||
|
||||
op = new CompileKotlinOperation().jvmOptions(new JvmOptions().enableNativeAccess("m1", "m2"));
|
||||
assertThat(op.jvmOptions()).as("m1,m2").containsExactly("--enable-native-access=m1,m2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEnableNativeAccess() {
|
||||
var options = new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED);
|
||||
assertThat(options).as(JvmOptions.ALL_UNNAMED).containsExactly("--enable-native-access=ALL-UNNAMED");
|
||||
|
||||
options = new JvmOptions().enableNativeAccess("m1");
|
||||
assertThat(options).as("m1").containsExactly("--enable-native-access=m1");
|
||||
|
||||
options = new JvmOptions().enableNativeAccess("m1", "m2");
|
||||
assertThat(options).as("m1,m2").containsExactly("--enable-native-access=m1,m2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIllegalNativeAccess() {
|
||||
var options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW);
|
||||
assertThat(options).as("ALLOW").containsExactly("--illegal-native-access=allow");
|
||||
|
||||
options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.DENY);
|
||||
assertThat(options).as("DENY").containsExactly("--illegal-native-access=deny");
|
||||
|
||||
options = new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.WARN);
|
||||
assertThat(options).as("WARN").containsExactly("--illegal-native-access=warn");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testJvmOptions() {
|
||||
var op = new CompileKotlinOperation().jvmOptions("option1", "option2");
|
||||
assertThat(op.jvmOptions()).as("option1,option2").containsExactly("option1", "option2");
|
||||
|
||||
op = new CompileKotlinOperation().jvmOptions(List.of("option1", "option2"));
|
||||
assertThat(op.jvmOptions()).as("List.of(option1,option2)").containsExactly("option1", "option2");
|
||||
|
||||
op = op.jvmOptions(new JvmOptions().enableNativeAccess(JvmOptions.ALL_UNNAMED));
|
||||
assertThat(op.jvmOptions()).as("List.of(option1,option2,ALL_UNNAMED)")
|
||||
.containsExactly("option1", "option2", "--enable-native-access=ALL-UNNAMED");
|
||||
|
||||
op = op.jvmOptions(new JvmOptions().illegalNativeAccess(JvmOptions.NativeAccess.ALLOW));
|
||||
assertThat(op.jvmOptions()).as("allow")
|
||||
.containsExactly("option1", "option2", "--enable-native-access=ALL-UNNAMED",
|
||||
"--illegal-native-access=allow");
|
||||
}
|
||||
}
|
3
src/test/resources/argfile.txt
Normal file
3
src/test/resources/argfile.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
-Xjdk-release=17 -no-reflect
|
||||
|
||||
-progressive
|
1
src/test/resources/argfile2.txt
Normal file
1
src/test/resources/argfile2.txt
Normal file
|
@ -0,0 +1 @@
|
|||
-include-runtime
|
26
src/test/resources/kotlinc-args.txt
Normal file
26
src/test/resources/kotlinc-args.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
@
|
||||
-api-version
|
||||
-classpath
|
||||
-d
|
||||
-expression
|
||||
-include-runtime
|
||||
-J
|
||||
-java-parameters
|
||||
-jdk-home
|
||||
-jvm-target
|
||||
-kotlin-home
|
||||
-language-version
|
||||
-module-name
|
||||
-no-jdk
|
||||
-no-reflect
|
||||
-no-stdlib
|
||||
-nowarn
|
||||
-opt-in
|
||||
-P
|
||||
-progressive
|
||||
-script
|
||||
-script-templates
|
||||
-verbose
|
||||
-Werror
|
||||
-Wextra
|
||||
-X
|
Loading…
Add table
Add a link
Reference in a new issue