Adding a dependency

Introduction

Maven maintains an explicit dependency graph, which code uses which other code in order to compile. If your code requires code from other developers, either from a different playground or in form of an external java library, this dependency must be manually registered in order to keep the code compiling.

Adding another playground as a dependency

Imagine you want to write code that relies on classes in someone else's playground. To do this, you have to specify this dependency on the playground of the other person:

  • First make sure you have the playground of the other person loaded in Eclipse (see Creating Eclipse Projects from Maven Modules).
  • Open the pom.xml file in your playground
  • Switch to the dependencies view (second tab at the bottom of the editor window)
  • Click on "Add Dependency"
  • In the dialog, type in the name of the other playground you want to use
  • Select the playground from the list and click ok.
  • Save the pom.xml.

Adding another library as a dependency

First, make sure the library has a license that is compatible with the GPL that MATSim uses. Gnu.org has an extensive list of compatible and non-compatible licenses. If the license is not compatible, do not use it. Also, do not use SNAPSHOT-versions of libraries as a dependeny. Only use stable versions.

  • Open the pom.xml file in your playground
  • Switch to the dependencies view (second tab at the bottom of the editor window)
  • Click on "Add Dependency"
  • In the dialog, type in the name of the other library you want to use
  • If the library is available by Maven, it will be listed with the available versions.
  • Select the library and the correct version from the list and click ok (Do not select a SNAPSHOT-version!).
  • Save the pom file.
If the library is not available, please contact me (mrieser).

Notes

Maven prevents reusing test code between different modules, i.e. moduleA cannot use code in moduleB/src/test/java. There are some fancy tricks to circumvent this limitation, please contact me (mrieser) if you really need this feature.

Warning: Table 'watchdog' is read only query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '<em>Table &amp;#039;sessions&amp;#039; is read only\nquery: UPDATE sessions SET uid = 0, cache = 0, hostname = &amp;#039;38.107.179.232&amp;#039;, session = &amp;#039;&amp;#039;, timestamp = 1328354124 WHERE sid = &amp;#039;e972b2ab7dd755a2094beea8ac708f02&amp;#039;</em> in <em>/home01/vsp_access/matsimwww/includes/database.mysql.inc</em> on line <em>174</em>.', 2, '', 'http://matsim.org/docs/devguide/adding-a-dependency', '', '38.107.179.232', 1328354124) in /home01/vsp_access/matsimwww/includes/database.mysql.inc on line 174