A zip file cannot include itself - Maven-assembly plugin

Charls picture Charls · Mar 14, 2014 · Viewed 12.1k times · Source

I'm building a project using maven assembly plugin. But the process fail with the following error,(Here I pasted the error in jenkins. I checked without jenkins too.)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:29.792s
[INFO] Finished at: Fri Mar 14 10:26:58 IST 2014
[INFO] Final Memory: 26M/75M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:assembly (default) on project ExecutionBot: Failed to create assembly: Error creating     assembly archive jar-with-dependencies: A zip file cannot include itself -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Configuration in pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
  <execution>
     <goals>
       <goal>assembly</goal>
     </goals>
     <phase>package</phase>
     <configuration>
       <descriptorRefs>
         <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
      <archive>
        <manifest>
          <mainClass>com.starter.MyListner</mainClass>
        </manifest>
      </archive>
     </configuration>
     </execution>
    </executions>
</plugin>

Answer

Charls picture Charls · Mar 14, 2014

In my case the prob was with the version of the maven assembly plugin. By default it uses the version 2.2 and it has some issues (up to-today may be they'll fix it in future). Better use 2.1. So customized my code as below. Now its working fine

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.1</version>
    <executions>
         <execution>
         <goals>
            <goal>assembly</goal>
         </goals>
         <phase>package</phase>
         <configuration>
         <descriptorRefs>
             <descriptorRef>jar-with-dependencies</descriptorRef>
         </descriptorRefs>
         <archive>
        <manifest>
          <mainClass>com.starter.MyListner</mainClass>
        </manifest>
       </archive>
      </configuration>
   </execution>
   </executions>
</plugin>