manifold
manifold copied to clipboard
How do I use Javadoc agent with Gradle?
Hello! I see Manifold provides a Maven build example here for using manifold-javadoc-agent to generate Javadoc from the sources that use the features like manifold-preprocessor. How could I achieve the same for Gradle? I tried the following but it fails:
apply plugin: 'systems.manifold.manifold-gradle-plugin'
manifold {
manifoldVersion = '2023.1.10'
}
configurations {
manifoldJavadocAgent
}
dependencies {
annotationProcessor libs.manifold.preprocessor
testAnnotationProcessor libs.manifold.preprocessor
manifoldJavadocAgent libs.manifold.javadoc.agent
manifoldJavadocAgent libs.manifold.preprocessor
}
tasks.withType(Javadoc) {
options.JFlags += '-Xbootclasspath/a:' + configurations.manifoldJavadocAgent.filter {
!it.name.startsWith('manifold-javadoc-agent')
}.asPath
options.JFlags += '-javaagent:' + configurations.manifoldJavadocAgent.filter {
it.name.startsWith('manifold-javadoc-agent')
}.singleFile
options.JFlags += '--add-modules'
options.JFlags += 'jdk.compiler'
}
Error output:
java.lang.NoClassDefFoundError: com/sun/tools/javac/util/Context
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3543)
at java.base/java.lang.Class.getMethod0(Class.java:3529)
at java.base/java.lang.Class.getMethod(Class.java:2225)
at manifold.javadoc.agent.Util.bypassJava9Security(Util.java:59)
at manifold.javadoc.agent.Util.initJavacPlugin(Util.java:30)
at jdk.javadoc/jdk.javadoc.internal.tool.JavadocTool.getEnvironment(JavadocTool.java)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:546)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:393)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:342)
at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
I'm using JDK 17 and Gradle 8.1.1. Any advices would be appreciated. In the future, it would be awesome if manifold-gradle-plugin configures all Javadoc tasks automatically, so a user doesn't have to do any customization by themselves.
Gentle ping :pray:
@trustin I’ll see about providing gradle example soon. Integrating this into the gradle plugin is a great idea, thanks.
Thanks, @rsmckinney!
@trustin It is an honor to see the author of Netty here! I am the user of Netty from the times you had forked it from your Apache Mina.
I am considering to start using Manifold. Do you use it or was it a theoretical question? 🙏😅