Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Android Security Essentials Live Lessons this week in the Android 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: 15959
    
  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: 15959
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: maven clean output directory
 
Similar Threads
What does maven "packaging = jar" mean ?
Build problem with maven and eclipse web project
Maven or Ant + Ivy
Creating a build and deployable using Ant
Eclipse problem regarding M2Eclipse/integrated web server