File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

maven clean war

 
ankur rathi
Ranch Hand
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first time with maven. I've used ant before, though.

This is what a document which is given to me says:
1. Setup maven (this includes installing maven, and setting up maven's bin folder in path).
Now we have quite a few folders in our application and each folder represents a web application. These web applications are deployed as WAR files. So basically we use maven to build these web applications.
The document says:
2. Open command prompt, go into any web application folder, run following command: mavan clean war
Surprisingly this commands create a war file (web-application-folder-name.war) in target folder, the target folder is a folder in web application folder. For example, if I have a web application folder c:/application/webapp1 and I run this command from this location, I'll eventually have a war file named webapp1.war in c:/application/webapp1/target folder.
After this step I get this war file from here and deploy it on server.

I am able to do that as document suggested but have no clue what's happening behind the scene.

Let's assume maven clean war buids and generate war file for the folder from which this command was ran. Where did I define that it should place generated war file in target folder? Or it's always the case is. I am just concerned how it can work without any errors. If I run maven clean jar command, it creates jar file out of it – isn’t that folder supposed to stop it doing that. How can that web application be built as a JAR file? So many questions.
 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is by default all Maven generated war, ear, jar will be placed inside a target folder which maven creates during each run. Especially when you say mvn clean, maven actually cleans or delets the target folder and creates a new one and places the output of the build in that folder.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maven is Magic. Which is both its blessing and its curse. It automatically knows how to do things, but it's not very easy to see what it's able to do.

In the case of a WAR build, Maven uses its WAR plugin, and that's what defines the sources and targets of objects that aren't otherwise handled by core Maven. You can find the documentation on Maven's rules at maven.apache.org, although their documentation takes some getting used to. Also make sure that you don't accidentally pull documentation for Maven 1, since even though it's history, search engines readily pull up those pages.

As Jothi has noted, the standard output location for build targets as well as a number of intermediate targets is the "target" subdirectory of the Maven project. Maven will create this directory if it doesn't exist.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic