0

I am trying to deploy my java modules on OSGI container. Through karaf 'feature' i am able to generate feature.xml which lists all bundles that are needed.

As we know each bundle is a dependency. Now we do have some dependencies that can be downloaded by maven from its repository.

How can i point karaf to download those dependencies from maven repo directly OR even from our local maven repo. For example like in a pom we write dependency and when we do maven clean install it downloads all jars to local m2 repo.

My feature xml contains these bundles of maven repo which are unresolved yet.

<bundle>mvn:org.springframework.data/spring-data-cassandra/1.2.2.RELEASE</bundle>
<bundle>mvn:org.springframework.data/spring-cql/1.2.2.RELEASE</bundle>
<bundle>wrap:mvn:org.springframework/spring-context/4.0.9.RELEASE</bundle>
<bundle>wrap:mvn:org.springframework/spring-aop/4.0.9.RELEASE</bundle>
<bundle>wrap:mvn:org.springframework/spring-beans/4.0.9.RELEASE</bundle>
<bundle>wrap:mvn:aopalliance/aopalliance/1.0</bundle>
<bundle>wrap:mvn:org.springframework/spring-beans/4.2.3.RELEASE</bundle>
<bundle>wrap:mvn:org.springframework/spring-core/4.2.3.RELEASE</bundle>
<bundle>mvn:commons-logging/commons-logging/1.2</bundle>
<bundle>wrap:mvn:org.springframework/spring-expression/4.2.3.RELEASE</bundle>
<bundle>wrap:mvn:org.springframework/spring-jdbc/4.2.3.RELEASE</bundle>
<bundle>wrap:mvn:org.springframework/spring-tx/4.2.3.RELEASE</bundle>
<bundle>wrap:mvn:org.springframework/spring-test/4.2.3.RELEASE</bundle>
usman
  • 1,351
  • 5
  • 23
  • 47

2 Answers2

3

In the $KARAF_HOME/etc folder edit the org.ops4j.pax.url.mvn.cfg file to refer to the location of the local repository.

org.ops4j.pax.url.mvn.localRepository=<path to repository>
Ashoka
  • 935
  • 7
  • 20
  • point is can i ask karaf through feature to download e.g commons-lang from maven when i say mvn:commons-lang/commons-lang/2.6 will that download it for me? – usman Jan 08 '16 at 13:53
  • Yes, it does that automatically. It will try to fetch from all repositories configured in the `org.ops4j.pax.url.mvn.repositories` property of `$KARAF_HOME/etc/org.ops4j.pax.url.mvn.cfg`. This includes Maven Central by default and several others. – raulk Jan 11 '16 at 14:11
  • i was testing on repositories and found that maven site mostly allows GET method download and karaf is unable to download those libs from maven repo. – usman Jan 12 '16 at 09:28
0

It depends on the karaf version. Karaf 2.x did not download to the local maven repository. It was able to read from the local repo though.

Karaf 3.x and 4.x download all dependencies to the local maven repo the first time they are accessed. So the following times the install works a lot faster.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64