karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject git commit: [KARAF-2791]AddFeaturesToRepoMojo should support read version from dependency features
Date Tue, 25 Feb 2014 06:59:32 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-2.3.x be5419892 -> 63bff3d9e


[KARAF-2791]AddFeaturesToRepoMojo should support read version from dependency features


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/63bff3d9
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/63bff3d9
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/63bff3d9

Branch: refs/heads/karaf-2.3.x
Commit: 63bff3d9ea7aa4d53974e7b499d5afa20afef319
Parents: be54198
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Tue Feb 25 14:58:01 2014 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Tue Feb 25 14:58:01 2014 +0800

----------------------------------------------------------------------
 .../tooling/features/AddFeaturesToRepoMojo.java | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/63bff3d9/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
----------------------------------------------------------------------
diff --git a/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
b/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
index eb67a07..a332e3d 100644
--- a/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
+++ b/tooling/features-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddFeaturesToRepoMojo.java
@@ -38,12 +38,14 @@ import java.util.Set;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.felix.utils.version.VersionRange;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.osgi.framework.Version;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -228,6 +230,7 @@ public class AddFeaturesToRepoMojo extends MojoSupport {
         throws Exception {
         // let's ensure a mvn: based url is sitting in the local repo before we try reading
it
         Artifact descriptor = resourceToArtifact(uri, true);
+        
         if (descriptor != null) {
             resolveBundle(descriptor, remoteRepos);
         }
@@ -293,6 +296,19 @@ public class AddFeaturesToRepoMojo extends MojoSupport {
             if (version != null) {
                 // looking for a specific feature with name and version
                 f = featuresMap.get(feature + "/" + version);
+                if (f == null) {
+                    //it's probably is a version range so try to use VersionRange Utils
+                    VersionRange versionRange = new VersionRange(version);
+                    for (String key : featuresMap.keySet()) {
+                        String[] nameVersion = key.split("/");
+                        if (feature.equals(nameVersion[0])) {
+                            Version ver = new Version(featuresMap.get(key).getVersion());
+                            if (versionRange.contains(ver)) {
+                                f = featuresMap.get(key);
+                            }
+                        }
+                    }
+                }
             } else {
                 // looking for the feature name (with the greatest version)
                 for (String key : featuresMap.keySet()) {
@@ -477,7 +493,12 @@ public class AddFeaturesToRepoMojo extends MojoSupport {
                     NodeList featureNodes = e.getElementsByTagName("feature");
                     for (int j = 0; j < featureNodes.getLength(); j++) {
                         Element b = (Element) featureNodes.item(j);
-                        f.addDependency(b.getTextContent());
+                        if (b.getAttribute("version") != null 
+                            && b.getAttribute("version").length() > 0) {
+                            f.addDependency(b.getTextContent() + "/" + b.getAttribute("version"));
+                        } else {
+                            f.addDependency(b.getTextContent());
+                        }
                     }
                     NodeList configNodes = e.getElementsByTagName("config");
                     for (int j = 0; j < configNodes.getLength(); j++) {


Mime
View raw message