java - Conditional inclusion of JARs in a WAR built by Maven -
i have build war file using maven include jars conditionally, each jar created seperate maven project deploys jar nexus(our organisations remote) repository
eg : have jars these core.jar,reward.jar,payment.jar,domains.jar on need build final war based on conditions(environmnet) include above jars
combination of final war(w1) w1.war : core.jar,domains.jar w1.war : core.jar,domains.jar,rewards.jar(any way specify include jar if rewards applicable)
the maven war plugin allows include/exclude jars. example:
<plugin> <artifactid>maven-war-plugin</artifactid> <version>3.1.0</version> <configuration> <packagingexcludes> web-inf/lib/excluded.jar </packagingexcludes> <packagingincludes> web-inf/lib/included.jar </packagingincludes> </configuration> </plugin>
you can associate inclusions/exclusions condition using profiles. example, let war plugin use properties (${excludedresources}, ${includedresources}) ...
<plugin> <artifactid>maven-war-plugin</artifactid> <version>3.1.0</version> <configuration> <packagingexcludes> ${excludedresources} </packagingexcludes> <packagingincludes> ${includedresources} </packagingincludes> </configuration> </plugin>
... , define values properties via profiles:
<profiles> <profile> <id>prod</id> <properties> <excludedresources>web-inf/lib/a.jar,web-inf/lib/b.jar</excludedresources> <includedresources>web-inf/lib/c.jar</includedresources> </properties> </profile> <profile> <id>tst</id> <properties> <excludedresources>web-inf/lib/x.jar,web-inf/lib/y.jar</excludedresources> <includedresources>web-inf/lib/z.jar</includedresources> </properties> </profile> </profiles>
so, can use maven war plugin's built-in ability tweak war contents , can make these tweaks conditional using maven profiles.
Comments
Post a Comment