我有一个使用Maven编译的Java项目,最后使用maven-assembly-plugin将编译的JAR文件,DLL等打包成10个不同的ZIP文件。每个ZIP文件适用于不同的环境(具有不同的DLL),但其内容通常是相同的。如何拥有Maven Assembly Plugin的自定义属性?
现在我使用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是我找到的最好的建议,但它不是答案。
您可以尝试在此处查看:https://github.com/khmarbaise/multienv-maven-plugin? – khmarbaise