Building MATSim with Maven

Build MATSim with Maven

Prerequisites

  • Download and install Maven. Follow the instructions you find at http://maven.apache.org/download.html
  • Download the settings.xml that provides an empty personal settings file. Copy this file to the ".m2" directory maven creates in your home directory when run for the first time. This file can be used to customize maven, if missing maven produces an annoying warning but is still working.
  •  If you want to use a plugin for Eclipse we recommend to install the m2eclipse  Eclipse plugin (http://m2eclipse.codehaus.org) that can be easily retrieved from the update site: http://m2eclipse.codehaus.org/update/

Using Maven

Note that the tests are not compiled by maven so far. As some playgrounds may contain test cases that use the MatsimTestCase class in test/src you will never be able to compile all of the playgrounds with maven unless you compile MatsimTestCase once manually. Dependency management is however working, even if the compile target fails due to dependencies to the test directory.

From the command line

  • Download MATSim from sourceforge svn.
  • Change to directory and type mvn compile
  • Maven should now start to download the libraries needed to build MATSim and to compile everything in the src directory.

Within Eclipse

  • Download MATSim from sourceforge and create a new Java-Project in Eclipse.
  • Click right on the project. If you have installed the m2eclipse plugin you have a Maven entry in the context menu. Expand it and select the option Enable Dependency Management.
  • Open the External Tools Configurations dialog (the button looks quite similar to the Run button and is located on its right hand side in the button bar of the java perspective). There you see a section Maven Build automatically created by the m2eclipse plugin. Execute the target mavenCompile to download all libraries needed for Matsim and to compile the project.
  • In the Java Perspective is now a new folder in the Package Explorer containing the dependencies managed by maven. From here you can work in eclipse as usual.

Useful commands, hints

  • You can find the  the Project Object Model description (the pom.xml) in the main folder of the matsim project.
  • Run maven with one of the default maven phases which are documented at maven.apache.org/guides/getting-started/maven-in-five-minutes.html with the following command: mvn phasename
  • To skip the tests use the -Dmaven.test.skip=true option
  • To create a jar containing all library classes execute mvn assembly:assembly

 

settings.xmlsettings.xml
415 bytes