【发布时间】:2017-02-05 22:45:21
【问题描述】:
我有一个使用 Maven 编译的 Java 项目,最后使用 maven-assembly-plugin 将编译后的 JAR 文件、DLL 等打包到 10 个不同的 ZIP 文件中。每个 ZIP 文件用于不同的环境(具有不同的 DLL),但它们的内容通常是相同的。
现在我使用 10 个不同的 assembly.xml 文件来创建这 10 个 ZIP 文件。
问题是这些 XML 几乎相同,唯一的区别是 DLL 路径中的 1 个单词。此类文件的示例:(实际上要长得多)
<assembly>
<id>{someVariable}</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<!-- Copying DLLs: -->
<fileSet>
<directory>target/dll/{someVariable}</directory>
<outputDirectory>dll</outputDirectory>
<includes>
<include>*.dll</include>
</includes>
</fileSet>
</fileSets>
</assembly>
如您所见,我想在更多地方使用{someVariable},这是所需的功能,但我无法使其工作。希望这是可能的,这是我问题的核心。我想使用相同的 assembly.xml 文件并始终使用不同的 {someVariable} 值执行 10 次,如下所示:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-the-zip</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>src/assembly/myCommonAssembly.xml</descriptor>
</descriptors>
<properties>
<someVariable>my-value</someVariable>
</properties>
</configuration>
</execution>
</executions>
</plugin>
有可能吗?仅供参考:<properties> 部分不起作用,我只是想展示我想做的事情。
我知道我可以在poml.xml 中创建属性并在assembly.xml 中使用它们,但这并不能解决我的问题,因为我仍然需要创建 10 个不同的 assembly.xml 文件。
This 是我找到的最好的建议,但它不是答案。
【问题讨论】:
标签: maven variables properties maven-assembly-plugin