Excluding Packages

To exclude specific packages, use <excludePackageNames/> parameter as shown below. The parameter accepts wildcard (*) characters in its value but the wildcards should either be at the start or the end of the package name. If more than one package is to be excluded, each package name must be separated either with a colon (':'), a comma (',') or a semicolon (';'). (similar to the Javadoc Tool)

For instance, with the following packages:

com.mycompany.myapp
com.mycompany.myapp.package1
com.mycompany.myapp.package1.subpackage1
com.mycompany.myapp.package1.subpackage2
com.mycompany.myapp.package1.subpackage3
com.mycompany.myapp.package1.util
com.mycompany.myapp.package2
com.mycompany.myapp.package2.subpackage4
com.mycompany.myapp.package2.subpackage5
com.mycompany.myapp.package2.util
com.mycompany.myapp.package3
com.mycompany.myapp.package3.subpackage6
com.mycompany.myapp.package3.subpackage6.subsubpackage1
com.mycompany.myapp.package3.subpackage6.subsubpackage2
com.mycompany.myapp.package3.subpackage7
com.mycompany.myapp.package3.util

You could have the following configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-javadoc-plugin</artifactId>
  <version>3.11.2</version>
  <configuration>
    <!--
    Exclude packages:
      com.mycompany.myapp.package1.subpackage1
      com.mycompany.myapp.package1.subpackage2
      com.mycompany.myapp.package1.subpackage3
      com.mycompany.myapp.package1.util
      com.mycompany.myapp.package2
      com.mycompany.myapp.package2.subpackage4
      com.mycompany.myapp.package2.subpackage5
      com.mycompany.myapp.package2.util
      com.mycompany.myapp.package3.util
    BUT include the packages:
      com.mycompany.myapp
      com.mycompany.myapp.package1
      com.mycompany.myapp.package3
      com.mycompany.myapp.package3.subpackage6
      com.mycompany.myapp.package3.subpackage6.subsubpackage1
      com.mycompany.myapp.package3.subpackage6.subsubpackage2
      com.mycompany.myapp.package3.subpackage7
    -->
    <excludePackageNames>com.mycompany.myapp.package1.*:com.mycompany.myapp.package2:com.mycompany.myapp.package2.*:*.util</excludePackageNames>
  </configuration>
</plugin>