You read my previous post on SCM?
Then we can continue by telling you more about maven. A great page to start is the maven project home page. For the quickies there is maven in 5 minutes.
Installation you’ll really have to figure out yourself, is no more than unzipping package and setting some path variables.
Create your first project by the following commands
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
cd my-app
With the create goal you can generate the basic project structure and a basic pom file. The cd (change directory) was only to get yourself in your new project folder in order to continue.
To get this project into eclipse simply execute the following command.
mvn eclipse:eclipse
You can then import the project into eclipse as an existing java project. Dependencies will then be added to the classpath for your eclipse project (you might have to set the M2_REPO variable in eclipse to point to your maven repository). If you don’t like the command way you can look for the maven eclipse plugin. This enables you to graphically manage your dependencies from within eclipse.
Then you can start developping, to compile use
mvn compile
You’ll see that your junit tests form the test packages are executed before compiling the project itself. This is how it should be so keep your tests up to date.
Once the project is stable you can package project facets into jar with
mvn package
To be able to use this jar as a dependency in one of your next projects you can install the jar into your repository
mvn install
So far all of this was very straight forward. Now we’ll get into more realistic situations with version control and release management.
Let us first configure our version control so we’ve got something to fall back to when we have a bad day. If you haven’t any svn set up you can read the subversion setup post. Therefore add the following lines to your pom file
…
Also you’ll want to deploy a complete project … parent pom
war and ear packaging
…
resources
o list of build tools
o http://www.javaworld.com/javaworld/jw-10-2002/jw-1011-maven.html
o http://www.ibm.com/developerworks/java/library/j-maven/
o alternative maven repo