-
Notifications
You must be signed in to change notification settings - Fork 34
Maven How To
OWLTools uses Maven as build tool. It can be used on the command line and in various IDEs. There are maven plugins for Eclipse, !NetBeans, and IntelliJ.
What are we using maven for:
-
Dependency management
Maven allows to specify dependencies (I want this jar in this version) and provides a convenient way to deal with them without commiting every jar to the svn repository. Instead of having the jar dependencies in your svn, the dependency jars are stored in an central maven-repository (public or your own) and cached in a local folder ($HOME/.m2/repository).
-
Build tool
Maven has a nice build cycle, which includes automated testing as part of the release cycle.
-
Project modularization
Maven has build-in capabilities to handle multi-module projects including a reactor build and centralized configuration
-
Workspace resolution of projects in Eclipse:
No more rebuilding and copying a jar to see the changes of a project in you own.
Most important command:
cd OWLTools-Parent
mvn clean package
This will change the current directory to the OWLTools parent project, clean up first, then compile the project, execute the tests, and create the jar. If any of the tests fails, the jar will not be created. To skip the test execution add {{{ -Dmaven.test.skip.exec=true }}} to the command.
The reactor build feature can be used, in the OWLTools-Parent folder, where the parent pom.xml is located specifying its modules. For a quick build execute:
mvn clean compile
Another use case is to build a specific project and all required modules for it. Start by going to the OWLTools-Parent parent folder. Execute:
mvn clean package -am -pl <Module>
Whereas the {{{ }}} is the path to the module. This will trigger a recursive build of all the required modules. If you just want to build OWLTools-Oort:
mvn clean package -am -pl ../OWLTools-Oort
For more details see the maven documentation.
In general Maven is an additional project nature in Eclipse. Once activated, the plugin creates a container, which has all the dependencies. The nice part is that the plugin allows workspace resolution, meaning the project is the dependency instead of a fixed jar.
In general Eclipse assumes: it is the only one compiling and updating resources. So if you did something on the command-line, you need to update the project (F5) and "Project > clean" in Eclipse. Otherwise, there might be some !ClassNotFoundExceptions and other strange things, while using Eclipse.
The recommended command-line version is 3.x, where x is the latest release. Follow the instructions on the maven page to install it here.
The goal is to run the {{{mvn}}} command in any (project)-folder.
Remark: Although Eclipse does not need a command-line version, it is recommended to be able to make builds on the command-line
The recommended maven plugin is m2e. This plugin for Eclipse requires Eclipse 3.6 or later.
Installation via its eclipse update site: http://download.eclipse.org/technology/m2e/releases
Please do not use the out-dated versions (i.e. m2eclipse) from sonatype or similar. The required version for m2e is 1.0.0 or later. You need to un-install all older versions.
Since Eclipse 3.7 the plugin is pre-installed with the release.