Maven
Contents
The following steps will guide you through the process of installing maven in order to check out the LarKC platform and perform standard tasks such as building and testing the platform using maven.
Suggested reading material
If you are unfamiliar with maven (or want to refresh your knowledge) it is strongly recommended to read the "What is maven?" section of the official project site. This page gives a good overview of what maven is (and is capable of) and what it is not.
The Maven Getting Started Guide answers many questions and guides you through the process of setting up and executing various goals of a maven project.
In a nutshell
Install maven2 (or m2eclipse which comes with an embedded version of maven, it is recommended that you also install the SVN integration)
Check out the LarKC platform (release 2.0 prototype)
Run mvn clean install -Dmaven.test.skip=true
Install maven2
The following are very basic instructions. For more detailed information please have a look at the official installation instructions.
Linux
Most modern distributions have maven in their software repositories. If available, we recommend installing maven via those repositories. If you are using the apt package managing tool (e.g. Ubuntu, Debian) simply type
sudo apt-get install maven2
For yum (e.g. ?RedHat, Fedora, centOS) simply type
yum install maven2
As an alternative there are downloadable versions of maven for linux here.
Windows
Download the binary version of maven here. The version used for this tutorial was 2.2.1.
Note: When using m2eclipse with subclise on Windows it is recommended to install the Maven SCM handler for Subclipse, provided by m2e-extras.
Testing the installation
After successful installation you should be able to run the following command
mvn --version
which will print out your Apache Maven version (should be 2.2.x or higher) along with other information.
Hint: If maven complains about not finding a certain settings.xml file, create it (in the maven settings directory, usually ~/.m2/ on Linux, C:\Documents and Settings\username\.m2 on Windows) and paste the following:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> </settings>
Install the m2eclipse plug-in
Maven has very good eclipse integration via the m2eclipse plug-in.
You can find detailed instructions on how to install the plug-in here.
Although m2eclipse comes with an embedded version of maven, it is recommended to use an external maven installation to gain more fine-grained output among other small benefits. To add an external maven installation to eclipse open up the eclipse preferences via Window -> Preferences. On the left side go to Maven -> Installations click Add and point to your maven installation (i.e. the folder where you have unpacked the file downloaded from http://maven.apache.org/download.html ).
Check out the LarKC platform
In order to check out the LarKC platform from SVN you need to install a SVN client first. If you want tight integration with eclipse we recommend using subclipse.
The v2.0 prototype is the first version of the LarKC platform which utilizes maven to achieve a more streamlined project lifecycle. To add the v2.0 prototype branch as a SVN repository use the following URL:
https://larkc.svn.sourceforge.net/svnroot/larkc/branches/Release_2.0_prototype
If you use subclipse, add a new SVN repository and use the URL provided above as the repository location.
On success, you should see a directory structure similar to the following.
By right-clicking on the platform folder you can check out the project.
Note: If "Check out as Maven Project..." is missing, simply use "Checkout..." instead.
Clicking finish will complete the checkout process.
Build the LarKC platform
Since maven uses a streamlined approach to compiling, building and testing software (among other things) the LarKC platform is build just like any other maven project.
If you are unfamiliar with maven, the “Getting started” guide of the Apache Maven project is an excellent resource: http://maven.apache.org/guides/getting-started/index.html
For example: To run the maven goals clean and install (which cleans the project, downloads the required dependencies for the project, builds it and packages it) without running the tests, go to the platform directory and run
mvn clean install -Dmaven.test.skip=true
You can also run any maven goal (such as clean and/or install) inside eclipse, via m2eclipse. To do so create a run configuration by clicking on Run -> Run configurations. Create a new Maven build configuration as seen in the screenshot below.
Note that we are skipping the execution of tests (via the -Dmaven.test.skip=true) since the development branch may contain tests which are either to stressful or unstable to run. In eclipse, this can be done by checking the "Skip Tests" checkbox.
Also note that you may need to increase the amount of memory available to maven by using e.g. -Xmx512M in Run configurations -> JRE -> VM arguments.
A successful run of mvn clean install -Dmaven.test.skip=true should produce the following output:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Platform
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44 seconds
[INFO] Finished at: Fri Oct 29 14:02:46 CEST 2010
[INFO] Final Memory: 54M/589M
[INFO] ------------------------------------------------------------------------
Troubleshooting
Please refer to the official FAQ or the unofficial FAQ for maven related problems.
General Hints and Tips
If you get strange ClassNotFound exceptions in eclipse, try cleaning the project (Project -> Clean...). This may occur sometimes and has nothing to do with maven in general.
In case you get dependency errors on your first mvn install simply try running mvn install again. Since all dependencies are downloaded from online maven repositories, it may be that some dependencies fail to resolve because of connection errors. Trying a 2nd time (or 3rd time) solves this problem most of the time.
If running a maven goal fails repeatedly in eclipse, try running the same goal in the command line. It may be the case that you are using the wrong maven version inside eclipse.
