2

親プロジェクトにリンクされている 3 つのモジュールがあります。これらすべてのプロジェクトを含む zip ファイルを作成する必要があります。Mavenアセンブリプラグインを使用して実行できることはわかっています。しかし、どの pom.xml で使用する必要がありますか。3 つのプロジェクトのリソースを 1 つの共通フォルダーにコピーする方法はありますか。同じために利用できる例はありますか。これはマルチモジュールビルドです

4

1 に答える 1

1

このような目的で最善の方法は、マルチモジュール ビルドで別のモジュールを作成することです。これにより、次の構造体が生成されます。

 root (pom.xml)
   +--- mod1 (pom.xml)
   +--- mod2 (pom.xml)
   +--- mod3 (pom.xml)
   +--- mod-package (pom.xml)

mod-package の pom.xml は次のようになります。

<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>

  <parent>
    <groupId>com.soebes.packaging.test</groupId>
    <artifactId>root</artifactId>
    <version>0.1.0-SNAPSHOT</version>
  </parent>

  <artifactId>mod-package</artifactId>
  <packaging>pom</packaging>

  <name>Packaging :: Mod Package</name>

 <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <descriptors>
            <descriptor>pack.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>package-the-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

また、mod-package/pack.xml にある pack.xml ファイルを忘れないでください。

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>pack</id>
  <formats>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <moduleSets>
    <moduleSet>
      <!-- Enable access to all projects in the current multimodule build! -->
      <useAllReactorProjects>true</useAllReactorProjects>
      <binaries>
        <outputDirectory>modules/${artifactId}</outputDirectory>
        <unpack>false</unpack>
      </binaries>
    </moduleSet>
  </moduleSets>
</assembly>
于 2012-08-04T18:05:30.840 に答える