How to avoid duplication of forking when creating aggregated javadoc in a project with several modules

I am trying to configure a Maven multimodule project to create a zip distribution through a build plugin that should include aggregated javadoc for all submodules in the project.

Project structure (simplified, in fact there are about 20 modules):

Project X Core +- pom.xml (1) +- module-A | +- pom.xml (2) +-module-B | +- pom.xml (3) +-assembly +- pom.xml (4) 

where assembly is the submodule that creates the zip distribution. The root pom lists all the submodules as modules, each pom submodule in turn has a root pom as a parent. The build plugin is bound to the package phase. All this is wonderful.

The problem occurs when I try to create aggregated javadoc (not javadoc jars, but a directory with html) to include it in the assembly. To do this, I configured maven-javadoc-plugin as an assembly plugin in the root pump, as shown below:

  <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <configuration> <source>1.6</source> <encoding>utf8</encoding> <quiet>true</quiet> <links> <link>http://docs.oracle.com/javase/6/docs/api/</link> </links> </configuration> <executions> <execution> <id>create-javadoc</id> <phase>package</phase> <goals> <goal>aggregate</goal> </goals> </execution> </executions> </plugin> 

In addition, I configured my assembly descriptor in the assembly submodule to include fileSet with javadocs selected from the destination directory of its parent project:

  <fileSet> <directory>../target/site/apidocs</directory> <outputDirectory>docs/apidocs</outputDirectory> </fileSet> 

The problem that I am encountering with this setting is this: I see the following output when running mvn package :

 [INFO] Reactor Build Order: [INFO] [INFO] Project X Core [INFO] Project X: module A [INFO] Project X: module B [INFO] Project X: assembly [INFO] ------------------------------------------------------------------------ [INFO] Building Project X Core 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-core --- [INFO] [INFO] --- animal-sniffer-maven-plugin:1.13:check (default) @ projectX-core --- [INFO] Checking unresolved references to org.codehaus.mojo.signature:java16:1.0 [INFO] [INFO] >>> maven-javadoc-plugin:2.10.1:aggregate (create-javadoc) > generate-sources @ projectX-core >>> [INFO] [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] Forking Project X Core 1.0.0-SNAPSHOT [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-core --- [INFO] [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] Forking Project X: module A 1.0.0-SNAPSHOT [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modA --- [INFO] [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] Forking Project X: module B 1.0.0-SNAPSHOT [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modB --- Downloading: https://example.org/repositories/snapshots/org/example/project/projectX-modB/1.0.0-SNAPSHOT/modB-1.0.0-20141121.022310-7.jar [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] Forking Project X: Assembly 1.0.0-SNAPSHOT [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Downloading: https://example.org/repositories/snapshots/org/example/project/projectX-modC/1.0.0-SNAPSHOT/maven-metadata.xml 2/2 KB (snip for brevity) [INFO] ------------------------------------------------------------------------ [INFO] Building Project X: module A 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modA --- [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ projectX-modA --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/jeen/Projects/projectX/modA/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ projectX-modA --- [INFO] Compiling 52 source files to /Users/jeen/Projects/projectX/modA/target/classes [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ projectX-modA --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/jeen/Projects/projectX/modA/util/src/test/resources [INFO] [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ projectX-modA --- [INFO] Building jar: /Users/jeen/Projects/projectX/modA/target/modA-1.0.0-SNAPSHOT.jar [INFO] [INFO] >>> maven-javadoc-plugin:2.10.1:aggregate (create-javadoc) > generate-sources @ projectX-modA >>> [INFO] [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] Forking Project X Core 1.0.0-SNAPSHOT [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-core --- [INFO] [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] Forking Project X Module A 1.0.0-SNAPSHOT [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] [INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ projectX-modA --- [INFO] [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [INFO] Forking ProjectX Module B 1.0.0-SNAPSHOT [INFO] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ..... 

This is just a snippet, but these "Forking" messages are repeated many times for each submodule (in fact, actually about 60 times per module). It bothers me: it seems like a lot of duplication work is going on. The second thing that bothers me is that it seems to upload deleted snapshots of artifacts that are part of the current reactor (see "Downloading" messages in the snippet above). I should note that, despite all these repeated messages, the goal is achieved: the aggregate javadoc is created and included in the assembly.

So the question really is: what (if anything) am I doing wrong? Should I just ignore these repeated "Forking" messages and upload snapshots, or are they a sign of a misconfiguration? If the latter, does anyone have an idea how should I adjust the settings to make this work correctly?

FWIW I already tried several alternative configurations, including moving the javadoc plugin configuration to the build submodule, but none of them gave the expected results.

I tried to keep him informed and, if necessary, let me know more information.

Launching Maven 3.2.3, by the way.

+7
maven maven-assembly-plugin maven-javadoc-plugin
source share
1 answer

I seem to have found the answer to my question.

The problem is the javadoc plugin configuration. Since the plugin is located in the assembly section of the aggregator project, it is inherited by submodules (which, apparently, each of them executes in turn).

Just making sure that the plugin is not getting inherited, fixed the problem:

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <inherited>false</inherited> ... 
+3
source share

All Articles