You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ge...@apache.org on 2011/01/11 22:19:03 UTC
svn commit: r1057870 -
/karaf/branches/karaf-2.1.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
Author: gertv
Date: Tue Jan 11 21:19:01 2011
New Revision: 1057870
URL: http://svn.apache.org/viewvc?rev=1057870&view=rev
Log:
KARAF-375: Allow configuring features-maven-plugin to exclude transitive features
Modified:
karaf/branches/karaf-2.1.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
Modified: karaf/branches/karaf-2.1.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.1.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java?rev=1057870&r1=1057869&r2=1057870&view=diff
==============================================================================
--- karaf/branches/karaf-2.1.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java (original)
+++ karaf/branches/karaf-2.1.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java Tue Jan 11 21:19:01 2011
@@ -85,6 +85,11 @@ public class AddFeaturesToRepoMojo exten
*/
private boolean failOnArtifactResolutionError = false;
+ /**
+ * @parameter
+ */
+ private boolean addTransitiveFeatures = true;
+
public void execute() throws MojoExecutionException, MojoFailureException {
try {
Map<String, Feature> featuresMap = new HashMap<String, Feature>();
@@ -94,12 +99,23 @@ public class AddFeaturesToRepoMojo exten
featuresMap.put(f.getName(), f);
}
}
+ Set<String> featuresBundles = new HashSet<String>();
Set<String> transitiveFeatures = new HashSet<String>();
- addFeatures(features, transitiveFeatures, featuresMap);
Set<String> bundles = new HashSet<String>();
- for (String feature : transitiveFeatures) {
- bundles.addAll(featuresMap.get(feature).getBundles());
+ addFeatures(features, featuresBundles, transitiveFeatures, featuresMap);
+
+ // add the bundles of the configured features to the bundles list
+ bundles.addAll(featuresBundles);
+
+ // if transitive features are enabled we add the contents of those
+ // features to the bundles list
+ if (this.addTransitiveFeatures) {
+ for (String feature : transitiveFeatures) {
+ getLog().info("Adding contents of transitive feature: " + feature);
+ bundles.addAll(featuresMap.get(feature).getBundles());
+ }
}
+
getLog().info("Base repo: " + localRepo.getUrl());
for (String bundle : bundles) {
// get rid of of possible line-breaks KARAF-313
@@ -184,14 +200,22 @@ public class AddFeaturesToRepoMojo exten
}
}
- private void addFeatures(List<String> features, Set<String> transitiveFeatures, Map<String, Feature> featuresMap) {
+ private void addFeatures(List<String> features, Set<String> featuresBundles, Set<String> transitiveFeatures, Map<String, Feature> featuresMap) {
for (String feature : features) {
Feature f = featuresMap.get(feature);
if (f == null) {
throw new IllegalArgumentException("Unable to find the feature '" + feature + "'");
}
- transitiveFeatures.add(feature);
- addFeatures(f.getDependencies(), transitiveFeatures, featuresMap);
+ // only add the feature to transitives if it is not
+ // listed in the features list defined by the config
+ if (!this.features.contains(feature)) {
+ transitiveFeatures.add(feature);
+ } else {
+ // add the bundles of the feature to the bundle set
+ getLog().info("Adding contents for feature: " + feature);
+ featuresBundles.addAll(featuresMap.get(feature).getBundles());
+ }
+ addFeatures(f.getDependencies(), featuresBundles, transitiveFeatures, featuresMap);
}
}