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.
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.
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.
Customer surveys are for companies who didn't pay proper attention to begin with.