17

次のアセンブリを構成しました。

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2-beta-5</version>
            <executions>
                <execution>
                    <id>${project.name}-test-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <appendAssemblyId>false</appendAssemblyId>
                        <finalName>${project.name}-test</finalName>
                        <filters>
                            <filter>src/assemble/test/distribution.properties</filter>
                        </filters>
                        <descriptors>
                            <descriptor>src/assemble/distribution.xml</descriptor>
                        </descriptors>
                        <attach>true</attach>
                    </configuration>
                </execution>
                <execution>
                    <id>${project.name}-prod-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <appendAssemblyId>false</appendAssemblyId>
                        <finalName>${project.name}-prod</finalName>
                        <filters>
                            <filter>src/assemble/prod/distribution.properties</filter>
                        </filters>
                        <descriptors>
                            <descriptor>src/assemble/distribution.xml</descriptor>
                        </descriptors>
                        <attach>true</attach>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

これにより、2つのzipファイルが生成されました。

  • distribution-prod.zip
  • distribution-test.zip

プロパティattach=trueに対する私の期待は、2つのzipファイルがプロパティfinalNameで指定された名前でインストールされることです。ただし、その結果、アーティファクトにインストール(添付)されるファイルは1つだけになります。Mavenプロトコルは次のとおりです。

  • distrib-0.1-SNAPSHOT.zip
  • distrib-0.1-SNAPSHOT.zip

プラグインはプロパティfinalNameの代わりにartifact-idを使用しています!これはバグですか?

最後のインストールは最初のインストールを上書きしています。この2つのファイルを異なる名前でインストールするにはどうすればよいですか?

調査ありがとうございます。ローランド

4

1 に答える 1

19

最後のインストールが最初のインストールを上書きしています。この 2 つのファイルを異なる名前でインストールするにはどうすればよいですか?

予想どおりです (これがバグかどうかはわかりませんが、アセンブリ プラグインのしくみです)。これを回避するには、appendAssemblyIdプロパティをtrueand に設定し、同等の結果を得るために、finalNameto${project.name}とアセンブリidtestandに変更するprod(つまり、2 つのアセンブリ記述子を使用する) 必要があります。このようなもの:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.2-beta-5</version>
      <executions>
        <execution>
          <id>${project.name}-test-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <appendAssemblyId>true</appendAssemblyId>
            <finalName>${project.name}</finalName>
            <filters>
                <filter>src/assemble/test/distribution.properties</filter>
            </filters>
            <descriptors>
              <descriptor>src/assemble/distribution-test.xml</descriptor>
            </descriptors>
          </configuration>
        </execution>
        <execution>
          <id>${project.name}-prod-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <appendAssemblyId>true</appendAssemblyId>
            <finalName>${project.name}</finalName>
            <filters>
              <filter>src/assemble/prod/distribution.properties</filter>
            </filters>
            <descriptors>
              <descriptor>src/assemble/distribution-prod.xml</descriptor>
            </descriptors>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

wheredistribution-test.xmlおよびdistribution-prod.xmlアセンブリid testprodそれぞれ宣言します。

于 2010-05-02T14:31:32.900 に答える