一个zip文件不能包含它自己 - Maven-assembly插件

时间:2014-03-14 05:36:46

标签: maven maven-plugin maven-assembly-plugin

我正在使用maven程序集插件构建一个项目。但是这个过程失败并出现以下错误,(这里我在jenkins中粘贴了错误。我也没有jenkins检查过。)

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

4 个答案:

答案 0 :(得分:5)

在我的情况下,问题在于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)

尝试在配置中添加排除

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

答案 2 :(得分:0)

在我的情况下,我有一个空的 includes 标记。

# format to ss:fff output:
df['s_ms'] = (df['dt_s'].fillna(0).apply(lambda s: f'{int(s):02d}') + 
              ':' + 
              df['dt_ms'].fillna(0).apply(lambda s: f'{int(s):03d}'))
# df['s_ms'] 
# 0    00:000
# 1    01:641
# 2    25:575
# 3    00:589
# 4    00:629
# Name: s_ms, dtype: object

答案 3 :(得分:0)

这里你使用了带有 jar-with-dependencies 的程序集插件。这将创建一个名为 xyz-jar-with-dependencies.zip 的 zip 文件。 该错误明确指出您不能在 xyz-jar-with-dependencies.zip 中包含任何 *.zip。 因此,如果您 <excludes> <exclude>**/*.zip</exclude> </excludes> 形成程序集配置或从程序集描述符(如果您正在使用),则可以修复此错误。