The information on this page is user-contributed. Its accuracy is not verified by the Maven team!
Tips and Surprises
- <bottom> tag: If you want to include html markup, embed the text in a cdata section: e.g. <bottom><![CDATA[Copyright 2005, <a xhref=" http://www.mycompany.com">MyCompany, Inc.<a>]]></bottom>
- The @see and @link tags are not handeld correctly (see issue report: http://jira.codehaus.org/browse/MJAVADOC-28)
Examples
Using a different doclet
This example uses Sun's standard doclet:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<doclet>com.sun.tools.doclets.standard.Standard</doclet -->
<docletPath>C:\Programm Files\Java\jdk1.5.0_05\lib\tools.jar</docletPath>
</configuration>
</plugin>
Reporting
See Reporting Plugins for an example of configuring the Javadoc plugin in the <reporting> section of the pom.
Linking to external Javadocs
| Code Block | ||
|---|---|---|
| ||
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
<links>
<link>http://java.sun.com/j2se/1.4.2/docs/api</link>
<link>http://jakarta.apache.org/commons/chain/apidocs</link>
</links>
</configuration>
</plugin>
|
Aggregating Javadoc jars
Aggregating Javadoc for the website is described here.
According to this, aggregation should also work for javadoc:jar.
Example taken from here:
| Code Block | ||
|---|---|---|
| ||
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
|
Deploying Javadoc to a Remote Server (Windows, Putty, SCP)
So you want to generate Javadoc and put it on a web server for the world (or your company) to see. You just want the Javadoc; you don't want a site. And you don't want to have to set up key pairs for authentication with your web server; you just want to SCP the files with a username and password.
This is possible to do but takes a bit of maneuvering. The long and short of it is that you call the site-deploy goal of the maven-site-plugin, but tell it the site root is the apidocs directory.
To get started, give Maven the SSH login credentials for your Javadoc web server. You do this using a <server> tag in your settings.xml file.
| Code Block | ||
|---|---|---|
| ||
<server> <id>someServer</id> <username>bob</username> <password>12345</password> <filePermissions>644</filePermissions> <directoryPermissions>755</directoryPermissions> <configuration> <sshExecutable>plink</sshExecutable> <scpExecutable>pscp</scpExecutable> </configuration> </server> |
(BEGIN ASIDE: Unfortunately, the <sshExecutable> tag above is not properly parsed by the 2.0-beta-6 version of the maven-site-plugin. You will need to get the 2.0-beta-7-SNAPSHOT version for the remote copy to work. To do this, add the snapshot repository as
| Code Block | ||
|---|---|---|
| ||
<repository> <id>apache.org</id> <name>Apache Maven Snapshot Repository</name> <url>http://people.apache.org/repo/m2-snapshot-repository</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> |
and add the plugin dependency to your project POM file as
| Code Block | ||
|---|---|---|
| ||
<dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>2.0-beta-7-SNAPSHOT</version> </dependency> |
END:ASIDE)
You now need to configure the site plugin in your POM file. For starters, you want to generate Javadoc. To do this, set your reporting tag to
| Code Block | ||
|---|---|---|
| ||
<reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.4</version> </plugin> </plugins> </reporting> |
In your <build> tag, configure the site plugin to only look at the apidocs directory...
| Code Block | ||
|---|---|---|
| ||
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.0-beta-7-SNAPSHOT</version>
<configuration>
<inputDirectory>${project.reporting.outputDirectory}/apidocs</inputDirectory>
</configuration>
</plugin>
|
Finally, configure your distribution management to distribute the site to the Javadoc web server...
| Code Block | ||
|---|---|---|
| ||
<distributionManagement> <site> <id>someServer</id> <url>scpexe://somePath</url> </site> </distributionManagement> |
That should do it. Run
| Code Block |
|---|
mvn site-deploy |
and Maven should build your site and upload the Javadoc directory to your web server. If you get an error that the host is not recognized, make sure you SSH to your web server using Putty at least once in order to establish trust between your machine and the server.
