This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes How do I eliminate certain files from my Maven WAR final build? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How do I eliminate certain files from my Maven WAR final build?" Watch "How do I eliminate certain files from my Maven WAR final build?" New topic
Author

How do I eliminate certain files from my Maven WAR final build?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using Maven 3.0.4. I have some environment specific properties files (e.g. dev_hibernate.cfg.xml), all of which located in my src/main/resources directory. When building my war, I would like these environment specific files removed and so I have this in my pom.xml file …



However, when I run "mvn clean package" the .xml and .properties files are still appearing in my WAR's WEB-INF/classes directory. Can anyone tell what is wrong with the expression above or if there is a better way to do this?

Thanks, - Dave
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Can you include the <artifactId> for that plugin to make the example runnable on another machine?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
I edited my question to include the artifactId.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

Why are you copying the files again after deleting them???


JBoss In Action
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

I'm going to take a guess that the WAR file has been created during the package phase before your ant tasks are run. Perhaps try running your ant tasks in the prepare-package phase.
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Winner! Thanks, -

ps - Based on the profile used, I'm copying the files from my src/main/resources directory to the WEB-INF/classes directory. However, I don't want to include the other properties files for profiles that aren't used.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How do I eliminate certain files from my Maven WAR final build?
 
Similar Threads
How to copy generated wsdl file to WAR file?
pom.xml for maven2 users
Trying to copy xml files to end directory during hudson maven build
Maven: activating a default profile, with a twist
Building Seam projects in Eclipse