Monday, 15 August 2011

Build war with maven plus a jar with a subset of classes -



Build war with maven plus a jar with a subset of classes -

by default building war in standard way.

however, need export collection of java classes jar share legacy reasons. there easy way this?

update: clarify, in add-on default war output , layout need jar contains:

{project.base}/src/main/java* {project.base}/src/main/resources/meta-inf/services/*

you can maven-jar-plugin.

keep <packaging>war</packaging> , maven-war-plugin (if have defined in pom) , add together maven-jar-plugin <build> configuration, defining custom class inclusions/exclusions.

example excluding class a , classes of bundle pkg of builded jar:

... <packaging>war</packaging> ... <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-war-plugin</artifactid> ... </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-jar-plugin</artifactid> <executions> <execution> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <excludes> <exclude>a.class</exclude> <exclude>pkg/**</exclude> </excludes> </configuration> </execution> </executions> </plugin> </plugins> </build>

as output, when build project maven, have war , jar (without excluded classes) in output directory.

hope helps

maven

No comments:

Post a Comment