Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples for Java 21, add Kotlin DSL gradle example #143

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ Asciidoclet may be used via a `maven-javadoc-plugin` doclet:
<configuration>
<source>11</source>
<additionalJOptions>
<additionalJOption>-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption> // <1>
<additionalJOption>-Xdoclint:all,-html,-accessibility</additionalJOption> // <2>
<additionalJOption>-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption><!-- 1 -->
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</additionalJOption><!-- 1 -->
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</additionalJOption><!-- 1 -->
<additionalJOption>-J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</additionalJOption><!-- 1 -->
<additionalJOption>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</additionalJOption><!-- 1 -->
<additionalJOption>-Xdoclint:all,-html,-accessibility</additionalJOption><!-- 2 -->
</additionalJOptions>
<doclet>org.asciidoctor.asciidoclet.Asciidoclet</doclet>
<docletArtifact>
Expand All @@ -153,20 +157,57 @@ To work around that, we have to disable these doclint categories.

Asciidoclet may be used via a doclet in the `Javadoc` task:

with Kotlin
[source,kotlin]
----
val asciiDoclet by configurations.registering

dependencies {
asciiDoclet("org.asciidoctor:asciidoclet:2.+")
}

tasks.withType<Javadoc>().configureEach { // process *all* javadoc configurations, not just the one for main
options {
doclet("org.asciidoctor.asciidoclet.Asciidoclet")
docletpath(*asciiDoclet.get().files.toTypedArray())
overview("README.adoc") // you can also point this to the traditional overview like in the groovy example
jFlags(
"--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
)
}
(options as StandardJavadocDocletOptions).apply {
addStringOption("-base-dir", project.layout.projectDirectory.asFile.path) // 1
addStringsOption("-attribute", ",").value = listOf("name=${project.name}", "version=${project.version}") // 2
}
}
----

or with groovy, this example only uses main javadoc and will not handle classes generated by source code
[source,groovy]
----
configurations {
asciidoclet
}

dependencies {
asciidoclet 'org.asciidoctor:asciidoclet:1.+'
asciidoclet 'org.asciidoctor:asciidoclet:2.+'
}

javadoc {
options.docletpath = configurations.asciidoclet.files.asType(List)
options.doclet = 'org.asciidoctor.asciidoclet.Asciidoclet'
options.overview = "src/main/java/overview.adoc"
options.jFlags = [
"--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
]
options.addStringOption "-base-dir", "${projectDir}" // <1>
options.addStringOption "-attribute", // <2>
"name=${project.name}," +
Expand Down