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:

[email protected]> 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/[email protected]
   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/[email protected]@noreleases, 
  http://repository.apache.org/content/groups/[email protected]@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:

[email protected]> config:edit org.ops4j.pax.url.mvn

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

[email protected]> 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:

[email protected]> config:update

You can see the updated configuration using config:list:

[email protected]> 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/[email protected]
   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