Reputation: 362
I have 5 packages
com/test1
com/test2
com/test3
com/test4
com/test4
I want to build the war only any of one or tow packages at a time. How can I achieve this?
Upvotes: 1
Views: 126
Reputation: 1179
Try this for jars:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludes>
<exclude>your_package_folder_here/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
And this for wars:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<packagingExcludes>WEB-INF/classes/your_package_folder_here/**</packagingExcludes>
</configuration>
</plugin>
Don't forget to use /**
at the end of the full path of the package folder you want to exclude /**
is for folders /*
is for files. your jar file will be placed in target without the package. Rule applies for both cases.
If you want to exclude multiple packages then my first advice is to read the plugin api first:
packagingExcludes java.lang.String 2.1-alpha-2 false true The comma separated list of tokens to exclude from the WAR before packaging. This option may be used to implement the skinny WAR use case. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[]. Hint: read the about (?!Pattern).
Then finally you could get to this example:
(...)
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<packagingExcludes>WEB-INF/classes/com/steelzack/b2b2bwebapp/excludefolder/**,WEB-INF/classes/com/steelzack/b2b2bwebapp/excludefolder2/**</packagingExcludes>
</configuration>
</plugin>
(...)
Upvotes: 1