Software Testing--- A fine Tuning Process

Software Testing--- A fine Tuning Process

Friday, 10 February 2012

Maven - Setup - Windows 7

Maven - Setup - Windows

I am writing this as I am doing the same myself on my Windows  machine. And if you are one of those developers who are still using windows for development, these windows specific uncluttered instructions and links will be of useful.

Step 1: Obtain Maven Binary: Maven 2.0.1
Fuji uses Maven based project system and its needed for you to make use of Fuji. As of this writing, 2.0.1 is latest Maven available at,
Maven 2.0.1 .
If you want to use any other version of Maven, you can find here at All Maven Binaries.

Step 2: Extract Maven
The binary that you obtained from the above step is a windows zip file. Most probably, you can extract it by double clicking it. If not, see whether you have WinZip, which is not free, but you can try it for free. You can also try extracting with WinRAR.
I always have a handy folder like "Software" on my root directory, which is easy for me to figure out what all I installed. The "Program Files" folder is too much crowded and not every software can handle the "Spaces" in the directory names.
I myself, extracted the Maven onto  C:\\Software, so that I can find maven at C:\\Software\\apache-maven-2.1.0-M1.
Step 3: Setting up of Windows Environment for Maven
The maven should be made available to those applications that needed it.  The Windows environment can be enhanced with variables to launch maven. However, its kind of global. Same maven version is available everywhere and  it doesn't offer you to choose among the various versions of maven to use with different applications. Alternatively, you can create a batch file with all the necessary commands in it for that application. You must execute this batch file, very first time after launching the command prompt. So, as usual, you have choices and need to make a choice.
Choice 1: Update Windows Environment system wide
1.1. Launch System Properties for setting up M2_HOME
You can do it by either
Right clicking "My Computer" icon generally available on your Desktop
 or
 Windows Start ->  My Computer -> View System Information
1.2. Set up Maven Home
Properties -> Advanced -> Environment Variables -> System variables -> New
Variable Name: M2_HOME
Variable Value: C:\\Software\\apache-maven-2.1.0-M1
Note: The variable value depends on where you extracted the maven. The above is as on my system.
1.3. Update Windows Path
 If you have closed System Properties window, repeat Mini Step 1 to launch it.
Properties -> Advanced -> Environment Variables -> System Variables
Select "Path" and then Click "Edit". Then Add ";%M2_HOME%\\bin" at the end and  then click "OK".
Choice 2: Make a batch file
Create a batch file, say "env.bat". The name can be anything with extension of "bat". And then have the following commands in it.
set M2_HOME=C:\\Software\\apache-maven-2.1.0-M1
set PATH=%M2_HOME%\\bin;%PATH%

And this is my choice. Simple and better control.
Step 4: Ensure Maven is Available
Open Command line prompt, Windows Start -> Run and then type, cmd. A command window opens up. If you haven't set the system wide properties, set your directory wherever env.bat is there and then type "env" at the command prompt.

If you get the following, then MVN isn't properly setup. Check your setting.
C:\\Documents and Settings\\rdara>mvn
'mvn' is not recognized as an internal or external command,
operable program or batch file.
If its success, then you will see all that mvn is displaying....