如何防止“创建装配体归档文件分发时出错:zip文件不能包含自身" [英] How to prevent 'Error creating assembly archive distribution: A zip file cannot include itself'

查看:379
本文介绍了如何防止“创建装配体归档文件分发时出错:zip文件不能包含自身"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多模块项目,我想用所有源文件(和其他文件)创建一个zip文件.我使用 maven-assemble-plugin .

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

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

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

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

我的程序集描述符:

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

使用dependencySet我可以使用选项 useProjectArtifact来解决该问题. ,但我找不到moduleSet的任何选项.有什么办法可以排除当前项目的构建?

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?

推荐答案

我找到了

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>

这篇关于如何防止“创建装配体归档文件分发时出错:zip文件不能包含自身"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆