Adding a maven repository for installing features to ServiceMix

I’m running ServiceMix on a machine which doesn’t have internet access, so installing and upgrading features is a bit hard. You can, however, install features from an internal maven repository like Nexus. This post explains how you can configure which maven repositories should be used by ServiceMix.

The OSGI implementation of ServiceMix (Apache Felix/Karaf) has a console which you can use to update the configuration. You can see the currently active configurations as follows:

karaf@root> config:list
...
----------------------------------------------------------------
Pid:            org.ops4j.pax.url.mvn
BundleLocation: mvn:org.ops4j.pax.url/pax-url-mvn/1.1.2
Properties:
   service.pid = org.ops4j.pax.url.mvn
   org.ops4j.pax.url.mvn.defaultRepositories = file:/opt/fuse/fuse-4.2/system@snapshots
   felix.fileinstall.filename = org.ops4j.pax.url.mvn.cfg
   org.ops4j.pax.url.mvn.repositories = http://repo1.maven.org/maven2,http://repo.fusesource.com/maven2, 
  http://repo.fusesource.com/maven2-snapshot@snapshots@noreleases, 
  http://repository.apache.org/content/groups/snapshots-group@snapshots@noreleases, 
  http://repository.ops4j.org/maven2, 
  http://svn.apache.org/repos/asf/servicemix/m2-repo, 
  http://repository.springsource.com/maven/bundles/release, 
  http://repository.springsource.com/maven/bundles/external
...

The configuration with Pid org.ops4j.pax.url.mvn is used to tell ServiceMix where to look for features. You can add your own Maven repository to org.ops4j.pax.url.mvn.repositories.

First you need to tell karaf that you want to edit the configuration with pid org.ops4j.pax.url.mvn:

karaf@root> config:edit org.ops4j.pax.url.mvn

Now you can modify the value of org.ops4j.pax.url.mvn.repositories:

karaf@root> config:propset org.ops4j.pax.url.mvn.repositories 
  http://<internal-maven-repo>/nexus/content/groups/public

Save the configuration updates, make sure the changes are visible to the bundles that use it:

karaf@root> config:update

You can see the updated configuration using config:list:

karaf@root> config:list
----------------------------------------------------------------
Pid:            org.ops4j.pax.url.mvn
BundleLocation: mvn:org.ops4j.pax.url/pax-url-mvn/1.1.2
Properties:
   service.pid = org.ops4j.pax.url.mvn
   org.ops4j.pax.url.mvn.defaultRepositories = file:/opt/fuse/fuse-4.2/system@snapshots
   felix.fileinstall.filename = org.ops4j.pax.url.mvn.cfg
   org.ops4j.pax.url.mvn.repositories = 
  http://<internal-maven-repo>/nexus/content/groups/public

Using this modified configuration i can now install features from my internal maven repository. This means i need to proxy all the required external maven repositories in my internal maven repository.

blog comments powered by Disqus