Reputation: 1825
My pom.xml looks like this (note I'm building a JAR as well as a WAR):
...
<packaging>war</packaging>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<containerConfigXML>src/main/webapp/META-INF/context.xml</containerConfigXML>
<archiveClasses>true</archiveClasses>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
However, the generated JAR only includes the classes in WEB-INF/classes. How can I get the JAR to include the classes in src/main/java/com/... etc as well - without having to add all the classes to the WEB-INF directory?
Thanks!
Upvotes: 0
Views: 2892
Reputation: 1825
Fixed by removing the archiveClasses node from the above code sample. New pom.xml looks like this:
...
<packaging>war</packaging>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<containerConfigXML>src/main/webapp/META-INF/context.xml</containerConfigXML>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
Now the generated JAR includes all classes, not just those in WEB-INF/classes
Upvotes: 1
Reputation: 13984
Generally if your resources are configured correctly (or standard layout) you should just be able to run
mvn package
Which should generate the jar file in your target directory.
Hope this helps.
Upvotes: 0