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.

1
  • After reading this discussion, it seems the only way to do it is to use a profile, like the current answer.
    – Tunaki
    Oct 5, 2015 at 17:37

3 Answers 3

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'
5
  • 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. Oct 7, 2015 at 8:42
  • 1
    Also note that exclusion is possible since Maven 3.2.1 And it seems to work without the colon in front of the module name. Oct 7, 2015 at 8: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. Oct 7, 2015 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, 2017 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' May 6, 2021 at 4:14
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.

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
    
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.