0

I would like to enable my Maven build to fetch all source and JavaDoc jars and to unpack all JavaDoc jars only once in a multi-module Maven project.

I managed with the help of the Maven dependency plugin to to fetch all source and JavaDoc jars for every sub-module. But I need them only once to be unpacked and not for every sub-module.

The best solution would be to be able to unpack all managed dependencies specified in the project parent POM. Any idea how to achieve this?

Here is my current solution:

<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

<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 に答える
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 に答える