Maven

Description:
Maven is a more advanced build tool than Ant, which relies on the default layout of directories, downloads the needed JAR files from the Internet.
Download at:
http://maven.apache.org
Preconditions:
JDK 5.0 should be installed
  • Open Total Commander and in one window (either the left or the right one) navigate to the file %CD%\maven\maven 2.0.4 bin.zip
  • Unzip the directory maven-2.0.4 to c:\tools.
  • Create a new System variable M2_HOME with the value c:\tools\maven-2.0.4
  • Add a new directory to the Path system variable, namely the %M2_HOME%\bin directory.

Check the installation

  • Open a DOS window window somewhere, type "mvn -version" and check the response
c:\temp>mvn -version
Maven version: 2.0.4
  • Execute the following DOS command (copy-paste the bold text on a single line):
c:\temp><<mvn archetype:create>>
    <<-DgroupId=lv.yourdomain.yourproject>>
    <<-DartifactId=your_jarfilename>>
    <<-DpackageName=lv.yourdomain.yourproject.xxx>>
  • It should create subdirectory "your_jarfilename" with the Maven's standard directory layout beneath it. Edit the Java files under your_jarfilename/src/main/java and JUnit tests under your_jarfilename/src/test/java (see JUnit tutorial on how to write JUnit tests at http://www.junit.org/index.htm ).
  • Compile, test and package (to a JAR file) is done with a single command in the "your_jarfilename" directory (i.e. the directory where pom.xml file is located):
mvn package
  • If you want to make sure that "target" subdirectory is cleaned and everything is recompiled, then type
mvn clean package