[FELIX-2293]features-maven-plugin validate should support specify the feature repositories from the maven plugin configure
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@936233 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
index 2a11324..8756321 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/AddFeaturesToRepoMojo.java
@@ -135,48 +135,6 @@
}
}
- private String translateFromMaven(String uri) {
- if (uri.startsWith("mvn:")) {
- String[] parts = uri.substring("mvn:".length()).split("/");
- String groupId = parts[0];
- String artifactId = parts[1];
- String version = null;
- String classifier = null;
- String type = "jar";
- if (parts.length > 2) {
- version = parts[2];
- if (parts.length > 3) {
- type = parts[3];
- if (parts.length > 4) {
- classifier = parts[4];
- }
- }
- }
- String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
- String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
-
- return getLocalRepoUrl() + "/" + dir + name;
- }
- if (System.getProperty("os.name").startsWith("Windows") && uri.startsWith("file:")) {
- String baseDir = uri.substring(5).replace('\\', '/').replaceAll(" ", "%20");
- String result = baseDir;
- if (baseDir.indexOf(":") > 0) {
- result = "file:///" + baseDir;
- }
- return result;
- }
- return uri;
- }
-
- private String getLocalRepoUrl() {
- if (System.getProperty("os.name").startsWith("Windows")) {
- String baseDir = localRepo.getBasedir().replace('\\', '/').replaceAll(" ", "%20");
- return localRepo.getProtocol() + ":///" + baseDir;
- } else {
- return localRepo.getUrl();
- }
- }
-
private void addFeatures(List<String> features, Set<String> transitiveFeatures, Map<String, Feature> featuresMap) {
for (String feature : features) {
Feature f = featuresMap.get(feature);
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/MojoSupport.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/MojoSupport.java
index d309b58..7d491e5 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/MojoSupport.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/MojoSupport.java
@@ -296,4 +296,46 @@
"Error during setting up classpath", e);
}
}
+
+ protected String translateFromMaven(String uri) {
+ if (uri.startsWith("mvn:")) {
+ String[] parts = uri.substring("mvn:".length()).split("/");
+ String groupId = parts[0];
+ String artifactId = parts[1];
+ String version = null;
+ String classifier = null;
+ String type = "jar";
+ if (parts.length > 2) {
+ version = parts[2];
+ if (parts.length > 3) {
+ type = parts[3];
+ if (parts.length > 4) {
+ classifier = parts[4];
+ }
+ }
+ }
+ String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
+ String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
+
+ return getLocalRepoUrl() + "/" + dir + name;
+ }
+ if (System.getProperty("os.name").startsWith("Windows") && uri.startsWith("file:")) {
+ String baseDir = uri.substring(5).replace('\\', '/').replaceAll(" ", "%20");
+ String result = baseDir;
+ if (baseDir.indexOf(":") > 0) {
+ result = "file:///" + baseDir;
+ }
+ return result;
+ }
+ return uri;
+ }
+
+ protected String getLocalRepoUrl() {
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ String baseDir = localRepo.getBasedir().replace('\\', '/').replaceAll(" ", "%20");
+ return localRepo.getProtocol() + ":///" + baseDir;
+ } else {
+ return localRepo.getUrl();
+ }
+ }
}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
index deb6963..c49c6db 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
@@ -85,7 +85,11 @@
*/
private String karafConfig;
-
+ /**
+ * The repositories which are included from the plugin config
+ * @parameter
+ */
+ private List<String> repositories;
/*
* A map to cache the mvn: uris and the artifacts that correspond with them
@@ -147,6 +151,15 @@
info(" - read %s", file.getAbsolutePath());
features.add(repository.getFeatures());
+
+ // add the repositories from the plugin configuration
+ for (String uri : repositories) {
+ getLog().info(String.format(" - adding repository from %s", uri));
+ Repository dependency = new RepositoryImpl(URI.create(translateFromMaven(uri)));
+ features.add(dependency.getFeatures());
+ validateBundlesAvailable(dependency);
+ analyzeExports(dependency);
+ }
for (URI uri : repository.getRepositories()) {
Artifact artifact = resolve(uri.toString());