I don't understand why when I put the webResources
entry in the maven-war-plugin
, the resources are placed in the war root directory. I think it should put only in WEB-INF/classes
.
This is my maven-war-plugin
configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<!-- <configuration> <webXml>target/web.xml</webXml> </configuration> -->
<configuration>
<webResources>
<resource>
<excludes>
<exclude>dbre.xml</exclude>
</excludes>
<directory>src/main/resources</directory>
</resource>
</webResources>
<archive>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
If I delete <webResources>
entry, only default src/main/resources
files are copied to WEB-INF/classes
but isn't in root war directory.
This is the expected behaviour. Quoting maven-war-plugin
documentation:
The WAR Plugin is also capable of including resources not found in the default resource directory through the webResources parameter.
...
external-resource2.jpg
andimage2
are copied to the root of the WAR, preserving the directory structure.
And later:
By default web resources are copied to the root of the WAR
If you want to override the default target path, you can specify the <targetPath>
attribute. For example, if you want the web resources to be located inside WEB-INF
, you would configure the plugin like this:
<webResources>
<resource>
<excludes>
<exclude>dbre.xml</exclude>
</excludes>
<directory>src/main/resources</directory>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>