[英]Arranging Profiles and Plugins in pom.xml
我的pom.xml中有這些東西
這些配置文件用於單獨的構建環境。
我需要使這兩個配置文件通用的插件。
這些通用插件應該放在哪里?
您可以簡單地將它們放在默認構建部分中。 由於這兩個配置文件都使用了插件,因此這是最好的方法。
請注意,如果不同配置文件的插件配置略有不同,則可以在插件配置中使用屬性,並在配置文件中定義這些屬性的值。
<build>
<plugins>
<plugin>
<groupId>someGroup</groupId>
<artifactId>plugin1</artifactId>
...
</plugin>
<plugin>
<groupId>someGroup</groupId>
<artifactId>plugin2</artifactId>
...
</plugin>
<plugin>
<groupId>someGroup</groupId>
<artifactId>plugin3</artifactId>
...
</plugin>
</plugins>
</build>
編輯
請注意,即使未激活任何配置文件,此解決方案也將啟用插件。 不確定這是您所需要的。 (您可能有第三個構建環境:例如,未定義配置文件的開發人員計算機)。 在這種情況下,第三個配置文件的解決方案是必經之路。
mvn clean install -Pprofile1,profile-common
要么
mvn clean install -Pprofile2, profile-common
和您在profile-common中定義的常用插件
您可以在任何給定時間激活多個配置文件。 這樣,您可以創建一個通用配置文件(profile3)並將插件保留在那里。 取決於特定配置文件的插件/配置,可以保留在特定的profile1和profile2中。
-P profile-1,profile-3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.