简体   繁体   中英

Always update bundles from remote repo or disable local repo in ServiceMix 6.0.X / Karaf 3.0.X

I have a problem with updating bundles from remote repo in our testing environment. Environment includes several servers with ServiceMix (or Karaf, no matter) and server with JFrog Artifactory.

Before karaf 3.0.X we use SNAPSHOT versions for dynamically update bundles on working OSGi container, but now karaf search bundles in local repo and if exists never check latest version on remote repository (artifactory). How can I fix it?

Configuration example for karaf and maven ( M2_HOME was set for user)

settings.xml ( $M2_HOME/conf/settings.xml )

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <pluginGroups/>
  <proxies/>
  <servers/>
  <mirrors/>
  <profiles>
    <profile>
      <id>default-repo-settings</id>

      <activation>
        <activeByDefault/>
      </activation>

      <repositories>
        <repository>
            <id>artifactory</id>
            <url>http://artifactory/ext-snapshot-local</url>
            <snapshots>
                <updatePolicy>always</updatePolicy>
            </snapshots>
            <releases>
                <updatePolicy>always</updatePolicy>
            </releases>
        </repository>
        <!-- same repos here -->
      </repositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>default-repo-settings</activeProfile>
  </activeProfiles>
</settings>

org.ops4j.pax.url.mvn.cfg ( $KARAF_HOME/etc/org.ops4j.pax.url.mvn.cfg )

org.ops4j.pax.url.mvn.useFallbackRepositories=false
org.ops4j.pax.url.mvn.disableAether=true
org.ops4j.pax.url.mvn.useLocalRepositoryAsRemote=true
org.ops4j.pax.url.mvn.globalUpdatePolicy=always
org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}}/${karaf.default.repository}}@snapshots@id=karaf.${karaf.default.repository}}

org.ops4j.pax.url.mvn.repositories= \
    http://artifactory/ext-snapshot-local@snapshots@id=artifactory, \
    http://repo1.maven.org/maven2@id=central, \
    http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, \
    http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \
    http://zodiac.springsource.com/maven/bundles/release@id=gemini, \
    http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \
    https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, \
    https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases

It is probably best to simplify your artifact promotion approach to have one and only one location to get artifacts to the SMX/Karaf containers. I suggest setting up your Artifactory so you have a virtual repo that merges your in-house repo with remote repositories (Maven Central, Spring, etc). Your containers should only point to your in-house Artifactory instance. This also allows your Artifactory to cache the remote repos and you are no longer dependent on the Internet being up and the remote Maven Repos being up as well.

Now, any time you do a 'update $bundleId', it'll query the virtual repo and Artifactory will present you the best available match on a -SNAPSHOT artifact.

Also, probably good idea to remove the @snapshots from the local file: repo line to help avoid confusion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM