I would like to execute commands that will allow to build WAR files depending on execution id
My original WAR file is generated with a lot of submodules. If I need to test and build for testing only my module, I would like to build a "lighter" WAR by excluding a few jars since the build takes a lot of time. Instead would like to build a lighter WAR given some flags / commands.
As seen in the code below, I intend to skip a few dependencies/ JARs if executed with a command.
I believe you could run something similar to
mvn deploy <prefix>:<goal>:<execution-id>
as seen in Run a single Maven plugin execution? or Maven maven-exec-plugin multiple execution configurations but I have no luck so far.
Below is my pom configuration
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>exclude-few-deps</id>
<goals><goal>war</goal></goals>
<phase>package</phase>
<configuration>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webXml>src/main/resources/web.xml</webXml>
<packagingExcludes>
WEB-INF/lib/student-*.jar,
WEB-INF/lib/library-*.jar
</packagingExcludes>
</configuration>
</execution>
<execution>
<id>default-cli</id>
<goals><goal>war</goal></goals>
<phase>package</phase>
<configuration>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webXml>src/main/resources/web.xml</webXml>
</configuration>
</execution>
</executions>
</plugin>
I am unsure which command should I execute to select the execution with id
mvn war:war:@exclude-few-deps
or
mvn clean package:@exclude-few-deps
I also tried to play around with maven profiles but seems like I am unable to get this working.
Any help is appreciated.