Category Archives: maven

Maven : Creating simple project

  1. create a folder for the test project (D:\sandbox\junk)
  2. exceute the following from that folder
    • mvn archetype:create -DgroupId=sam.test -DartifactId=mvntest
    • Let it download some jar files
    • [INFO] Parameter: groupId, Value: sam.test
      [INFO] Parameter: packageName, Value: sam.test
      [INFO] Parameter: package, Value: sam.test
      [INFO] Parameter: artifactId, Value: mvntest
      [INFO] Parameter: basedir, Value: d:\SANDBOX\junk
      [INFO] Parameter: version, Value: 1.0-SNAPSHOT
      [INFO] project created from Old (1.x) Archetype in dir: d:\SANDBOX\junk\mvntest
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESSFUL
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 3 minutes 50 seconds
      [INFO] Finished at: Thu Mar 08 18:12:49 IST 2012
      [INFO] Final Memory: 12M/31M
      [INFO] ------------------------------------------------------------------------
      
    • pom.xml
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>sam.test</groupId>
        <artifactId>mvntest</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
      
        <name>mvntest</name>
        <url>http://maven.apache.org</url>
      
        <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
      
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
          </dependency>
        </dependencies>
      </project>
      
  3. How to perform an archetype:create from Eclipse
  4. Importing Maven 2 project to Eclipse

Installing Maven

  1. Download Maven 2.2.1
  2. Unzip it to somewhere convenient (D:\TOOLS\apache-maven-2.2.1)
  3. Add M2_HOME system variable
    • Variable Name : M2_HOME
    • Variable Value : D:\TOOLS\apache-maven-2.2.1
  4. Modify Path variable, add %M2_HOME%\bin; at the end of the Variable value field
  5. To verify, open a CMD and type mvn -version