aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven - Selecting the certain resource files into WAR from the default src/main/resources location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven - Selecting the certain resource files into WAR from the default src/main/resources location" Watch "Maven - Selecting the certain resource files into WAR from the default src/main/resources location" New topic
Author

Maven - Selecting the certain resource files into WAR from the default src/main/resources location

Mullin Yu
Greenhorn

Joined: Feb 24, 2005
Posts: 14


Currently, I want to exclude some files from the default src/main/resources folder into my WAR when packaging

I tried using maven-war-plugin with the following configuration but failed.

src/main/resources WEB-INF/classes *.xml

...WEB-INF/classes will still contain the XML files.

How to do so?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Can you please post a SSCCE? We can help you out easier that way.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 423

It would be really helpful if you show us the actual lines in the POM that you tried to use to exclude the files. Else have a look at http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html (second paragraph)
Mullin Yu
Greenhorn

Joined: Feb 24, 2005
Posts: 14
1. If using the following:

<webResources> <resource> <excludes> <exclude>**/log4j.xml</exclude> </excludes> </resource> <resource> <directory>${basedir}/src/main/webapp</directory> <targetPath>.</targetPath> <excludes> <exclude>**/osirisws-servlet.xml</exclude> </excludes> </resource> </webResources> <warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes>

got exception: [INFO] Trace java.lang.NullPointerException at org.apache.maven.plugin.war.AbstractWarMojo.copyResources(AbstractWarMojo.java:395) at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:325) at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:167) at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:133) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483) at – user509392 4 mins ago edit
got exception: [INFO] Trace java.lang.NullPointerException at org.apache.maven.plugin.war.AbstractWarMojo.copyResources(AbstractWarMojo.java:395) at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:325) at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:167) at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:133) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483) at

2. If using the following
<webResources> <resource><directory>${basedir}/src/main/resources</directory><targetPath>WEB-INF/classes</targetPath> <excludes> <exclude>**/log4j.xml</exclude> </excludes> </resource> <resource> <directory>${basedir}/src/main/webapp</directory> <targetPath>.</targetPath> <excludes> <exclude>**/osirisws-servlet.xml</exclude> </excludes> </resource> </webResources> <warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes> – user509392 35 secs ago edit
2. If using the following <webResources> <resource><directory>${basedir}/src/main/resources</directory><targetPath>WEB-INF/classes</targetPath> <excludes> <exclude>**/log4j.xml</exclude> </excludes> </resource> <resource> <directory>${basedir}/src/main/webapp</directory> <targetPath>.</targetPath> <excludes> <exclude>**/osirisws-servlet.xml</exclude> </excludes> </resource> </webResources> <warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes>

log4.xml still existing in WEB-INF\classes so, can't be excluded while osirisws-servlet can be excluded.
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 423

First of all: Please use code tags
Then try to replace "<warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes>" with "<warSourceExcludes>**/*.xml</warSourceExcludes>"
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Maven - Selecting the certain resource files into WAR from the default src/main/resources location