3

I have a Maven multi module project like this:

foo-parent
    foo-module
    foo-module-new
    foo-other-module1
    foo-other-module2
    pom.xml

And when calling mvn javadoc:aggregate in foo-parent, I want to exclude the module foo-module from Javadoc generation.

Exclusion by package name with the parameter excludePackageNames doesn't work in my case because foo-module and foo-module-new have the same package name.

Arend v. Reinersdorff
  • 4,110
  • 2
  • 36
  • 40
  • After reading [this discussion](http://comments.gmane.org/gmane.comp.jakarta.turbine.maven.user/134446), it seems the only way to do it is to use a profile, like the current answer. – Tunaki Oct 05 '15 at 17:37

3 Answers3

6

Launch the following to generate javadocs only for foo-other-module1 and foo-other-module2 modules (note: always include the aggregator module, in this case foo-parent):

mvn javadoc:aggregate -pl :foo-parent,:foo-other-module1,:foo-other-module2

Since Maven 3.2.1, you can also exclude modules from your reactor, so the above simplifies to

mvn javadoc:aggregate -pl '!foo-module'
PaoloC
  • 3,817
  • 1
  • 23
  • 27
  • I think you are correct: Specifying the projects on the modules on the command line is currently the best option. Although I would have preferred to keep this logic in the pom.xml. – Arend v. Reinersdorff Oct 07 '15 at 08:42
  • 1
    Also note that [exclusion is possible since Maven 3.2.1](http://stackoverflow.com/questions/13266470/how-do-i-exclude-certain-modules-from-a-maven-build-using-the-commandline/22783633#22783633) And it seems to work without the colon in front of the module name. – Arend v. Reinersdorff Oct 07 '15 at 08:44
  • I'll accept your answer if you change it to exclusion instead of inclusion. I really think that's the better option in this case. – Arend v. Reinersdorff Oct 07 '15 at 12:04
  • For all people unable to read thoroughly (like me): The answer states explicitly that you have to add the parent module to the list of modules meant to be included. Otherwise the aggregate still contains the Javadocs from the complete project. If you understand this right from the beginning, it might save you a whole day... – Kathi Jan 27 '17 at 14:00
  • 1
    Either escape the ! with \ or surround it with single quotes. mvn javadoc:aggregate -pl \!foo-module OR mvn javadoc:aggregate -pl '!foo-module' – Jody Bleyle May 06 '21 at 04:14
1

Use maven profile.

  1. add in your pom :

     <profiles>
         <profile>
         <id>javadoc</id>
         <modules>
             <module>module_include_javadoc1</module>
             <module>module_include_javadoc2</module>
         </modules>        
         </profile>
       </profiles>
    
  2. Run this:

     mvn javadoc:aggregate -Pjavadoc
    
halfer
  • 19,824
  • 17
  • 99
  • 186
question_maven_com
  • 2,457
  • 16
  • 21
  • In this simple form, the answer won't work if all modules are specified at the top of the parent pom. Which is needed for a normal, non-Javadoc build. Generally I think a solution with profiles will be too messy. There's no easy way to exclude a module from a profile. – Arend v. Reinersdorff Oct 06 '15 at 07:23
  • Here's a more detailed answer on [how to exclude a module from a Maven reactor build](http://stackoverflow.com/questions/5539348/how-to-exclude-a-module-from-a-maven-reactor-build/11429945#11429945). – Arend v. Reinersdorff Oct 08 '15 at 07:07
1

Since maven-javadoc-plugin:3.2.0 you can use the skippedModules property to provide a comma separated list of modules to skip. For instance the following configuration would skip the foo-module module:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-javadoc-plugin</artifactId>
  <reportSets>
    <reportSet>
      <id>aggregate</id>
      <configuration>
        <skippedModules>foo-module</skippedModules>
      </configuration>
    </reportSet>
  </reportSets>
</plugin>

Alternatively, you may use the maven.javadoc.skippedModules user property to achieve the same outcome.

rmbrad
  • 952
  • 10
  • 13