2015-11-22 209 views
7

我有一個名爲MOD1模塊,我試圖用mvn assembly:assembly從應用程序文件夾添加到文件夾中/project jars一個maven多模塊項目,應用程序pom.xml的位置。錯誤創建組件歸檔斌:必須至少設置一個文件

錯誤:

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

項目文件夾結構:

app 
    | pom.xml 
    | src | main  | ... 
wrapper 
    | pom.xml 
    | src | main  | ... 
mod1 
    | pom.xml 
    | src | main  | ... 

// After mvn assembly:assembly 

project jars 
    | mod1.jar 

MOD1的pom.xml

<project> 
    <groupId>org.test</groupId> 
    <artifactId>mod1</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 
</project> 

包裝的pom.xml

<groupId>org.test.app</groupId> 
<artifactId>wrapper</artifactId> 
<version>1.0-SNAPSHOT</version> 
<packaging>pom</packaging> 

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

描述符(src/main/assembly/modules-assembly.xml):

<assembly> 
    <id>bin</id> 
    <baseDirectory>/</baseDirectory> 

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

    <includeBaseDirectory>false</includeBaseDirectory> 

    <moduleSets> 
     <moduleSet> 
      <useAllReactorProjects>true</useAllReactorProjects> 
      <includes> 
       <include>org.test:mod1.jar</include> 
      </includes> 
      <binaries> 
       <attachmentClassifier>jar-with-dependencies</attachmentClassifier> 
       <outputDirectory>/project jars</outputDirectory> 
       <unpack>false</unpack> 
      </binaries> 
     </moduleSet> 
    </moduleSets> 
</assembly> 

UPDATE

應用的pom.xml

<project> 
    <groupId>org.test</groupId> 
    <artifactId>app</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 

    <modules> 
    <module>../mod1</module> 
    <module>../wrapper</module> 
    </modules> 
</project> 
+0

你能試着用' org.test:MOD1',即沒有'.jar'? – Tunaki

+0

我得到了同樣的錯誤@Tunaki –

+0

你在哪裏啓動這個命令mvn assembly:assembly? –

回答

1

爲什麼你在項目 '應用程序' 的兩個模塊 '包裝',並聲明「 MOD1' 。應用程序必須在依賴庫中使用'mod1'?

這樣做:

Add parent pom.xml and 3 modules : 
    +app 
    +wrapper 
    +mod1 

POM應用:

<dependency> 
<groupId>${groupId}</groupId> 
<artifactId>mod1</artifactId> 
</dependency> 

<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-jar-plugin</artifactId> 
<configuration> 
    <archive> 
    <manifest> 
    <addClasspath>true</addClasspath> 
    <classpathPrefix>project/</classpathPrefix> 
    </manifest> 
</archive> 
</configuration> 
</plugin> 

<includes><excludes>創建assembly.xml和過濾器的依賴。

要創建裝配,使用這樣的回答: Maven build assembly with dependencies

相關問題