General Configuration

You can get many commonly used Java libraries there. However for our development we need our own repository. In order to tell Maven how to use it, you have to change your settings.xml file, which can be found in <user folder>/.m2/settings.xml. More documentation about Maven settings can be found here: http://maven.apache.org/settings.html.

Adding 52°North Repositories

To specify and activate the 52°North repositories add the following sections to your settings.xml.

Please incorborate the instructions into this page Take a look for the walkthrough for Linux (adaptable for Windows as well). Please remind, for the WPS software you'll need additional repositories. Take a look here (under "Installation of the service (CVS and maven instructions)").

After dowloading the files from the remote repository you can continue with loading the dependencies and optionally integrate you local copy into eclipse.

Installing in local repository

Installing into your local maven-repository means that maven downloads all dependencies from remote repositories into its local cache. Furthermore Maven complies your local sourcecode and creates packages in your local maven-repository.

You can skip this step if it fails and you just want to get the project into eclipse.

mvn install

Deploying to the remote repository

Deploying into the remote 52°North repository is only needed if you want to share libraries with other projects or you want to upload something for your team that is not in a shared repository.

Best Practices

BestPracticeJarsInMaven - How to include libraries, i.e. jar files or dll's, into Maven projects which are not available in on-line repositories, for example because of licensing issues, patched versions, or custom libs.

Maven and Eclipse

Create Eclipse Projects

Maven can automatically create eclipse project files. Additionally maven creates links from your local repository to eclipse for all the jars you need.

Once for each workspace, Eclipse needs to know the path to the local maven repository. Therefore the classpath variable M2_REPO has to be set. Execute the following command: mvn -Declipse.workspace= eclipse:add-maven-repo |

Now you can run mvn eclipse:eclipse from the root of you you module (e.g. /home/user/52n-repo/sas/trunk/).

Checkout Maven Projects with Eclipse

If you have the latest Eclipse and m2e plugin installed you can easily download Maven projects. Open the project root folder, e.g. MyProject/trunk, which is the one with the pom.xml file. Then right click on the folder and select "Check out as Maven Project..." and follow the (few) steps in the Wizard. If neccessary, install SCM connectors for m2e by clicking the link in the lower right corner of the dialogue. You also might have to update the project configuration.

Debug Unit Tests with Maven in Eclipse

If you want to debug the unit tests but still run them with Maven (for example because the tests need resource filtering), add the option -Dmaven.surefire.debug to the goal in the Run Configuration, e.g. test -Dmaven.surefire.debug. Then run the test. The console will stop at a line like Listening for transport dt_socket at address: 5005 and wait for a remote debugger connection before continuing with the tests. You have to create that connection now (Debug Configurations > Remote Java Application > Create New) and set the host to localhost and the port to the one mentioned in the console (in our example 5005). Name the Debug Configuration accordingly and start it by clicking Debug.

Maven and XMLBeans

There are detailed instructions how to build ogcschema with maven and xmlbeans: MavenOgcXmlbeans. Furthermore there is the former general MavenXMLBeans description.

Frequently Asked Questions and Troubleshooting

StackOverflowException during compile

Sometimes you can receive errors this the following during any maven compile run:

[INFO] Compilation failure
Failure executing javac, but could not parse the error:
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1799)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1522)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:377)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1241)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1210)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
... then trace repeats multiple times

The solution is to increase the JVM stack size by adding -Xss2048k to your MAVEN_OPTS. Further reading:

Eclipse and m2e plugin

Archive for required libray ... cannot be read or is not a valid ZIP file.

Using the Eclipse Maven plugin can sometimes be a bit bumpy. The error message above often means that a download of a library was not successful, which you can easily check by opening the path in the error message and checking the file <library name>-<versiong>.jar. If its size is 0 KB then is invalid. To fix this, just delete the whole folder <library name>/<version> and update the project dependencies. Maven should now re-download the library and hopefully install it properly.

Progress is stuck in ... "download sources and javadoc"

If you check out a project for the first time, Eclipse and m2e might get stuck in a task (shon in the Progress view) called "Downloading Sources and Javadoc" for a long time, possibly forever. You cannot quit Eclipse or change anything in the project while Eclipse is waiting for this to happen. However, it might not ever happen and Maven probably checks all the repositories if the source files and Javadoc files of all the dependencies are available.

You can also run mvn install from the console, which often solves these kinds of problems and less prone to errors during downloading. Afterwards, "Update Dependencies" in Eclipse and everything should work.

Take a look in the shown path wether the library is missing. You can try to force a redownload of the library by deleting the whole folder <library name>/<version>.

You can also run mvn install from the console, which often solves these kinds of problems and less prone to errors during downloading. Afterwards, "Update Dependencies" in Eclipse and everything should work.

Highlighting a new comunity in the drop-down menu

Until today (2012-03-08) there are three communities, who build their sites with maven, Sensor Web, Geoprocessing and Security & Geo-RM. If there is going to be an new community, who will also build their sites with Maven, here is what you have to do to highlight the name in the drop-down menu:

The community names are highlighted via an if-statement. You can find it in the site.vm circa line 580ff. The beginning should look like the following:

The code is bassically the same for Sensor Web and Security & Geo-RM. The property $communityName in line 580 must be initialized in the respective pom of the project the sites are build with, meaning there has to be a property in the pom. Example:

You will have to deploy the updated Maven-skin to the repository, so that the changes are available for the other communities. This is described in the next section.

Deploying updated Maven-skins

There are two ways of deploying updated Maven-skins. The first one, deploying without increased version, is simple, but not entirely clean. The second one, deploying with increased version, requires updating the version of th 52n parent (root) project.

Deploying without increased version

If you have changed something in the Maven-skin source code, you can deploy it simply by executing

mvn deploy

If you want to deploy to a specific repository add something like the following

mvn deploy -DrepositoryId=n52-releases-dist

Now the current version of the Maven-skin will be replaced by your updated version. NOTE: This can lead to problems for others, who want to build their sites with the updated skin, because the local version of the skin will not be automatically updated. They will have to delete it manually from their local maven repository first, to get the updated version from the 52n repository.

Deploying with increased version

A more clean method to deploy an updated skin is to increase the version. After you have modified the sorce code of the Maven-skin project, increase the version in the pom. E.g. from 8 to 9. Deploy the skin as described in the previous section.

Now you will have to adjust the version in the 52n parent project. Open /src/site/site.xml and change the version of the Maven-skin accordingly. To avoid the same pitfall as described in the previous section you should increase the version of the parent pom as well. You can do this in the pom, e.g. from 5.6 to 5.7. The 52n parent project can deployed with the following command:

deploy site:attach-descriptor

Add specific repository:

deploy -DrepositoryId=n52-releases-dist site:attach-descriptor

Now updated versions of skin and parent should exist in the repository. To build the community sites with the new skin you will have to increase the version of the parent in the pom used for building the sites. The new skin and parent should be automatically fetched from the repository.