我有一個使用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