2017-05-05 7 views
0

私はマルチモジュールプロジェクトを持っています。 各モジュールは、自身の/ targetフォルダ内のjar/warファイルにパッケージ化されています。マルチモジュールをzipファイルにパッケージするには?

すべてのモジュールjar/warファイルといくつかの設定ファイルをとり、すべてをzipに入れたいと思います。

どうすればよいですか?私はアセンブリプラグインで試してみましたが、これまでにやってきたのはそれぞれのモジュールのジップです。それぞれの/ targetフォルダに入っていますので、かなり無駄です^^

+0

[uber jarとは何ですか?](http://stackoverflow.com/questions/11947037/what-is-an-uber-jar) –

答えて

1

まず、別のモジュールを作成します。dist

などの新しいモジュールとして親に追加し、タイプ war含む依存関係として結果のzipファイルに表示したいすべてのモジュールを追加し、 jar <packaging>pom</packaging>は、このモジュールがどの任意のJavaコードが含まれていない原因を与えられるべきです与えられた依存関係を含むzipファイルを作成したいだけです。

<project ..> 

<packaging>pom</packaging> 

<dependencies> 
    <dependency> 
     <groupId>module-1</groupId> 
     <artifactId>module-1-artifact</artifactId> 
     <version>${project.version}</version> 
     <type>war</type> 
    </dependency> 
    <dependency> 
     <groupId>module-2</groupId> 
     <artifactId>module-2-artifact</artifactId> 
     <version>${project.version}</version> 
    </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>make-bundles</id> 
         <phase>package</phase> 
         <goals> 
          <goal>single</goal> 
         </goals> 
         <configuration> 
          <descriptors> 
           <descriptor>proj1-assembly.xml</descriptor> 
          </descriptors> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

には、以下の記述を追加します。

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> 

    <id>dist-assembly</id> 

    <formats> 
     <format>zip</format> 
    </formats> 

    <includeBaseDirectory>false</includeBaseDirectory> 

    <dependencySets> 
     <dependencySet> 
      <outputDirectory>/</outputDirectory> 
      <useProjectArtifact>false</useProjectArtifact> 
      <unpack>false</unpack> 
     </dependencySet> 
    </dependencySets> 
</assembly> 

依存関係は、実行の順序が正しくMavenので計算されていることを確認する必要があります。

このzipファイルで補足的な設定が必要な場合は、たとえば、これらのファイルをsrc/main/configに追加して、アセンブリ記述子にfileSets部分を追加できます。

+0

この回答が受け入れられない理由を理解できません:)ありがとう、それを使用して、それを投票した。 –

関連する問題