Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A zip file cannot include itself - Maven-assembly plugin

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>
like image 855
Charls Avatar asked Mar 14 '14 05:03

Charls


2 Answers

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> 
like image 147
Charls Avatar answered Oct 14 '22 12:10

Charls


try adding Excludes in your configuration:

<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>
                <excludes>
                    <exclude>**/*.zip</exclude>
                </excludes>
     </configuration>
     </execution>
    </executions>
</plugin>
like image 3
Sunny Sharma Avatar answered Oct 14 '22 11:10

Sunny Sharma