Pojos in Maven 2, filtering classes
I'm deploying a we开发者_JS百科b application to a service which requires me to package some of the classes to a Jar file.
So in example having the following source tree:
com.enterprise
|------ package1
|------ package2
|------ package3
How can I create a jar including only classes from package1 and package3 but not package2?
You can configure the Maven jar plugin with the maven.jar.excludes
property that contains a list of what paths don't get included into the jar file. To my knowledge this property is automatically used when invoking mvn jar:jar
.
Or you can directly configure the plugin to include/exclude paths:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
...
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>client</classifier>
<excludes>
<exclude>**/service/*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Configure the jar plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<excludes>
<exclude>com/yourcompany/package2/*</exclude>
</excludes>
</configuration>
</plugin>
You probably want to do this inside a profile
精彩评论