How to prevent 'Error creating assembly archive distribution: A zip file cannot include itself'

匿名 (未验证) 提交于 2019-12-03 01:26:01

问题:

I have a multi module project and I want to make a zip with all sources (and other files). I use maven-assemble-plugin.

I found a way with dependencySet, but I do not want add all my module sources (and later javadoc, too) as dependencies. I tried to use moduleSet, but I get an error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (make-zip) on project test-distribution: Failed to create assembly: Error creating assembly archive distribution: A zip file cannot include itself -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (make-zip) on project test-distribution: Failed to create assembly: Error creating assembly archive distribution: A zip file cannot include itself 

My pom.xml:

<plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-assembly-plugin</artifactId>     <version>2.6</version>     <executions>         <execution>             <id>make-zip</id>             <phase>package</phase>             <goals>                 <goal>single</goal>             </goals>             <configuration>                 <descriptors>                     <descriptor>src/assemble/distribution.xml</descriptor>                 </descriptors>                 <appendAssemblyId>false</appendAssemblyId>                 <finalName>test</finalName>              </configuration>         </execution>     </executions> </plugin> 

My assembly descriptor:

<?xml version="1.0" encoding="UTF-8"?> <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">      <id>distribution</id>     <formats>         <format>zip</format>     </formats>     <includeBaseDirectory>false</includeBaseDirectory>      <moduleSets>         <moduleSet>             <useAllReactorProjects>true</useAllReactorProjects>              <sources>                  <outputDirectory>/Sources</outputDirectory>              </sources>         </moduleSet>     </moduleSets> </assembly> 

With dependencySet I could fix that problem with option useProjectArtifact, but I found no option for moduleSet. Is there any way to exclude the current project's build?

回答1:

I find a way to exclude current project's build:

<?xml version="1.0" encoding="UTF-8"?> <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">      <id>distribution</id>     <formats>         <format>zip</format>     </formats>     <includeBaseDirectory>false</includeBaseDirectory>      <moduleSets>         <moduleSet>             <useAllReactorProjects>true</useAllReactorProjects>             <excludes>                 <exclude>*:test-distribution</exclude>             </excludes>             <sources>                 <outputDirectory>/Sources</outputDirectory>             </sources>         </moduleSet>     </moduleSets> </assembly> 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!