Add default repository to defaultRepositories 80/85880/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 18 Nov 2019 17:42:35 +0000 (18:42 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 20 Nov 2019 09:09:16 +0000 (09:09 +0000)
SFT reconfigures the repository layout such that Karaf ends up
ignoring its default system repository, which contains various
edits we are doing for the baseline distribution.

This leads to SFT running actually against vanilla Karaf
definitions, which is not what we want.

We need to override the repository config to ensure we pick up
the maven repository, so we can find things like pax-exam, etc.

Fix this by setting org.ops4j.pax.url.mvn.defaultRepositories
to point to karaf.default.repository, so that it is consulted
*before* all other repositories.

JIRA: ODLPARENT-209
Change-Id: I6c0fe2716ca1f4aaf695f20dc142838e13cc9e81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 032a0f970970aba54318360828c10f30861a463e)

features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java

index 6a092bb2e65266053e7c92dc4f0d2331a94f9aff..143976dd53624c0b4326b21f1bb7c8cc08bb2ae1 100644 (file)
@@ -56,8 +56,7 @@ import org.slf4j.LoggerFactory;
 public class SingleFeatureTest {
 
     private static final String MAVEN_REPO_LOCAL = "maven.repo.local";
-    private static final String ORG_OPS4J_PAX_URL_MVN_LOCAL_REPOSITORY = "org.ops4j.pax.url.mvn.localRepository";
-    private static final String ORG_OPS4J_PAX_URL_MVN_REPOSITORIES = "org.ops4j.pax.url.mvn.repositories";
+
     private static final String ETC_ORG_OPS4J_PAX_URL_MVN_CFG = "etc/org.ops4j.pax.url.mvn.cfg";
     private static final String ETC_ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg";
 
@@ -189,6 +188,10 @@ public class SingleFeatureTest {
             logLevel(LogLevel.INFO),
             mvnLocalRepoOption(),
 
+            // Make sure karaf's default repository is consulted before anything else
+            editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG, "org.ops4j.pax.url.mvn.defaultRepositories",
+                "file:${karaf.home}/${karaf.default.repository}@id=system.repository"),
+
             // TODO ODLPARENT-148: We change the karaf.log location because it's very useful for this to be preserved
             // even if one does not use "-Dkaraf.keep.unpack=true", which on build server is typically not feasible,
             // because that leads to excessive disk space consumption (full karaf dist; what we really want is the log)
@@ -308,15 +311,15 @@ public class SingleFeatureTest {
      * @return Edit Configuration option which removes external snapshot repositories.
      */
     private static Option disableExternalSnapshotRepositories() {
-        return editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG, ORG_OPS4J_PAX_URL_MVN_REPOSITORIES,
-                EXTERNAL_DEFAULT_REPOSITORIES);
+        return editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG,
+            "org.ops4j.pax.url.mvn.repositories", EXTERNAL_DEFAULT_REPOSITORIES);
     }
 
     protected Option mvnLocalRepoOption() {
         String mvnRepoLocal = System.getProperty(MAVEN_REPO_LOCAL, "");
         LOG.info("mvnLocalRepo \"{}\"", mvnRepoLocal);
-        return editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG, ORG_OPS4J_PAX_URL_MVN_LOCAL_REPOSITORY,
-                mvnRepoLocal);
+        return editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG,
+            "org.ops4j.pax.url.mvn.localRepository", mvnRepoLocal);
     }
 
     protected Option getKarafDistroOption() throws IOException {