Maven 如何预防';创建程序集存档分发时出错:zip文件不能包含自身';

Maven 如何预防';创建程序集存档分发时出错:zip文件不能包含自身';,maven,maven-assembly-plugin,Maven,Maven Assembly Plugin,我有一个多模块项目,我想制作一个包含所有源(和其他文件)的zip。我用 我找到了一种方法,但我不想将所有模块源(以及后来的javadoc)添加为依赖项。我尝试使用,但出现错误: [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: Erro

我有一个多模块项目,我想制作一个包含所有源(和其他文件)的zip。我用

我找到了一种方法,但我不想将所有模块源(以及后来的javadoc)添加为依赖项。我尝试使用,但出现错误:

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

org.apache.maven.plugins
,但我找不到
模块集
的选项。有什么方法可以排除当前项目的生成吗?

我找到了一种方法来实现当前项目的生成:

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

分布
拉链
假的
真的
*:测试分布
/来源

我怀疑您的配置正在试图压缩的某个文件夹中创建zip文件。zip就是这样工作的,它创建文件,然后将归档文件添加到其中,因此会出现错误。这只是一个猜测,只是为了弄清楚。
<?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>