How to Compile OpenNMS

This topic describes how to compile OpenNMS from source.

If you have not set up your environment properly, please refer to Set up local development environment (MacOS).

Checkout the Code

First of all, the code should be checked out.

I usually do this in a ~/dev directory:

cd ~/dev
git clone opennms

Build from Source


Go to the build directory, e.g. cd ~/dev/opennms

Regular development

time (./ && ./ -U -DskipTests && ./ -p dir -DskipTests); say "OpenNMS may be ready for deployment"

When Deploying it somewhere else than locally on my machine

time (./ && ./ -DskipTests && ./ -Dopennms.home=/opt/opennms -DskipTests); say "OpenNMS may be ready for deployment"

Detailled explanation

The build of OpenNMS is usually split into 3 phases:

  • -> Removes all previously build artifacts/archives

  • -> Compiles the root module

  • -> Builds the final assembly opennms-<version>.tar.gz

Behind the scenes OpenNMS uses Maven as a build tool.

The above scripts roughly translate to the following actions:

  • -> invokes mvn clean and mvn clean -F opennms-full-assembly

  • -> invokes a mvn install on the root module

  • -> invokes a mvn install -F opennms-full-assembly

Each script has various numbers of arguments and options, which can be shown with -h

Full build (step by step)

First navigate to your local git repository

cd ~/dev/opennms

Ensure you are on the desired branch (e.g. develop)

git status

Now do a full build with the following command

./ && ./ -DskipTests && ./ -DskipTests -p dir

This will build OpenNMS from source (no tests are executed) and will place all files and directories to ~/dev/opennms/target/opennms-<current-version>.

If you want an archive instead, simply omit the -p dir option

If you want another opennms.home directory, simply define it in the assembly step: ./ -DskipTests -Dopennms.home=/opt/opennms -p dir.

Please keep in mind, that if you are building the first time, this may take several hours, because a lot of dependencies must be downloaded.

Running OpenNMS after compilation

After OpenNMS built from Source successfully it must be configured before it can be started.

First configure java:

./bin/runjava -s

and afterwards initialize/update the database:

sudo ./bin/install -dis

Pro Tip:

In case you are working on an OSGi bundle it is recommend to link the root user’s .m2/repository directory to the user you build OpenNMS with.

This enables you to use the bundle:watch command or manually install missing bundles, which are not located in the system directory.

> sudo su
> mkdir ~/.m2
> cd ~/.m2
> ln -s /home/<user>/.m2/repository repository

Now OpenNMS can be started (i.e. with the -t option to enable the remote debugger):

sudo ./bin/opennms -vt start

The WEB UI should come up after some time at http://localhost:8980/opennms.

How I Build

Regular development

time (./ && ./ -U -DskipTests && ./ -p dir -DskipTests); say "OpenNMS may be ready for deployment"

When deploying it to a custom opennms.home (i.e. on another machine)

time (./ && ./ -DskipTests && ./ -Dopennms.home=/opt/opennms -DskipTests); say "OpenNMS may be ready for deployment"


If you encounter a dependency download or OpenNMS Maven Repositor issue, try rebuilding at least twice before considering it an actual issue.

Sometimes it requires multiple runs before it actually works.

This will be solved as soon as the maven repository is populated properly

Running Tests

There will be a topic talking about running the various tests locally.

As a general side note however

*NEVER run ALL unit or integration tests locally.

This is what Bamboo is for.*

1 Like