Setting up Javadoc aggregation in Maven

I am trying to create a cumulative Javadoc site for all the modules in my project, but I cannot configure the plugin so that it is satisfactory. Basically, I can't get it to aggregate javadocs all the time, detecting links and excluding certain packages. Essentially, it looks like the plugin configuration is completely ignored.

I have root pom.xml that references a bunch of submodules and contains the following configuration:

<modules> <module>foo</module> <module>bar</module> </modules> <build> <plugins> <plugin> <groupId>org.maven.apache.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9</version> <executions> <execution> <id>aggregate</id> <phase>site</phase> <goals> <goal>aggregate</goal> </goals> <configuration> <links> <link>http://docs.oracle.com/javase/6/docs/api</link> <link>http://static.netty.io/3.5/api</link> <link>http://google-guice.googlecode.com/git/javadoc</link> <link>http://docs.guava-libraries.googlecode.com/git-history/release/javadoc</link> <link>http://fasterxml.github.com/jackson-databind/javadoc/2.0.4</link> <link>https://developers.google.com/protocol-buffers/docs/reference/java</link> </links> <bootclasspath>${sun.boot.class.path}</bootclasspath> <additionalJOption>-J-Xmx1024m</additionalJOption> <detectJavaApiLink>true</detectJavaApiLink> <detectLinks>true</detectLinks> <excludePackageNames>*.testing.*</excludePackageNames> </configuration> </execution> </executions> </plugin> </plugins> </build> 

But when I run mvn javadoc:aggregate with this setting, I end up with the javadoc site, which has no links to any of the libraries referenced, and still includes all the testing classes.

I don’t even see how the plugin tries to download a list of packages for each advertised link source.

On the other hand, generating javadoc for each individual module works well and as expected.

How am I wrong?

+4
source share
1 answer

Plugin configurations can be placed on two levels; inside or outside the execution tag ("global").

When a configuration is inside the execution tag, it belongs to that particular execution. In your case, you will need to run mvn site to execute it, since it is tied to this phase.

When the mvn javadoc:aggregate command is used, it searches for a "global" configuration. There is no such configuration in your pom, and therefore it uses the default configuration.

Change your plugin configuration to this:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9</version> <configuration> <links> <link>http://docs.oracle.com/javase/7/docs/api</link> <link>http://static.netty.io/3.5/api</link> <link>http://google-guice.googlecode.com/git/javadoc</link> <link>http://docs.guava-libraries.googlecode.com/git-history/release/javadoc</link> <link>http://fasterxml.github.com/jackson-databind/javadoc/2.0.4</link> <link>https://developers.google.com/protocol-buffers/docs/reference/java</link> </links> <bootclasspath>${sun.boot.class.path}</bootclasspath> <additionalJOption>-J-Xmx1024m</additionalJOption> <detectJavaApiLink>true</detectJavaApiLink> <detectLinks>true</detectLinks> <excludePackageNames>*.testing.*</excludePackageNames> </configuration> <executions> <execution> <id>aggregate</id> <phase>site</phase> <goals> <goal>aggregate</goal> </goals> </execution> </executions> </plugin> 

You can put configuration inside the execution part to override and configure the configuration for this execution.

BTW <groupId> is incorrect in your pom. It should be

 <groupId>org.apache.maven.plugins</groupId> 

but not

 <groupId>org.maven.apache.plugins</groupId> 
+4
source

Source: https://habr.com/ru/post/1444489/


All Articles