This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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: 17148
    
  27

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


An IDE is no substitute for an Intelligent Developer.
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: 17148
    
  27

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
 
It's not a secret anymore!