2014-03-14 52 views
6

我正在使用maven assembly插件构建一个项目。但这一过程失败,出现以下错误,(在这里我粘贴在詹金斯的错误。我不詹金斯检查过。)一个zip文件不能包含它本身 - Maven-assembly插件

[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 

配置在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> 
+0

也许你正在尝试保存在文件夹中创建zip文件,在该文件夹中迭代文件并添加到zip。 –

+0

是的,那是什么发生。任何想法如何使用配置来解决它 – Charls

+0

请更新到maven-assembly-plugin(2.4)的最新版本,而不是真正的旧版本。此外请显示您的完整POM文件。 – khmarbaise

回答

2

尝试加入排除你的配置:

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

以下谢谢兄弟。我解决了它。我会在下面显示。这也可能是一个解决方案。 :)(y) – Charls

4

在我的情况下,概率是与maven程序集插件的版本。默认情况下,它使用2.2版本,它有一些问题(到今天可能是他们将来修复它)。更好地使用2.1。因此,如下所示自定义我的代码现在它的工作正常

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

[请使用2.4导致它是当前版本](https://maven.apache.org/plugins/maven-assembly-plugin/)。所有其他人都过时了。 – khmarbaise

相关问题