• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please post a SSCCE? We can help you out easier that way.
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all: Please use code tags
Then try to replace "<warSourceExcludes>**/osirisws-servlet.xml,**/log4j.xml</warSourceExcludes>" with "<warSourceExcludes>**/*.xml</warSourceExcludes>"
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic