我可以使用maven javadoc插件(版本2.7)excludePackageNames属性来排除包但不包括其子包吗?

时间:2012-07-09 23:19:53

标签: maven javadoc

我有一组我正在生成javadoc的类,其中一些我想从已发布的javadoc中排除。结构如下:

com.company.package.classA
com.company.package.classB
com.company.package.subpackage.classC
com.company.package.subpackage.classD

我想排除“package”中的所有类,并在“subpackage”中包含所有类。设定:

<excludePackageNames>com.company.package</excludePackageNames>

排除了包装下的所有子包。

除了重组代码之外,有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

你可以使用 maven-javadoc-plugin为你做这件事。

2.7版及更高版本支持此功能。

示例:

<plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.8.1</version>
    <executions>
      <execution>
        <id>javadoc-jar</id>
        <phase>package</phase>
        <goals>
          <goal>jar</goal>
        </goals>
        <configuration>
          <!-- switch on dependency-driven aggregation -->
          <includeDependencySources>true</includeDependencySources>

          <dependencySourceExcludes>
            <!-- exclude ONLY commons-cli artifacts -->
            <dependencySourceExclude>commons-cli:*</dependencySourceExclude>
          </dependencySourceExcludes>
        </configuration>
      </execution>
    </executions>
  </plugin>


     <configuration>
          <!-- switch on dependency-driven aggregation -->
          <includeDependencySources>true</includeDependencySources>

          <dependencySourceIncludes>
            <!-- include ONLY dependencies I control -->
            <dependencySourceInclude>org.test.dep:*</dependencySourceInclude>
          </dependencySourceIncludes>
     </configuration>