无法创建程序集:创建程序集归档时出错null:tar文件不能包含自身

时间:2017-01-12 13:37:12

标签: java maven

我尝试使用maven-assembly-plugin将项目打包到.tar文件中。

我已将以下插件添加到我的pom.xml文件中:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptor>src/assembly/myProjectConf.xml</descriptor>
                <finalName>my-project-${version}</finalName>
                <excludes>
                    <exclude>**/*.zip</exclude>
                    <exclude>**/*.tar</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

myProjectConf.xml具有以下内容:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.0.0 http://maven.apache.org/xsd/assembly-3.0.0.xsd">
    <formats>
        <format>tar</format>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>src/main</directory>
            <includes>
                <include>README*</include>
                <include>LICENSE*</include>
                <include>NOTICE*</include>
            </includes>
            <outputDirectory>${project.basedir}/target/packagedFiles</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>src/test</directory>
            <outputDirectory>${project.basedir}/target/packagedFiles</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>${project.basedir}/lib</directory>
            <outputDirectory>${project.basedir}/target/packagedFiles</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

但是,我得到了;

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default) on project job-manager: Failed to create assembly: Error creating assembly archive null: A tar file cannot include itself. -> [Help 1]

我查看了类似的问题How to prevent 'Error creating assembly archive distribution: A zip file cannot include itself',因此我将<excludes>添加到我的项目中,如上所示。

但是没有更改错误消息。

1 个答案:

答案 0 :(得分:0)

我通过添加“maven-clean-plugin”解决了这个问题。

<plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>auto-clean</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
相关问题