我的多个使用 maven-assemble-plugin 的 Maven 项目需要将两个二进制文件复制到一个文件夹中。
这是我所有项目共有的两个原始文件:
程序运行程序
程序运行工具
我希望重复使用这组文件。它们可能来自 JAR 或 ZIP 文件等依赖项,以便稍后在我的构建过程中将它们解压。这样,如果我后来选择升级二进制文件,我可以创建我的公共项目的新版本,并且只需更改对我的公共项目的依赖项。这样做的另一个原因是因为我想最大程度地减少各个项目中与构建相关的文件的数量。
现在,棘手的部分是我需要解压依赖项时重命名每个文件。例如,对于项目A,我需要复制文件如下:
bin/projectA_procrun.exe
bin/projectA_procrunw.exe
部分解决方案
我的部分解决方案是将这两个文件放在 src/main/build/bin 文件夹中在每个 Maven 项目上.
这并不理想,但至少我能够重用公共程序集文件的内容如本页所述 http://maven.apache.org/plugins/maven-assembly-plugin/examples/sharing-descriptors.html:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>my_assembly</id>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>src/main/build/bin/procrun.exe</source>
<outputDirectory>bin</outputDirectory>
<destName>${myexecutable.name}.exe</destName>
</file>
<file>
<source>src/main/build/bin/procrunw.exe</source>
<outputDirectory>bin</outputDirectory>
<destName>${myexecutable.name}w.exe</destName>
</file>
</files>
<!-- Additional details ommitted -->
</assembly>
尝试失败
The 输出文件名映射程序集中的属性允许重命名工件,但不能重命名程序集中的文件。
一次失败的尝试是将每个文件注册为单独的 Maven 工件。这样,我可以在与我的每个工件相对应的部分中使用 outputFileNameMapping。
我遇到的问题是 Nexus 不喜欢将“exe”作为工件。
Question
关于如何通过增强我的部分或采用替代方法来实现预期结果有什么想法吗?