0
votes

I am trying to add a custom project to the distribution. The project that I created via

mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ -DarchetypeCatalog=remote -DarchetypeVersion=1.6.0-SNAPSHOT

is (obviously) not available via the official nexus. I did not do any changes to this project.

I fired up karaf in distribution and tried to add the new project as a new repository via

feature:repo-add mvn:org.opendaylight.flowlistener/features-flowlistener/0.1.0-SNAPSHOT/xml/features

and received this error:

Adding feature url mvn:org.opendaylight.flowlistener/features-flowlistener/0.1.0-SNAPSHOT/xml/features Error executing command: Error resolving artifact org.opendaylight.flowlistener:features-flowlistener:xml:features:0.1.0-SNAPSHOT: [Could not find artifact org.opendaylight.flowlistener:features-flowlistener:xml:features:0.1.0-SNAPSHOT in opendaylight-snapshot (https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/)] : mvn:org.opendaylight.flowlistener/features-flowlistener/0.1.0-SNAPSHOT/xml/features

Is it generally possible to add projects that only exist locally? What am I doing wrong?

Thanks in advance! Max

2

2 Answers

3
votes

Artifact repositories are configured using etc/org.ops4j.pax.url.mvn.cfg in Karaf. The configuration shipped in OpenDaylight only uses the Karaf system directory; it ignores the local Maven repository entirely.

To add your local Maven repository, you should edit the org.ops4j.pax.url.mvn.repositories entry at the end of the file to include your Maven repository:

org.ops4j.pax.url.mvn.repositories= \
    file:${karaf.home}/${karaf.default.repository}@id=system.repository, \
    file:${karaf.data}/kar@id=kar.repository@multi, \
    file:${user.home}/.m2/repository@snapshots@id=m2.repository

By the way, unless you intend to contribute your project to OpenDaylight, you should avoid using the org.opendaylight namespace.

0
votes

Karaf distribution uses the settings in etc/org.ops4j.pax.url.mvn.cfg to resolve maven artifacts. You will have to tweak these settings (e.g. maven local repo) for the distribution to find your local project. There is some in-line documentation on how to edit this file: https://github.com/apache/karaf/blob/master/assemblies/features/base/src/main/resources/resources/etc/org.ops4j.pax.url.mvn.cfg