You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2011/12/11 09:43:55 UTC
svn commit: r1212979 - in /karaf/branches/karaf-2.2.x:
manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf
tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
Author: jbonofre
Date: Sun Dec 11 08:43:55 2011
New Revision: 1212979
URL: http://svn.apache.org/viewvc?rev=1212979&view=rev
Log:
[KARAF-965] add-features-to-repo goal is now able to handle feature version (name/version)
Modified:
karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf
karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
Modified: karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf?rev=1212979&r1=1212978&r2=1212979&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf (original)
+++ karaf/branches/karaf-2.2.x/manual/src/main/webapp/developers-guide/features-maven-plugin-add.conf Sun Dec 11 08:43:55 2011
@@ -30,6 +30,7 @@ The example below copies the bundles for
<feature>spring</feature>
<feature>war</feature>
<feature>my</feature>
+ <feature>other/1.0-SNAPSHOT</feature>
</features>
<repository>target/features-repo</repository>
</configuration>
@@ -44,6 +45,6 @@ The example below copies the bundles for
h3. Parameters
|| Name || Type || Description ||
| {{descriptors}} | {{String[]}} | List of features XML descriptors where the features are defined \\ NB: Karaf core features descriptors (standard and enterprise) are automatically added in this list |
-| {{features}} | {{String[]}} | List of features that bundles should be copied to the repository directory |
+| {{features}} | {{String[]}} | List of features that bundles should be copied to the repository directory. A feature could be just a feature name or a name/version. If it's just a name, the features-maven-plugin will take the first feature with the given name, whatever the version is. |
| {{repository}} | {{File}} | The directory where the bundles will be copied by the plugin goal |
| {{karafVersion}} | {{String}} | Target Karaf version to use to resolve the Karaf core features descriptors (standard and enterprise) |
\ No newline at end of file
Modified: karaf/branches/karaf-2.2.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.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java?rev=1212979&r1=1212978&r2=1212979&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java (original)
+++ karaf/branches/karaf-2.2.x/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java Sun Dec 11 08:43:55 2011
@@ -169,10 +169,12 @@ public class AddFeaturesToRepoMojo exten
// features to the bundles list
if (addTransitiveFeatures) {
for (String feature : transitiveFeatures) {
- getLog().info("Adding contents of transitive feature: " + feature);
- bundles.addAll(featuresMap.get(feature).getBundles());
+
+ Feature f = featuresMap.get(feature);
+ getLog().info("Adding contents of transitive feature: " + f.getName() + "/" + f.getVersion());
+ bundles.addAll(f.getBundles());
// Treat the config files as bundles, since it is only copying
- bundles.addAll(featuresMap.get(feature).getConfigFiles());
+ bundles.addAll(f.getConfigFiles());
}
}
@@ -226,7 +228,7 @@ public class AddFeaturesToRepoMojo exten
}
Repository repo = new Repository(URI.create(translateFromMaven(uri.replaceAll(" ", "%20"))));
for (Feature f : repo.getFeatures()) {
- featuresMap.put(f.getName(), f);
+ featuresMap.put(f.getName() + "/" + f.getVersion(), f);
}
if (resolveDefinedRepositoriesRecursively) {
for (String r : repo.getDefinedRepositories()) {
@@ -270,20 +272,42 @@ public class AddFeaturesToRepoMojo exten
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);
+
+ // feature could be only the name or name/version
+ int delimIndex = feature.indexOf('/');
+ String version = null;
+ if (delimIndex > 0) {
+ version = feature.substring(delimIndex + 1);
+ feature = feature.substring(0, delimIndex);
+ }
+
+ Feature f = null;
+ if (version != null) {
+ // looking for a specific feature with name and version
+ f = featuresMap.get(feature + "/" + version);
+ } else {
+ // looking for the first feature name (whatever the version is)
+ for (String key : featuresMap.keySet()) {
+ String[] nameVersion = key.split("/");
+ if (feature.equals(nameVersion[0])) {
+ f = featuresMap.get(key);
+ break;
+ }
+ }
+ }
if (f == null) {
throw new IllegalArgumentException("Unable to find the feature '" + feature + "'");
}
// 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);
+ if (!this.features.contains(f.getName() + "/" + f.getVersion())) {
+ transitiveFeatures.add(f.getName() + "/" + f.getVersion());
} else {
// add the bundles of the feature to the bundle set
getLog().info("Adding contents for feature: " + feature);
- featuresBundles.addAll(featuresMap.get(feature).getBundles());
+ featuresBundles.addAll(f.getBundles());
// Treat the config files as bundles, since it is only copying
- featuresBundles.addAll(featuresMap.get(feature).getConfigFiles());
+ featuresBundles.addAll(f.getConfigFiles());
}
addFeatures(f.getDependencies(), featuresBundles, transitiveFeatures, featuresMap);
}
@@ -321,6 +345,7 @@ public class AddFeaturesToRepoMojo exten
public static class Feature {
private String name;
+ private String version;
private List<String> dependencies = new ArrayList<String>();
private List<String> bundles = new ArrayList<String>();
private Map<String, Map<String, String>> configs = new HashMap<String, Map<String, String>>();
@@ -333,6 +358,14 @@ public class AddFeaturesToRepoMojo exten
public String getName() {
return name;
}
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
public List<String> getDependencies() {
return dependencies;
@@ -429,7 +462,9 @@ public class AddFeaturesToRepoMojo exten
}
Element e = (Element) nodes.item(i);
String name = e.getAttribute("name");
+ String version = e.getAttribute("version");
Feature f = new Feature(name);
+ f.setVersion(version);
NodeList featureNodes = e.getElementsByTagName("feature");
for (int j = 0; j < featureNodes.getLength(); j++) {
Element b = (Element) featureNodes.item(j);