This tar ball (export-doclet-0.1.tar.gz) contains two maven project artifacts. It shows how to access the javadoc information of a project during the maven lifecycle phase ‘generate-sources’, traverse it, fill a Java object structure (export-doclet-api), marshal it to XML and include it into the jar of the artifact. Later on, you will be able to unmarshal the javadoc information. The export-doclet-api is oriented towards the doclet-api and the reflection-api and may therefore be familiar to you.
You can build the project like this:
export-doclet$ mvn clean install
Afterwards change to your project directory and add the following lines to your pom
:
<!-- ... --> <build> <!-- ... --> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.7</version> <configuration> <doclet>de.jn.doclet.ExportDoclet</doclet> <docletArtifact> <groupId>de.jn.doclet</groupId> <artifactId>export-doclet</artifactId> <version>0.1</version> </docletArtifact> <additionalparam>-dest ${project.build.directory}/generated-resources/${project.groupId}_${project.artifactId}.xml</additionalparam> <useStandardDocletOptions>false</useStandardDocletOptions> </configuration> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>javadoc</goal> </goals> </execution> </executions> </plugin> </plugins> <resources> <resource> <directory>target/generated-resources</directory> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build> <!-- ... -->
Last but not least, you should build your project artifact:
myproject$ mvn package
If the project builds successfully the target
directory should contain a generated-resources
directory containing an xml file named ${groupid}_${projectid}.xml
. This file contains the marshalled javadoc information . It will be copied to the classpath root of the jar file of your artifact.