Using maven

Maven is an awesome build tool for JAVA, but it has some long parameter names that I don’t like to remember, so I put my often used tasks of maven in batch files.


mvn install:install-file -Dfile=%1 -DgroupId=%2 -DartifactId=%3 -Dversion=%4 -Dpackaging=pom -DgeneratePom=true

This installs the specified .jar file in the local repository located in

C:\Documents and Settings\*User*\.m2\repository

where *User* is your username. Four arguments are required: jar_file, group, artifact and version.


mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=%1 -DartifactId=%2

I use this one to create new projects for stand-alone java programs. Two arguments required: group and artifact.


mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=%1 -DartifactId=%2

This one creates a new project for a web application. Two arguments required: group and artifact.

More maven commands:



This is a snipet from pom.xml (maven configuration) file that I often add after creating a new project.

Ant tasks in pom.xml

      <!-- put Ant tasks here -->

This is very useful when you have some specific tasks that you were using in Ant and you don’t know the maven equivalent or if they’re custom made.

This is just a short compilation of things that I do with maven on a regular basis. There’s a lot more to this tool than shown here, and I’m still learning it myself. You can get more information on how to get started with maven here.