Thursday, 15 March 2012

java - Maven and JavaDoc: install additional (generated) files -



java - Maven and JavaDoc: install additional (generated) files -

my project can generate additional help files automatically source code.

how have maven install these files generated javadoc package?

i couldn't fingure out how have maven:

run class generate additional documentation, e.g. compile , launch src/main/java/mypackage/listoptions.java aka mypackage.listoptions produce list of available options/modules/examples/etc. .

install output files (i maven install files src/main/javadoc/resources site/apidocs/resources subfolder; want documentation live in top level site/apidocs folder; more exactly don't care site part @ all, having finish documetation in mypackage-0.1.0-snapshot-javadoc.jar; including non-javadoc-generated auxillary info linked javadoc).

minimal illustration - plugin configuration maven:

<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-javadoc-plugin</artifactid> <version>2.9.1</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> <configuration> <docfilessubdirs>true</docfilessubdirs> </configuration> </plugin>

directory layout:

./pom.xml ./src/main/java/foobar/generatenonstatic.java ./src/main/javadoc/staticfile.js ./src/main/javadoc/resources/insubfolder.png

mvn package produces: javadoc in ./target/apidocs , ./target/foobar-0.0.1-snapshot-javadoc.jar. file target/apidocs/resources/insubfolder.png ends in folder target/apidocs/resources (and .jar), staticfile.js not installed.

how run generatenonstatic.java have output included in javadoc .jar unclear me. don't see hook have exec:exec run after javadoc, , before ./target/foobar-0.0.1-snapshot-javadoc.jar built...

eric,

if uncomfortable modifying javadoc executable, alternative break apart javadoc phone call 2 separate steps (javadoc , jar) , create phone call between them manipulating maven build lifecycle via <phase> tag:

phase: generate-sources => maven-javadoc-plugin:javadoc phase: compile => exec-maven-plugin:java phase: bundle => maven-javadoc-plugin:jar

note: utilize exec:java, not exec:exec run java classes

<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-javadoc-plugin</artifactid> <version>2.9.1</version> <executions> <execution> <id>generate-javadocs</id> <phase>generate-sources</phase> <goals> <goal>javadoc</goal> </goals> </execution> <execution> <id>attach-javadocs</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>exec-maven-plugin</artifactid> <version>1.3.2</version> <executions> <execution> <id>generate-nonstatic-javadocs</id> <phase>compile</phase> <goals> <goal>java</goal> </goals> <configuration> <mainclass>foobar.generatenonstatic</mainclass> </configuration> </execution> </executions> </plugin>

java maven javadoc

No comments:

Post a Comment