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 maven clean output directory 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 "maven clean output directory" Watch "maven clean output directory" New topic
Author

maven clean output directory

Matthew Snow
Ranch Hand

Joined: May 02, 2007
Posts: 82
I've built a maven-archetype-webapp which builds to the target/ directory when I package the project. I want to maven to clean the target/ directory each time I package the project though. I imagine I would specify this in the build element of my pom.xml. Does anyone know how to do this?


When you break the big rules, you get a lot of little rules.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15947
    
  19

I believe it's automatic. But "mvn clean" should do a clean-only operation.


Customer surveys are for companies who didn't pay proper attention to begin with.
Matthew Snow
Ranch Hand

Joined: May 02, 2007
Posts: 82
Yes, thanks, mvn clean does clean the target directory. I don't suppose I can configure my pom.xml build element to clean before it builds the project?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15947
    
  19

No, what I meant was I think that the first think maven will do is run a clean operation in the course of a normal build. But I won't swear to it.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

From recent experience, Maven does not force a "clean" before it does a build by default. However, the usage page for the "clean" plugin describes how to enable this.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Matthew Snow
Ranch Hand

Joined: May 02, 2007
Posts: 82
Thanks for the link. That's what I was after.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: maven clean output directory
 
Similar Threads
Build problem with maven and eclipse web project
Maven or Ant + Ivy
Creating a build and deployable using Ant
What does maven "packaging = jar" mean ?
Eclipse problem regarding M2Eclipse/integrated web server