maven-assembly-plugin Windows与Linux

问题描述

我有一个使用maven-assembly-plugin的项目,在Linux和Windows上构建时,我看到了行为上的差异。每个平台上使用的pom.xml和assembly.xml完全相同。

Windows:

mvn日志记录如下:

[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) @ foo ---
[INFO] Building jar: C:\foo\target\foo.jar
[INFO]
[INFO] --- maven-assembly-plugin:3.1.0:single (default) @ foo ---
[INFO] Reading assembly descriptor: assembly.xml
[INFO] copying files to C:\foo\target\foo
[WARNING] Assembly file: C:\foo\target\foo is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.

在目标目录中,我观察到目录C:\ foo \ target \ foo,其中包含项目的所有相关jar。

Linux:

mvn日志记录如下:

[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) @ foo ---
[INFO] Building jar: /home/<user>/foo/target/foo.jar
[INFO] 
[INFO] --- maven-assembly-plugin:3.1.0:single (default) @ foo ---
[INFO] Reading assembly descriptor: assembly.xml
[INFO] copying files to /home/<user>/foo/target/foo-1.0.0001
[WARNING] Assembly file: /home/<user>/foo/target/foo-1.0.0001 is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.

但是在目标目录中没有目录target / foo(也没有target / foo-1.0.001)

我应该注意,下游项目期望存在target / foo目录,这就是为什么我要调查Windows和Linux在行为上的差异。

这是我pom中的插件定义:

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

这是程序集描述符:

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/3.1.0 http://maven.apache.org/xsd/assembly-3.1.0.xsd">
    <id>tar</id>
    <formats>
        <format>dir</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>

    <files>
        <file>
            <source>${project.build.directory}/${project.artifactId}.jar</source>
            <outputDirectory>./</outputDirectory>
        </file>
    </files>

    <dependencySets>
        <dependencySet>
            <unpack>false</unpack>
            <excludes>
                <exclude>${artifact}</exclude>
            </excludes>
        </dependencySet>
    </dependencySets>
</assembly>

我已经尝试在\<configuration>\<build>部分修改finalName都无济于事,并且还尝试了该插件的最新版本。

为什么在Windows上构建时会给我target \ foo目录(其中包含依赖项),而在Linux上构建后却看不到等效项?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)