Error creating assembly archive bin: You must set at least one file

Program-Me-Rev picture Program-Me-Rev · Nov 22, 2015 · Viewed 50.7k times · Source

I have a maven multi-module project with a module called mod1 that I'm trying to add into a folder /project jars with mvn assembly:assembly from the app folder, where the app pom.xml is.

error:

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

Project folder structure:

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>

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

The descriptor (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

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

Answer

question_maven_com picture question_maven_com · Nov 22, 2015

Why you declare in the project 'app' the both modules 'wrapper' and 'mod1'. app must use 'mod1' at dependency lib?

Do this :

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

pom app :

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

Create assembly.xml and filter dependency with <includes> and <excludes>.

To create the assembly, use this answer : Maven build assembly with dependencies