You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2017/04/25 11:52:08 UTC
karaf git commit: [KARAF-5106] Support feature repositories cyclic
dependencies
Repository: karaf
Updated Branches:
refs/heads/master 29d0d2ab4 -> b6f444bf0
[KARAF-5106] Support feature repositories cyclic dependencies
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b6f444bf
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b6f444bf
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b6f444bf
Branch: refs/heads/master
Commit: b6f444bf04662e4c455fa037b10c9fa4c9040520
Parents: 29d0d2a
Author: Guillaume Nodet <gn...@apache.org>
Authored: Tue Apr 25 13:51:31 2017 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Tue Apr 25 13:52:02 2017 +0200
----------------------------------------------------------------------
.../apache/karaf/profile/assembly/Builder.java | 34 +++++++++++---------
.../karaf/profile/assembly/BuilderTest.java | 31 ++++++++++++++++++
.../repo/foo/bar/1.0/bar-1.0-features.xml | 20 ++++++++++++
.../repo/foo/baz/1.0/baz-1.0-features.xml | 20 ++++++++++++
4 files changed, 89 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/b6f444bf/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index 371a18f..2b7d2b8 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -1352,22 +1352,24 @@ public class Builder {
if (Blacklist.isBlacklisted(clausesRepos, url, TYPE_REPOSITORY)) {
return;
}
- if (install) {
- synchronized (provider) {
- Path path = systemDirectory.resolve(pathFromProviderUrl(url));
- Files.createDirectories(path.getParent());
- Files.copy(provider.getFile().toPath(), path, StandardCopyOption.REPLACE_EXISTING);
- }
- }
- try (InputStream is = provider.open()) {
- Features featuresModel = JaxbUtil.unmarshal(url, is, false);
- if (blacklistPolicy == BlacklistPolicy.Discard) {
- Blacklist.blacklist(featuresModel, clauses);
- }
- synchronized (loaded) {
- loaded.put(provider.getUrl(), featuresModel);
- for (String innerRepository : featuresModel.getRepository()) {
- downloader.download(innerRepository, this);
+ synchronized (loaded) {
+ if (!loaded.containsKey(provider.getUrl())) {
+ if (install) {
+ synchronized (provider) {
+ Path path = pathFromProviderUrl(url);
+ Files.createDirectories(path.getParent());
+ Files.copy(provider.getFile().toPath(), path, StandardCopyOption.REPLACE_EXISTING);
+ }
+ }
+ try (InputStream is = provider.open()) {
+ Features featuresModel = JaxbUtil.unmarshal(url, is, false);
+ if (blacklistPolicy == BlacklistPolicy.Discard) {
+ Blacklist.blacklist(featuresModel, clauses);
+ }
+ loaded.put(provider.getUrl(), featuresModel);
+ for (String innerRepository : featuresModel.getRepository()) {
+ downloader.download(innerRepository, this);
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/b6f444bf/profile/src/test/java/org/apache/karaf/profile/assembly/BuilderTest.java
----------------------------------------------------------------------
diff --git a/profile/src/test/java/org/apache/karaf/profile/assembly/BuilderTest.java b/profile/src/test/java/org/apache/karaf/profile/assembly/BuilderTest.java
index 8532a12..a0e2315 100644
--- a/profile/src/test/java/org/apache/karaf/profile/assembly/BuilderTest.java
+++ b/profile/src/test/java/org/apache/karaf/profile/assembly/BuilderTest.java
@@ -16,7 +16,9 @@
*/
package org.apache.karaf.profile.assembly;
+import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.Writer;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -24,10 +26,39 @@ import java.nio.file.Paths;
import org.junit.Ignore;
import org.junit.Test;
+import org.osgi.framework.Constants;
public class BuilderTest {
@Test
+ public void testCyclicRepos() throws Exception {
+ Path workDir = Paths.get("target/distrib");
+ recursiveDelete(workDir);
+
+ // Create dummy etc/config.properties file
+ Path config = workDir.resolve("etc/config.properties");
+ Files.createDirectories(config.getParent());
+ try (BufferedWriter w = Files.newBufferedWriter(config)) {
+ w.write(Constants.FRAMEWORK_SYSTEMPACKAGES + "= org.osgi.dto");
+ w.newLine();
+ w.write(Constants.FRAMEWORK_SYSTEMCAPABILITIES + "= ");
+ w.newLine();
+ }
+
+ Path mvnRepo = Paths.get("target/test-classes/repo");
+ Builder builder = Builder.newInstance()
+ .repositories(Builder.Stage.Startup, true, "mvn:foo/baz/1.0/xml/features")
+ .homeDirectory(workDir)
+ .localRepository(mvnRepo.toString());
+ try {
+ builder.generateAssembly();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
@Ignore("This test can not run at this position as it needs the staticFramework kar which is not yet available")
public void testBuilder() throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf/blob/b6f444bf/profile/src/test/resources/repo/foo/bar/1.0/bar-1.0-features.xml
----------------------------------------------------------------------
diff --git a/profile/src/test/resources/repo/foo/bar/1.0/bar-1.0-features.xml b/profile/src/test/resources/repo/foo/bar/1.0/bar-1.0-features.xml
new file mode 100644
index 0000000..2cb192d
--- /dev/null
+++ b/profile/src/test/resources/repo/foo/bar/1.0/bar-1.0-features.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<features name="test" xmlns="http://karaf.apache.org/xmlns/features/v1.1.0">
+ <repository>mvn:foo/baz/1.0/xml/features</repository>
+</features>
http://git-wip-us.apache.org/repos/asf/karaf/blob/b6f444bf/profile/src/test/resources/repo/foo/baz/1.0/baz-1.0-features.xml
----------------------------------------------------------------------
diff --git a/profile/src/test/resources/repo/foo/baz/1.0/baz-1.0-features.xml b/profile/src/test/resources/repo/foo/baz/1.0/baz-1.0-features.xml
new file mode 100644
index 0000000..bdf780b
--- /dev/null
+++ b/profile/src/test/resources/repo/foo/baz/1.0/baz-1.0-features.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<features name="test" xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
+ <repository>mvn:foo/bar/1.0/xml/features</repository>
+</features>