2

Maven に WAR プラグインを使用して複数の実行を実行させようとしています。次のように定義されている限り、正常に機能します。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
<version>1.0</version>
    <configuration>
    (...)
    </configuration>

しかし、次の方法ではありません

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <configuration>
            (...)
            </configuration>
        </execution>
    </executions>
</plugin>

<configuration>タグで定義したリソースが Maven で見つからない場合。重要なことを見逃していませんか? また、単一のビルドで複数の WAR ファイルを構築するためのより良い方法はありますか?

4

2 に答える 2

1

デフォルトで生成される war をオフにする方法はわかりませんでしたが、<executions>要素の外側で 1 つの構成を使用し、残りを内側で使用できます。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1-beta-1</version>
    <configuration>
      <classifier>with-junk</classifier>
      <!-- temp directory that the webapp is assembled in (each must be different) -->
      <webappDirectory>${project.build.directory}/build-with-junk</webappDirectory>
      <webResources>
        <resource>
          <directory>junk</directory>
          <includes>
            <include>**/*</include>
          </includes>
        </resource>
      </webResources>
    </configuration>
    <executions>
      <execution>
        <id>add-other-junk</id>
        <phase>package</phase>
        <goals>
          <goal>war</goal>
        </goals>
        <!-- exclude prior configuration -->
        <inherited>false</inherited>
        <configuration>
          <classifier>with-other-junk</classifier>
          <webappDirectory>${project.build.directory}/build-other-junk</webappDirectory>
          <webResources>
            <resource>
              <directory>other-junk</directory>
              <includes>
                <include>**/*</include>
              </includes>
            </resource>
          </webResources>
        </configuration>
      </execution>
    </executions>
  </plugin>

私にとって、これはビルドartifact-0.1-with-junk.warされartifact-0.1-with-other-junk.war、両方に正しいファイルが含まれています。

于 2009-10-23T22:48:00.110 に答える