Reputation: 8292
There is an archiveClasses
option in maven-war-plugin, which packages all the classes in a single .jar, and then creates .war file with that jar in lib/ folder.
I need to do the same, but leave resource files in classes directory, so that they are still accessible from the classpath but easy to modify.
What is the easiest way to do that?
Upvotes: 8
Views: 4714
Reputation: 4554
One line answer : There are no options provided in
maven-war-plugin
to exclude the resources from the jar created usingarchiveClasses
flag.
The possible and easiest workaround for this problem is to move the files present under src/main/java/resources
directory to src/main/java/webapp/WEB-INF/classes
directory.
Upvotes: 2
Reputation: 1
you can do like this to solve the problem:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>${project.war.name}</warName>
<warSourceExcludes>**/*.class</warSourceExcludes>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
Upvotes: 0
Reputation: 662
Maybe you can try to configure your resources folder as a WebResource in the plugin configuration.
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<archiveClasses>true</archiveClasses>
<webResources>
<resource>
<directory>src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
Upvotes: 5
Reputation: 186
You should just be able to specify where those resources are. It usually looks in src/main/resources for resources, but if you need them in the java source tree you could try:
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<filtering>true</filtering>
<includes>
<include>*.xml</include>
</includes>
</resource>
</resources>
Upvotes: 0