maven 无法创建程序集:创建程序集存档空值时出错:tar文件不能包含其自身

vaj7vani  于 2022-11-22  发布在  Maven
关注(0)|答案(1)|浏览(193)

我正在尝试使用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>添加到我的项目中,正如您在上面看到的。
但错误消息没有任何变化。

4nkexdtk

4nkexdtk1#

我通过添加“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>

相关问题