2017-10-23 12 views
0

2つのモジュール(child1、child2)を持つマルチモジュールプロジェクトを作成しました。
私はパッケージを作成しようとしています--App.properties、child1.war、child2.warを含むべきAPP.zipはアセンブリプラグインを使用しています。私はMVNアセンブリを実行すると
は、しかし、私は以下のエラーを取得しています:シングル
コマンドマルチモジュールプロジェクトでアセンブリアーカイブを作成できません

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (default-cli) on project app: Failed to create assembly: Error creating assembly archive My_Package: You must set at least one file. -> [Help 1] 

プロジェクトのフォルダ構造

app 
    | 
    pom.xml 
    assembly.xml 
    app.properties 
    child 1 
     | 
     pom.xml src target 
        | 
        child1.war 
    child 2 
     | 
     pom.xml src target 
        | 
        child2.war 

親ポンポン(アプリ/のpom.xml)

<project> 
     <groupId>com.karthik</groupId> 
     <artifactId>parent</artifactId> 
     <packaging>pom</packaging> 
     <version>1.0-SNAPSHOT</version> 
     <name>parent</name> 

     <modules> 
      <module>child 1</module> 
      <module>child 2</module> 
     </modules> 
     <build> 
      <pluginManagement> 
       <plugins> 
        <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <configuration> 
        <finalName>APP</finalName> 
        <appendAssemblyId>false</appendAssemblyId> 
        <descriptors> 
        <descriptor>assembly.xml</descriptor> 
        </descriptors> 
       </configuration> 
       <executions> 
        <execution> 
        <id>make-bundles</id> 
        <goals> 
         <goal>single</goal> 
        </goals> 
        <phase>package</phase> 
         </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 
</project> 

assembly.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"> 
    <formats> 
     <format>zip</format> 
    </formats> 
    <id>My_Package</id> 
    <includeBaseDirectory>false</includeBaseDirectory> 
    <moduleSets> 
     <moduleSet> 
      <useAllReactorProjects>true</useAllReactorProjects> 
      <includes> 
       <include>com.karthik:child1</include> 
       <include>com.karthik:child2</include> 
      </includes> 
     </moduleSet> 
    </moduleSets> 
</assembly> 

私はこのエラーの原因となっているアセンブリ記述子で何かが間違っていると思います。
1)この問題を解決するにはどうすればよいですか& app.properties、child1.war、child2.warを含むzip(APP.zip)の作成を支援しますか?
2)いつ使用する必要がありますか<fileSet> & <moduleSet>タグ?

答えて

0

here

これを使用している実施例、親ポンポン:

<?xml version="1.0" encoding="UTF-8"?> 
<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.greg</groupId> 
    <artifactId>assembly-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 

    <name>assembly-example</name> 

    <modules> 
    <module>child1</module> 
    <module>child2</module> 
    <module>distribution</module> 
    </modules> 

    <build> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>3.1.0</version> 
      <configuration> 
      <descriptors> 
       <descriptor>src/assembly/assembly.xml</descriptor> 
      </descriptors> 
      </configuration> 
     </plugin> 
     </plugins> 
    </pluginManagement> 
    </build> 

</project> 

児童ポンポン:

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
    <groupId>com.greg</groupId> 
    <artifactId>assembly-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>child1</artifactId> 
    <packaging>jar</packaging> 

    <name>child1</name> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 
</project> 

配布ポンポン:

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
    <groupId>com.greg</groupId> 
    <artifactId>assembly-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>distribution</artifactId> 
    <packaging>jar</packaging> 

    <name>Distribution</name> 

    <dependencies> 
    <dependency> 
     <groupId>com.greg</groupId> 
     <artifactId>child1</artifactId> 
     <version>${project.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.greg</groupId> 
     <artifactId>child2</artifactId> 
     <version>${project.version}</version> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
     <plugin> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <executions> 
      <execution> 
      <id>distro-assembly</id> 
      <phase>package</phase> 
      <goals> 
       <goal>single</goal> 
      </goals> 
      <configuration> 
       <descriptors> 
       <descriptor>src/assembly/assembly.xml</descriptor> 
       </descriptors> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
</project> 
</project> 

アセンブリ。 xml

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

    <id>bin</id> 
    <formats> 
    <format>zip</format> 
    </formats> 
    <includeBaseDirectory>false</includeBaseDirectory> 
    <moduleSets> 
    <moduleSet> 
     <useAllReactorProjects>true</useAllReactorProjects> 
     <includes> 
     <include>com.greg:child1</include> 
     </includes> 
     <binaries> 
     <outputDirectory>modules/maven-assembly-plugin</outputDirectory> 
     <unpack>false</unpack> 
     </binaries> 
    </moduleSet> 
    </moduleSets> 
</assembly> 

mvn clean package p 

は、zipファイルを生成します:配布/ SRC /組立ディレクトリ内

jar tvf distribution/target/distribution-1.0-SNAPSHOT-bin.zip 
    0 Mon Oct 23 14:55:10 BST 2017 modules/ 
    0 Mon Oct 23 14:55:10 BST 2017 modules/maven-assembly-plugin/ 
    2086 Mon Oct 23 14:55:06 BST 2017 modules/maven-assembly-plugin/child1-1.0-SNAPSHOT.jar 
    2086 Mon Oct 23 14:55:08 BST 2017 modules/maven-assembly-plugin/child2-1.0-SNAPSHOT.jar 
+0

お返事ありがとうございます。しかし、mvn packageコマンドを実行してもアセンブリは作成されません。また、バイナリセクションの出力ディレクトリの値はどうでしょうか? – Karthik

+0

また、assembly.xmlにmoduleSetを保持しています。配布モジュールのassembly.xmlは、他のモジュール - 子1と子2を見つけることができますか? – Karthik

+0

私は実例への答えを変えました。 –

1

は最後に、私は解決策に

1を発見した)別のモジュールを追加 - での組み立てに分布を親POM。

POM

<project> 
     <groupId>com.karthik</groupId> 
     <artifactId>parent</artifactId> 
     <packaging>pom</packaging> 
     <version>1.0-SNAPSHOT</version> 
     <name>parent</name> 

     <modules> 
      <module>child 1</module> 
      <module>child 2</module> 
      <module>distribution</module> 
     </modules> 
</project> 

2)分配モジュールにPOM

<parent> 
     <groupId>com.karthik</groupId> 
     <artifactId>parent</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>distribution</artifactId> 
    <packaging>pom</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Distribution</name> 

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

3)ファイル/アーチファクトがアセンブリ・ディスクリプタの<files>要素で組み立てることに追加

分配モジュールをMavenのアセンブリのプラグインを構成する親

assembly.xml

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> 
    <id>distribution</id> 
    <formats> 
     <format>zip</format> 
    </formats> 
    <files> 
     <file> 
      <source>../Child1/target/child1.war</source> 
     </file> 
     <file> 
      <source>../Child2/target/child2.war</source> 
     </file> 
     <file> 
      <source>../app.properties</source> 
     </file> 
    </files> 
</assembly> 
関連する問題