Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

maven clean war

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27933
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 was born with webbed fish toes. This tiny ad is my only friend:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic