0

我想启用我的 Maven 构建以获取所有源和 JavaDoc jar,并在多模块 Maven 项目中仅解压所有 JavaDoc jar 一次

我在 Maven 依赖插件的帮助下设法为每个子模块获取所有源和 JavaDoc jar。但我只需要一次将它们解包,而不是每个子模块。

最好的解决方案是能够解压缩项目父 POM 中指定的所有托管依赖项。知道如何实现这一目标吗?

这是我目前的解决方案:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>fetch-source</id>
      <goals>
        <goal>sources</goal>
      </goals>
    </execution>
    <execution>
      <id>fetch-doc</id>
      <goals>
        <goal>resolve</goal>
      </goals>
      <configuration>
        <classifier>javadoc</classifier>
      </configuration>
    </execution>
    <execution>
      <id>unpack-javadoc</id>
      <goals>
        <goal>unpack-dependencies</goal>
      </goals>
      <configuration>
        <classifier>javadoc</classifier>
          <useSubDirectoryPerArtifact>true</useSubDirectoryPerArtifact>
        <stripClassifier>true</stripClassifier>
      </configuration>
    </execution>
  </executions>
</plugin>
4

2 回答 2

0

好的,我最终得到了这个配置文件:

<profile>
  <id>fetchdocandsource</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>fetch-source</id>
            <goals>
              <goal>sources</goal>
            </goals>
          </execution>
          <execution>
            <id>fetch-doc</id>
            <goals>
              <goal>resolve</goal>
            </goals>
            <configuration>
              <classifier>javadoc</classifier>
            </configuration>
          </execution>
          <execution>
            <id>unpack-javadoc</id>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <classifier>javadoc</classifier>
              <useRepositoryLayout>true</useRepositoryLayout>
              <outputDirectory>${env.HOME}/javadoc</outputDirectory>
              <stripClassifier>true</stripClassifier>
              <markersDirectory>${env.HOME}/javadoc/.markers</markersDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

在当前配置中,我能够获取所有源和 JavaDoc jar 并将所有 JavaDoc 文件存储在中央目录中。拥有一个用于标记文件的中央目录(请参阅<markersDirectory/>参考资料)可以防止依赖插件为相同或不同的项目多次解压缩相同的 JavaDoc 依赖项。

于 2013-09-17T08:59:29.617 回答
0

听起来您想利用<inherited/>元素/属性来执行插件。例如:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>fetch-source</id>
      <!-- Will prevent this plugin execution in child modules. -->
      <inherited>false</inherited>
      <goals>
        <goal>sources</goal>
      </goals>
    </execution>
  </executions>
</plugin>
于 2013-09-15T18:42:16.630 回答