3

いくつかのモジュールで構成されるMavenプロジェクトがあります。すべての依存モジュールのビルドを呼び出すために使用する単一のPOMファイルがあります。私がやりたいのは、すべてのサブモジュールのパッケージライフサイクルが完了した後、多数のファイルを1つの場所にコピーし、それらを1回圧縮することです。

antrunを調べましたが、一度実行する方法がわかりません。現在、各モジュールのパッケージフェーズで実行されます。これが私の親POMファイルです(簡略化)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<name>project</name>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
    <module>../module1</module>
    <module>../module2</module>
</modules>
<dependencies>
    ...
</dependencies>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <configuration>
                        <tasks>
                            <mkdir dir="product" />
                            <copy todir="product">
                                <fileset dir="../module1/doc/release">
                                    <include name="*.pdf" />
                                </fileset>
                                <fileset dir="../module2/doc/release">
                                    <include name="*.pdf" />
                                </fileset>
                                <fileset dir="../module1/target">
                                    <include name="*.war" />
                                </fileset>
                                <fileset dir="../module2/target">
                                    <include name="*.war" />
                                </fileset>
                            </copy>
                            <copy file="app.properties" todir="cesium" />

                            <zip basedir="product" destfile="dist.zip"></zip>

                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

<properties>
    ...
</properties>

うまくいけば、私が何をしようとしているのかが明確になります。antrunタスクは、パッケージのライフサイクルの後で、モジュールごとではなく1回だけ実行する必要があります。

私はこのステップに正しい方法でアプローチしていない可能性があることを理解していますが、Mavenでこれにアプローチする最善の方法がわかりません。どんな考えでもありがたいです。

4

1 に答える 1

2

Maven アセンブリ プラグインを試してください。

Maven アセンブリ プラグインの例を次に示します。

于 2010-08-26T15:31:20.823 に答える