Skip to main content

Maven URL Handler

The equivalent of the above bundle would be:

<bundle>
   mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.api/1.0.0-m2
</bundle>

In addition to being less verbose, the Maven URL handlers can also resolve snapshots and can use a local copy of the jar if one is available in your Maven local repository.

The org.ops4j.pax.url.mvn bundle resolves mvn URLs. This flexible tool can be configured through the configuration service. For example, to find the current repositories type: karaf@trun:/> config:list and the following will display:

Pid:            org.ops4j.pax.url.mvn
BundleLocation: mvn:org.ops4j.pax.url/pax-url-mvn/0.3.3
Properties:
   service.pid = org.ops4j.pax.url.mvn
   org.ops4j.pax.url.mvn.defaultRepositories = file:/opt/development/  \\
       karaf/assembly/target/apache-felix-karaf-1.2.0-SNAPSHOT/   \\
       system@snapshots
   org.ops4j.pax.url.mvn.repositories = http://repo1.maven.org/maven2, 
       http://svn.apache.org/repos/asf/servicemix/m2-repo 
   below = list of repositories and even before the local repository

The repositories checked are controlled by these configuration properties. For example, org.ops4j.pax.url.mvn.repositories is a comma separated list of repository URLs specifying those remote repositories to be checked. So, to replace the defaults with a new repository at http://www.example.org/repo on the local machine:

karaf@trun:/> config:edit org.ops4j.pax.url.mvn
karaf@trun:/> config:property-list                  
   service.pid = org.ops4j.pax.url.mvn
   org.ops4j.pax.url.mvn.defaultRepositories = file:/opt/development/karaf/
       assembly/target/apache-felix-karaf-1.2.0-SNAPSHOT/system@snapshots
   org.ops4j.pax.url.mvn.repositories = http://repo1.maven.org/maven2,
       http://svn.apache.org/repos/asf/servicemix/m2-repo
   below = list of repositories and even before the local repository
karaf@trun:/> config:property-set org.ops4j.pax.url.mvn.repositories 
       http://www.example.org/repo
karaf@trun:/> config:update

By default, snapshots are disabled. To enable an URL for snapshots append @snapshots. For example: http://www.example.org/repo@snapshots. Repositories on the local are supported through file:/ URLs.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!