Repository: karaf Updated Branches: refs/heads/master 55bcb232d -> 91b1d5946
Convert the repo path to unix separators for boot feature repos. Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/fda18072 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/fda18072 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/fda18072 Branch: refs/heads/master Commit: fda180722d95071baa579778249b3b1a5d902d51 Parents: d784a9b Author: Andreas Kuhtz <[email protected]> Authored: Tue Oct 13 10:46:40 2015 +0200 Committer: Andreas Kuhtz <[email protected]> Committed: Tue Oct 13 10:46:40 2015 +0200 ---------------------------------------------------------------------- .../internal/service/BootFeaturesInstaller.java | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/fda18072/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java ---------------------------------------------------------------------- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java index 9c1e8fd..f3b1647 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java @@ -16,6 +16,7 @@ */ package org.apache.karaf.features.internal.service; +import java.io.File; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -42,8 +43,23 @@ public class BootFeaturesInstaller { private final String repositories; private final String features; private final boolean asynchronous; + + /** + * The Unix separator character. + */ + private static final char UNIX_SEPARATOR = '/'; + + /** + * The Windows separator character. + */ + private static final char WINDOWS_SEPARATOR = '\\'; /** + * The system separator character. + */ + private static final char SYSTEM_SEPARATOR = File.separatorChar; + + /** * @param features list of boot features separated by comma. Optionally contains ;version=x.x.x to specify a specific feature version */ public BootFeaturesInstaller(BundleContext bundleContext, @@ -82,6 +98,7 @@ public class BootFeaturesInstaller { for (String repo : repositories.split(",")) { repo = repo.trim(); if (!repo.isEmpty()) { + repo = separatorsToUnix(repo); try { featuresService.addRepository(URI.create(repo)); } catch (Exception e) { @@ -141,4 +158,23 @@ public class BootFeaturesInstaller { } } + //----------------------------------------------------------------------- + /** + * Converts all separators to the Unix separator of forward slash. + * + * @param path the path to be changed, null ignored + * @return the updated path + */ + private String separatorsToUnix(String path) { + if (SYSTEM_SEPARATOR == WINDOWS_SEPARATOR) { + // running under windows + if (path == null || path.indexOf(WINDOWS_SEPARATOR) == -1) { + return path; + } + + path = path.replace(WINDOWS_SEPARATOR, UNIX_SEPARATOR); + LOGGER.debug("Converted path to unix separators: {}", path); + } + return path; + } }
