汇编插件无法复制 Java 运行时映像



我正在使用汇编插件将JRT(Java运行时映像(和一些应用程序资源聚合到最终用户分布中。使用我们非常简单:

pom.xml

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly-win64</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<outputDirectory>dist/win64</outputDirectory>
<descriptors>
<descriptor>src/main/assembly/windows.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>

windows.xml

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>windows</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
... more resources
<fileSet>
<directory>target/runtime-images/win64</directory>
<outputDirectory>app</outputDirectory>
</fileSet>
</fileSets>
</assembly>

所有路径都是100%正确的。然而,如果target/runtime-images/win64包含实际的JRT映像,汇编插件就会忽略它

[DEBUG] FileSet[app/] dir perms: -1 file perms: -1
[DEBUG] The archive base directory is 'null'

没有复制尝试,没有错误,什么都没有。我怎么知道这条路是正确的?因为如果我把一些垃圾文件放在同一个目录(而不是JRT映像(中,一切都会像一个符咒一样工作。

我使用Windows,所以似乎不需要特定的文件权限魔术。

其他人也面临过同样的问题吗?或者有什么Maven替代程序集插件的方案吗?

哇,我发现问题了。这不是很明显,所以我把它贴在这里,也许它曾经帮助过别人。

我已经在parent-pom中声明了所有插件。没有配置,只有版本,所以我不必在每个子模块中指定插件版本。

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${plugin.assembly.version}</version>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>${plugin.moditect.version}</version>
</plugin>
</plugins>
</build>

然后在子模块中,我使用了这些插件,以便执行它们。

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
... configuration
</executions>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<executions>
... configuration
</executions>
</plugin>
</plugins>
</build>

但是Maven从父pom继承了插件顺序。我从没想过这件事会这么愚蠢。

最新更新