You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2012/04/11 19:06:37 UTC

svn commit: r1324865 - in /ant/ivy/core/trunk: doc/samples/eclipse-plugin/ src/java/org/apache/ivy/core/settings/ src/java/org/apache/ivy/osgi/core/ src/java/org/apache/ivy/osgi/obr/xml/ src/java/org/apache/ivy/osgi/p2/ src/java/org/apache/ivy/osgi/rep...

Author: hibou
Date: Wed Apr 11 17:06:36 2012
New Revision: 1324865

URL: http://svn.apache.org/viewvc?rev=1324865&view=rev
Log:
Improvement of the resolve process of an OSGi dependency:
- no more extra attribute, the kind of dependency is in the organisation name
- while resolving transitive dependencies, make Ivy aware of the packages by making them real module rather then tricking it by immediately trying to find an implementation fitting the requirement

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java
      - copied, changed from r1311262, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiRevisionStrategy.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiLatestStrategyTest.java
      - copied, changed from r1311262, ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiRevisionStrategyTest.java
Removed:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiRevisionStrategy.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/ArtifactTokens.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiRevisionStrategyTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/util/ArtifactTokensTest.java
Modified:
    ant/ivy/core/trunk/doc/samples/eclipse-plugin/ivy.xml
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/Version.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolverTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/util/VersionTest.java

Modified: ant/ivy/core/trunk/doc/samples/eclipse-plugin/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/samples/eclipse-plugin/ivy.xml?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/samples/eclipse-plugin/ivy.xml (original)
+++ ant/ivy/core/trunk/doc/samples/eclipse-plugin/ivy.xml Wed Apr 11 17:06:36 2012
@@ -32,8 +32,8 @@
         <!-- example of a dependency that we can't declare in the MANIFEST.MF because we want it to be embedded -->
         <!--dependency osgi="bundle" org="" module="org.apache.commons.httpcore" rev="4.1.0" conf="embedded->default" /-->
         <!-- Ivy-Osgi doesn't understand bundle fragment -->
-        <dependency o:type="bundle" org="" name="org.eclipse.swt.win32.win32.x86" rev="3.+" conf="win32->default" />
-        <dependency o:type="bundle" org="" name="org.eclipse.swt.cocoa.macosx.x86_64" rev="3.+" conf="macos->default" />
-        <dependency o:type="bundle" org="" name="org.eclipse.swt.gtk.linux.x86" rev="3.+" conf="linux->default" />
+        <dependency org="bundle" name="org.eclipse.swt.win32.win32.x86" rev="3.+" conf="win32->default" />
+        <dependency org="bundle" name="org.eclipse.swt.cocoa.macosx.x86_64" rev="3.+" conf="macos->default" />
+        <dependency org="bundle" name="org.eclipse.swt.gtk.linux.x86" rev="3.+" conf="linux->default" />
      </dependencies>
 </ivy-module>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java Wed Apr 11 17:06:36 2012
@@ -59,7 +59,7 @@ import org.apache.ivy.core.resolve.Resol
 import org.apache.ivy.core.resolve.ResolveOptions;
 import org.apache.ivy.core.retrieve.RetrieveEngineSettings;
 import org.apache.ivy.core.sort.SortEngineSettings;
-import org.apache.ivy.osgi.core.OsgiRevisionStrategy;
+import org.apache.ivy.osgi.core.OsgiLatestStrategy;
 import org.apache.ivy.plugins.IvySettingsAware;
 import org.apache.ivy.plugins.circular.CircularDependencyStrategy;
 import org.apache.ivy.plugins.circular.ErrorCircularDependencyStrategy;
@@ -248,12 +248,12 @@ public class IvySettings implements Sort
         LatestLexicographicStrategy latestLexicographicStrategy = new LatestLexicographicStrategy();
         LatestRevisionStrategy latestRevisionStrategy = new LatestRevisionStrategy();
         LatestTimeStrategy latestTimeStrategy = new LatestTimeStrategy();
-        OsgiRevisionStrategy osgiRevisionStrategy = new OsgiRevisionStrategy();
+        OsgiLatestStrategy osgiLatestStrategy = new OsgiLatestStrategy();
 
         addLatestStrategy("latest-revision", latestRevisionStrategy);
         addLatestStrategy("latest-lexico", latestLexicographicStrategy);
         addLatestStrategy("latest-time", latestTimeStrategy);
-        addLatestStrategy("latest-osgi", osgiRevisionStrategy);
+        addLatestStrategy("latest-osgi", osgiLatestStrategy);
 
         addLockStrategy("no-lock", new NoLockStrategy());
         addLockStrategy("artifact-lock", new ArtifactLockStrategy(debugLocking()));

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java Wed Apr 11 17:06:36 2012
@@ -22,12 +22,10 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.ivy.Ivy;
@@ -66,16 +64,7 @@ public class BundleInfoAdapter {
 
     public static final String CONF_USE_PREFIX = "use_";
 
-    public static final String EXTRA_ATTRIBUTE_NAME = "o:type";
-
-    public static final Map/* <String, String> */OSGI_BUNDLE = Collections.singletonMap(
-        EXTRA_ATTRIBUTE_NAME, BundleInfo.BUNDLE_TYPE);
-
-    public static final Map/* <String, String> */OSGI_PACKAGE = Collections.singletonMap(
-        EXTRA_ATTRIBUTE_NAME, BundleInfo.PACKAGE_TYPE);
-
-    public static final Map/* <String, String> */OSGI_SERVICE = Collections.singletonMap(
-        EXTRA_ATTRIBUTE_NAME, BundleInfo.SERVICE_TYPE);
+    public static final String EXTRA_INFO_EXPORT_PREFIX = "_osgi_export_";
 
     /**
      * 
@@ -90,7 +79,7 @@ public class BundleInfoAdapter {
             ExecutionEnvironmentProfileProvider profileProvider) throws ProfileNotFoundException {
         DefaultModuleDescriptor md = new DefaultModuleDescriptor(null, null);
         md.addExtraAttributeNamespace("o", Ivy.getIvyHomeURL() + "osgi");
-        ModuleRevisionId mrid = asMrid(bundle.getSymbolicName(), bundle.getVersion(), OSGI_BUNDLE);
+        ModuleRevisionId mrid = asMrid(BundleInfo.BUNDLE_TYPE, bundle.getSymbolicName(), bundle.getVersion());
         md.setResolvedPublicationDate(new Date());
         md.setModuleRevisionId(mrid);
 
@@ -102,6 +91,8 @@ public class BundleInfoAdapter {
         Iterator itExport = bundle.getExports().iterator();
         while (itExport.hasNext()) {
             ExportPackage exportPackage = (ExportPackage) itExport.next();
+            md.getExtraInfo().put(EXTRA_INFO_EXPORT_PREFIX + exportPackage.getName(),
+                exportPackage.getVersion().toString());
             exportedPkgNames.add(exportPackage.getName());
             String[] confDependencies = new String[exportPackage.getUses().size() + 1];
             int i = 0;
@@ -151,11 +142,11 @@ public class BundleInfoAdapter {
                 Iterator itPkg = profile.getPkgNames().iterator();
                 while (itPkg.hasNext()) {
                     String pkg = (String) itPkg.next();
-                    ArtifactId id = new ArtifactId(ModuleId.newInstance("", pkg),
+                    ArtifactId id = new ArtifactId(ModuleId.newInstance(BundleInfo.BUNDLE_TYPE, pkg),
                             PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION,
                             PatternMatcher.ANY_EXPRESSION);
                     DefaultExcludeRule rule = new DefaultExcludeRule(id,
-                            ExactOrRegexpPatternMatcher.INSTANCE, OSGI_PACKAGE);
+                            ExactOrRegexpPatternMatcher.INSTANCE, null);
                     String[] confs = md.getConfigurationsNames();
                     for (int i = 0; i < confs.length; i++) {
                         rule.addConfiguration(confs[i]);
@@ -288,8 +279,7 @@ public class BundleInfoAdapter {
                 continue;
             }
 
-            Map/* <String, String> */osgiAtt = Collections.singletonMap(EXTRA_ATTRIBUTE_NAME, type);
-            ModuleRevisionId ddmrid = asMrid(name, requirement.getVersion(), osgiAtt);
+            ModuleRevisionId ddmrid = asMrid(type, name, requirement.getVersion());
             DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ddmrid, false);
 
             String conf = CONF_NAME_DEFAULT;
@@ -314,23 +304,18 @@ public class BundleInfoAdapter {
 
     }
 
-    private static ModuleRevisionId asMrid(String symbolicNAme, Version v,
-            Map/* <String, String> */extraAttr) {
-        return ModuleRevisionId.newInstance("", symbolicNAme, v == null ? null : v.toString(),
-            extraAttr);
+    public static ModuleRevisionId asMrid(String type, String name, Version v) {
+        return ModuleRevisionId.newInstance(type, name, v == null ? null : v.toString());
     }
 
-    private static ModuleRevisionId asMrid(String symbolicNAme, VersionRange v, Map/*
-                                                                                    * <String,
-                                                                                    * String>
-                                                                                    */extraAttr) {
+    public static ModuleRevisionId asMrid(String type, String name, VersionRange v) {
         String revision;
         if (v == null) {
             revision = "[0,)";
         } else {
             revision = v.toIvyRevision();
         }
-        return ModuleRevisionId.newInstance("", symbolicNAme, revision, extraAttr);
+        return ModuleRevisionId.newInstance(type, name, revision);
     }
 
     public static class ProfileNotFoundException extends RuntimeException {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java Wed Apr 11 17:06:36 2012
@@ -226,7 +226,7 @@ public class ManifestParser {
         return new VersionRange(v);
     }
 
-    private static Version versionOf(String v) throws NumberFormatException {
+    private static Version versionOf(String v) throws ParseException {
         if (v == null) {
             return null;
         }

Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java (from r1311262, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiRevisionStrategy.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiRevisionStrategy.java&r1=1311262&r2=1324865&rev=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiRevisionStrategy.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OsgiLatestStrategy.java Wed Apr 11 17:06:36 2012
@@ -17,30 +17,18 @@
  */
 package org.apache.ivy.osgi.core;
 
+import java.text.ParseException;
 import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.regex.Pattern;
 
 import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.osgi.util.Version;
 import org.apache.ivy.plugins.latest.ArtifactInfo;
 import org.apache.ivy.plugins.latest.ComparatorLatestStrategy;
 import org.apache.ivy.plugins.version.VersionMatcher;
 
-public class OsgiRevisionStrategy extends ComparatorLatestStrategy {
+public class OsgiLatestStrategy extends ComparatorLatestStrategy {
 
-    private static final Pattern ALPHA_NUM_REGEX = Pattern.compile("([a-zA-Z])(\\d)");
-
-    private static final Pattern NUM_ALPHA_REGEX = Pattern.compile("(\\d)([a-zA-Z])");
-
-    private static final Pattern LABEL_REGEX = Pattern.compile("[_\\-\\+]");
-
-    /**
-     * Compares two ModuleRevisionId by their revision. Revisions are compared using an algorithm
-     * inspired by PHP version_compare one.
-     */
     final class MridComparator implements Comparator/* <ModuleRevisionId> */{
 
         public int compare(Object o1, Object o2) {
@@ -48,83 +36,20 @@ public class OsgiRevisionStrategy extend
         }
 
         public int compare(ModuleRevisionId o1, ModuleRevisionId o2) {
-            String rev1 = o1.getRevision();
-            String rev2 = o2.getRevision();
-
-            String[] outerParts1 = rev1.split("[\\.]");
-            String[] outerParts2 = rev2.split("[\\.]");
-
-            for (int i = 0; i < outerParts1.length && i < outerParts2.length; i++) {
-                String outerPart1 = outerParts1[i];
-                String outerPart2 = outerParts2[i];
-
-                if (outerPart1.equals(outerPart2)) {
-                    continue;
-                }
-
-                outerPart1 = ALPHA_NUM_REGEX.matcher(outerPart1).replaceAll("$1_$2");
-                outerPart1 = NUM_ALPHA_REGEX.matcher(outerPart1).replaceAll("$1_$2");
-                outerPart2 = ALPHA_NUM_REGEX.matcher(outerPart2).replaceAll("$1_$2");
-                outerPart2 = NUM_ALPHA_REGEX.matcher(outerPart2).replaceAll("$1_$2");
-
-                String[] innerParts1 = LABEL_REGEX.split(outerPart1);
-                String[] innerParts2 = LABEL_REGEX.split(outerPart2);
-
-                for (int j = 0; j < innerParts1.length && j < innerParts2.length; j++) {
-                    if (innerParts1[j].equals(innerParts2[j])) {
-                        continue;
-                    }
-                    boolean is1Number = isNumber(innerParts1[j]);
-                    boolean is2Number = isNumber(innerParts2[j]);
-                    if (is1Number && !is2Number) {
-                        return 1;
-                    }
-                    if (is2Number && !is1Number) {
-                        return -1;
-                    }
-                    if (is1Number && is2Number) {
-                        return Long.valueOf(innerParts1[j]).compareTo(Long.valueOf(innerParts2[j]));
-                    }
-                    // both are strings, we compare them taking into account special meaning
-                    Map/* <String, Integer> */meanings = getSpecialMeanings();
-                    Integer sm1 = (Integer) meanings.get(innerParts1[j].toLowerCase(Locale.US));
-                    Integer sm2 = (Integer) meanings.get(innerParts2[j].toLowerCase(Locale.US));
-                    if (sm1 != null) {
-                        sm2 = sm2 == null ? new Integer(0) : sm2;
-                        return sm1.compareTo(sm2);
-                    }
-                    if (sm2 != null) {
-                        return new Integer(0).compareTo(sm2);
-                    }
-                    return innerParts1[j].compareTo(innerParts2[j]);
-                }
-                if (i < innerParts1.length) {
-                    return isNumber(innerParts1[i]) ? 1 : -1;
-                }
-                if (i < innerParts2.length) {
-                    return isNumber(innerParts2[i]) ? -1 : 1;
-                }
+            Version v1;
+            Version v2;
+            try {
+                v1 = new Version(o1.getRevision());
+                v2 = new Version(o2.getRevision());
+            } catch (ParseException e) {
+                throw new RuntimeException("Uncomparable versions:" + o1.getRevision() + " and "
+                        + o2.getRevision() + " (" + e.getMessage() + ")");
             }
-
-            if (outerParts1.length > outerParts2.length) {
-                return 1;
-            } else if (outerParts1.length < outerParts2.length) {
-                return -1;
-            }
-
-            return 0;
+            return v1.compareTo(v2);
         }
 
-        private boolean isNumber(String str) {
-            return str.matches("\\d+");
-        }
     }
 
-    /**
-     * Compares two ArtifactInfo by their revision. Revisions are compared using an algorithm
-     * inspired by PHP version_compare one, unless a dynamic revision is given, in which case the
-     * version matcher is used to perform the comparison.
-     */
     final class ArtifactInfoComparator implements Comparator/* <ArtifactInfo> */{
 
         public int compare(Object o1, Object o2) {
@@ -158,78 +83,13 @@ public class OsgiRevisionStrategy extend
         }
     }
 
-    public static class SpecialMeaning {
-        private String name;
-
-        private Integer value;
-
-        public String getName() {
-            return name;
-        }
-
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        public Integer getValue() {
-            return value;
-        }
-
-        public void setValue(Integer value) {
-            this.value = value;
-        }
-
-        public void validate() {
-            if (name == null) {
-                throw new IllegalStateException("a special meaning should have a name");
-            }
-            if (value == null) {
-                throw new IllegalStateException("a special meaning should have a value");
-            }
-        }
-    }
-
-    private static final Map/* <String, Integer> */DEFAULT_SPECIAL_MEANINGS;
-    static {
-        DEFAULT_SPECIAL_MEANINGS = new HashMap/* <String, Integer> */();
-        DEFAULT_SPECIAL_MEANINGS.put("dev", new Integer(-1));
-        DEFAULT_SPECIAL_MEANINGS.put("rc", new Integer(1));
-        DEFAULT_SPECIAL_MEANINGS.put("final", new Integer(2));
-    }
-
     private final Comparator/* <ModuleRevisionId> */mridComparator = new MridComparator();
 
     private final Comparator/* <ArtifactInfo> */artifactInfoComparator = new ArtifactInfoComparator();
 
-    private Map/* <String, Integer> */specialMeanings = null;
-
-    private boolean usedefaultspecialmeanings = true;
-
-    public OsgiRevisionStrategy() {
+    public OsgiLatestStrategy() {
         setComparator(artifactInfoComparator);
-        setName("latest-revision");
+        setName("latest-osgi");
     }
 
-    public void addConfiguredSpecialMeaning(SpecialMeaning meaning) {
-        meaning.validate();
-        getSpecialMeanings().put(meaning.getName().toLowerCase(Locale.US), meaning.getValue());
-    }
-
-    public synchronized Map/* <String, Integer> */getSpecialMeanings() {
-        if (specialMeanings == null) {
-            specialMeanings = new HashMap/* <String, Integer> */();
-            if (isUsedefaultspecialmeanings()) {
-                specialMeanings.putAll(DEFAULT_SPECIAL_MEANINGS);
-            }
-        }
-        return specialMeanings;
-    }
-
-    public boolean isUsedefaultspecialmeanings() {
-        return usedefaultspecialmeanings;
-    }
-
-    public void setUsedefaultspecialmeanings(boolean usedefaultspecialmeanings) {
-        this.usedefaultspecialmeanings = usedefaultspecialmeanings;
-    }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java Wed Apr 11 17:06:36 2012
@@ -179,7 +179,7 @@ public class OBRXMLParser {
             Version version;
             try {
                 version = new Version(v);
-            } catch (NumberFormatException e) {
+            } catch (ParseException e) {
                 log(Message.MSG_ERR, "Incorrect resource version: " + v + ". The resource "
                         + symbolicname + " is then ignored.");
                 skip();

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java Wed Apr 11 17:06:36 2012
@@ -93,7 +93,7 @@ public class RequirementAdapter {
     }
 
     private void parseCompareFilter(CompareFilter compareFilter, boolean not)
-            throws UnsupportedFilterException {
+            throws UnsupportedFilterException, ParseException {
         String att = compareFilter.getLeftValue();
         if (BundleInfo.PACKAGE_TYPE.equals(att) || BundleInfo.BUNDLE_TYPE.equals(att)
                 || "symbolicname".equals(att) || BundleInfo.SERVICE_TYPE.equals(att)) {
@@ -116,6 +116,12 @@ public class RequirementAdapter {
             name = compareFilter.getRightValue();
         } else if ("version".equals(att)) {
             String v = compareFilter.getRightValue();
+            Version version;
+            try {
+                version = new Version(v);
+            } catch (ParseException e) {
+                throw new ParseException("Ill formed version: " + v, 0);
+            }
             Operator operator = compareFilter.getOperator();
             if (not) {
                 if (operator == Operator.EQUALS) {
@@ -136,37 +142,37 @@ public class RequirementAdapter {
                     throw new UnsupportedFilterException(
                             "Multiple version matching is not supported");
                 }
-                startVersion = new Version(v);
+                startVersion = version;
                 startExclusive = false;
-                endVersion = new Version(v);
+                endVersion = version;
                 endExclusive = false;
             } else if (operator == Operator.GREATER_OR_EQUAL) {
                 if (startVersion != null) {
                     throw new UnsupportedFilterException(
                             "Multiple version matching is not supported");
                 }
-                startVersion = new Version(v);
+                startVersion = version;
                 startExclusive = false;
             } else if (operator == Operator.GREATER_THAN) {
                 if (startVersion != null) {
                     throw new UnsupportedFilterException(
                             "Multiple version matching is not supported");
                 }
-                startVersion = new Version(v);
+                startVersion = version;
                 startExclusive = true;
             } else if (operator == Operator.LOWER_OR_EQUAL) {
                 if (endVersion != null) {
                     throw new UnsupportedFilterException(
                             "Multiple version matching is not supported");
                 }
-                endVersion = new Version(v);
+                endVersion = version;
                 endExclusive = false;
             } else if (operator == Operator.LOWER_THAN) {
                 if (endVersion != null) {
                     throw new UnsupportedFilterException(
                             "Multiple version matching is not supported");
                 }
-                endVersion = new Version(v);
+                endVersion = version;
                 endExclusive = true;
             }
         } else {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java Wed Apr 11 17:06:36 2012
@@ -195,9 +195,15 @@ public class P2ArtifactParser implements
             });
         }
 
-        protected void handleAttributes(Attributes atts) {
+        protected void handleAttributes(Attributes atts) throws SAXException {
             String id = atts.getValue(ID);
-            Version version = new Version(atts.getValue(VERSION));
+            Version version;
+            try {
+                version = new Version(atts.getValue(VERSION));
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version attribute on artifact '" + id + "': "
+                        + atts.getValue(VERSION) + " (" + e.getMessage() + ")");
+            }
             String classifier = atts.getValue(CLASSIFIER);
 
             p2Artifact = new P2Artifact(id, version, classifier);

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java Wed Apr 11 17:06:36 2012
@@ -286,11 +286,16 @@ public class P2MetadataParser implements
 
         }
 
-        protected void handleAttributes(Attributes atts) {
+        protected void handleAttributes(Attributes atts) throws SAXException {
             String id = atts.getValue(ID);
-            Version version = new Version(atts.getValue(VERSION));
+            String version = atts.getValue(VERSION);
             // Boolean singleton = Boolean.valueOf(atts.getValue(SINGLETON));
-            bundleInfo = new BundleInfo(id, version);
+            try {
+                bundleInfo = new BundleInfo(id, new Version(version));
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version on bundle '" + id + "': " + version
+                        + " (" + e.getMessage() + ")");
+            }
         }
 
     }
@@ -394,10 +399,15 @@ public class P2MetadataParser implements
             super(PROVIDED);
         }
 
-        protected void handleAttributes(Attributes atts) {
+        protected void handleAttributes(Attributes atts) throws SAXException {
             namespace = atts.getValue(NAMESPACE);
             name = atts.getValue(NAME);
-            version = new Version(atts.getValue(VERSION));
+            try {
+                version = new Version(atts.getValue(VERSION));
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version on provided capability: " + version
+                        + " (" + e.getMessage() + ")");
+            }
         }
 
     }
@@ -536,11 +546,16 @@ public class P2MetadataParser implements
             super(ARTIFACT);
         }
 
-        protected void handleAttributes(Attributes atts) {
+        protected void handleAttributes(Attributes atts) throws SAXException {
             String id = atts.getValue(ID);
-            Version version = new Version(atts.getValue(VERSION));
+            String version = atts.getValue(VERSION);
             String classifier = atts.getValue(CLASSIFIER);
-            artifact = new P2Artifact(id, version, classifier);
+            try {
+                artifact = new P2Artifact(id, new Version(version), classifier);
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version on artifact '" + id + "': " + version
+                        + " (" + e.getMessage() + ")");
+            }
         }
 
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptorBasedResolver.java Wed Apr 11 17:06:36 2012
@@ -20,6 +20,7 @@ package org.apache.ivy.osgi.repo;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -35,11 +36,15 @@ import java.util.Set;
 
 import org.apache.ivy.core.IvyPatternHelper;
 import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
 import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.DownloadStatus;
 import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
+import org.apache.ivy.core.resolve.IvyNode;
 import org.apache.ivy.core.resolve.ResolveData;
 import org.apache.ivy.core.resolve.ResolvedModuleRevision;
 import org.apache.ivy.osgi.core.BundleInfo;
@@ -56,6 +61,8 @@ import org.apache.ivy.util.Message;
 
 public abstract class RepoDescriptorBasedResolver extends BasicResolver {
 
+    private static final String CAPABILITY_EXTRA_ATTR = "osgi_bundle";
+
     private RepoDescriptor repoDescriptor = null;
 
     private URLRepository repository = new URLRepository();
@@ -109,22 +116,45 @@ public abstract class RepoDescriptorBase
         return repoDescriptor;
     }
 
-    public boolean isCheckconsistency() {
-        // since a module can fit a requirement with a different id, no not check anything
+    public boolean isAllownomd() {
+        // this a repo based resolver, we always have md
         return false;
     }
 
     public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
         ModuleRevisionId mrid = dd.getDependencyRevisionId();
 
-        String osgiAtt = mrid.getExtraAttribute(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
+        String osgiType = mrid.getOrganisation();
+        if (osgiType == null) {
+            throw new RuntimeException("Unsupported OSGi module Id: " + mrid.getModuleId());
+        }
         String id = mrid.getName();
-        Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiAtt, id);
+        Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiType, id);
         if (mds == null || mds.isEmpty()) {
             Message.verbose("\t " + id + " not found.");
             return null;
         }
 
+        ResolvedResource[] ret;
+        if (BundleInfo.BUNDLE_TYPE.equals(osgiType)) {
+            ret = findBundle(dd, data, mds);
+        } else {
+            ret = findCapability(dd, data, mds);
+        }
+
+        ResolvedResource found = findResource(ret, getDefaultRMDParser(dd.getDependencyId()), mrid,
+            data.getDate());
+        if (found == null) {
+            Message.debug("\t" + getName() + ": no resource found for " + mrid);
+        }
+        return found;
+    }
+
+    public ResolvedResource[] findBundle(DependencyDescriptor dd, ResolveData data, Set/*
+                                                                                        * <
+                                                                                        * ModuleDescriptor
+                                                                                        * >
+                                                                                        */mds) {
         ResolvedResource[] ret = new ResolvedResource[mds.size()];
         int i = 0;
         Iterator itMd = mds.iterator();
@@ -135,37 +165,82 @@ public abstract class RepoDescriptorBase
             report.setSearched(true);
             ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, md, report);
             MDResolvedResource mdrr = new MDResolvedResource(null, md.getRevision(), rmr);
-            if (!BundleInfo.BUNDLE_TYPE.equals(osgiAtt)) {
-                if (data.getVisitData(md.getModuleRevisionId()) != null) {
-                    // already resolved import, no need to go further
-                    return mdrr;
-                }
-            }
             ret[i++] = mdrr;
         }
+        return ret;
+    }
 
-        ResolvedResource found = findResource(ret, getDefaultRMDParser(dd.getDependencyId()), mrid,
-            data.getDate());
-        if (found == null) {
-            Message.debug("\t" + getName() + ": no resource found for " + mrid);
-        }
-        return found;
+    public ResolvedResource[] findCapability(DependencyDescriptor dd, ResolveData data, Set/*
+                                                                                            * <
+                                                                                            * ModuleDescriptor
+                                                                                            * >
+                                                                                            */mds) {
+        ResolvedResource[] ret = new ResolvedResource[mds.size()];
+        int i = 0;
+        Iterator itMd = mds.iterator();
+        while (itMd.hasNext()) {
+            ModuleDescriptor md = (ModuleDescriptor) itMd.next();
+            IvyNode node = data.getNode(md.getModuleRevisionId());
+            if (node != null) {
+                // already resolved import, no need to go further
+                return new ResolvedResource[] {buildResolvedCapabilityMd(dd, node.getDescriptor())};
+            }
+            ret[i++] = buildResolvedCapabilityMd(dd, md);
+        }
+        return ret;
+    }
+
+    private MDResolvedResource buildResolvedCapabilityMd(DependencyDescriptor dd,
+            ModuleDescriptor md) {
+        String org = dd.getDependencyRevisionId().getOrganisation();
+        String name = dd.getDependencyRevisionId().getName();
+        String rev = (String) md.getExtraInfo().get(
+            BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX + name);
+        ModuleRevisionId capabilityRev = ModuleRevisionId.newInstance(org, name, rev,
+            Collections.singletonMap(CAPABILITY_EXTRA_ATTR, md.getModuleRevisionId().toString()));
+
+        DefaultModuleDescriptor capabilityMd = new DefaultModuleDescriptor(capabilityRev,
+                "release", new Date());
+
+        String useConf = BundleInfoAdapter.CONF_USE_PREFIX + dd.getDependencyRevisionId().getName();
+
+        capabilityMd.addConfiguration(BundleInfoAdapter.CONF_DEFAULT);
+        capabilityMd.addConfiguration(BundleInfoAdapter.CONF_OPTIONAL);
+        capabilityMd.addConfiguration(BundleInfoAdapter.CONF_TRANSITIVE_OPTIONAL);
+        capabilityMd.addConfiguration(new Configuration(useConf));
+
+        DefaultDependencyDescriptor capabilityDD = new DefaultDependencyDescriptor(
+                md.getModuleRevisionId(), false);
+        capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_DEFAULT,
+            BundleInfoAdapter.CONF_NAME_DEFAULT);
+        capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_OPTIONAL,
+            BundleInfoAdapter.CONF_NAME_OPTIONAL);
+        capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL,
+            BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL);
+        capabilityDD.addDependencyConfiguration(useConf, useConf);
+        capabilityMd.addDependency(capabilityDD);
+
+        MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
+        report.setDownloadStatus(DownloadStatus.NO);
+        report.setSearched(true);
+        ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, capabilityMd, report);
+        return new MDResolvedResource(null, capabilityMd.getRevision(), rmr);
     }
 
     public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
             ModuleRevisionId mrid, Date date) {
         ResolvedResource found = super.findResource(rress, rmdparser, mrid, date);
 
-        String osgiAtt = mrid.getExtraAttribute(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
+        String osgiType = mrid.getOrganisation();
         // for non bundle requirement : log the selected bundle
-        if (!BundleInfo.BUNDLE_TYPE.equals(osgiAtt)) {
+        if (!BundleInfo.BUNDLE_TYPE.equals(osgiType)) {
             // several candidates with different symbolic name : make an warning about the ambiguity
             if (rress.length != 1) {
                 // several candidates with different symbolic name ?
                 Map/* <String, List<MDResolvedResource>> */matching = new HashMap();
                 for (int i = 0; i < rress.length; i++) {
                     String name = ((MDResolvedResource) rress[i]).getResolvedModuleRevision()
-                            .getId().getName();
+                            .getDescriptor().getExtraAttribute(CAPABILITY_EXTRA_ATTR);
                     List/* <MDResolvedResource> */list = (List) matching.get(name);
                     if (list == null) {
                         list = new ArrayList/* <MDResolvedResource> */();
@@ -175,7 +250,7 @@ public abstract class RepoDescriptorBase
                 }
                 if (matching.keySet().size() != 1) {
                     if (requirementStrategy == RequirementStrategy.first) {
-                        Message.warn("Ambiguity for the '" + osgiAtt + "' requirement "
+                        Message.warn("Ambiguity for the '" + osgiType + "' requirement "
                                 + mrid.getName() + ";version=" + mrid.getRevision());
                         Iterator itMatching = matching.entrySet().iterator();
                         while (itMatching.hasNext()) {
@@ -190,7 +265,7 @@ public abstract class RepoDescriptorBase
                             }
                         }
                     } else if (requirementStrategy == RequirementStrategy.noambiguity) {
-                        Message.error("Ambiguity for the '" + osgiAtt + "' requirement "
+                        Message.error("Ambiguity for the '" + osgiType + "' requirement "
                                 + mrid.getName() + ";version=" + mrid.getRevision());
                         Iterator itMatching = matching.entrySet().iterator();
                         while (itMatching.hasNext()) {
@@ -208,7 +283,7 @@ public abstract class RepoDescriptorBase
                     }
                 }
             }
-            Message.info("'" + osgiAtt + "' requirement " + mrid.getName() + ";version="
+            Message.info("'" + osgiType + "' requirement " + mrid.getName() + ";version="
                     + mrid.getRevision() + " satisfied by "
                     + ((MDResolvedResource) found).getResolvedModuleRevision().getId().getName()
                     + ";" + found.getRevision());
@@ -227,9 +302,10 @@ public abstract class RepoDescriptorBase
 
     protected void checkModuleDescriptorRevision(ModuleDescriptor systemMd,
             ModuleRevisionId systemMrid) {
-        String osgiAtt = systemMrid.getExtraAttribute(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
-        // only check revision if we're searching for a bundle (package and bundle have different version
-        if (osgiAtt == null || osgiAtt.equals(BundleInfo.BUNDLE_TYPE)) {
+        String osgiType = systemMrid.getOrganisation();
+        // only check revision if we're searching for a bundle (package and bundle have different
+        // version
+        if (osgiType == null || osgiType.equals(BundleInfo.BUNDLE_TYPE)) {
             super.checkModuleDescriptorRevision(systemMd, systemMrid);
         }
     }
@@ -240,35 +316,28 @@ public abstract class RepoDescriptorBase
     }
 
     protected Collection findNames(Map tokenValues, String token) {
-        if (BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME.equals(token)) {
-            return Arrays.asList(new String[] {BundleInfo.BUNDLE_TYPE, BundleInfo.PACKAGE_TYPE,
-                    BundleInfo.SERVICE_TYPE});
-        }
-
         if (IvyPatternHelper.ORGANISATION_KEY.equals(token)) {
-            return Collections.singletonList("");
+            return getRepoDescriptor().getModuleByCapbilities().keySet();
         }
 
-        String org = (String) tokenValues.get(IvyPatternHelper.ORGANISATION_KEY);
-        if (org != null && org.length() != 0) {
-            return Collections.EMPTY_LIST;
+        String osgiType = (String) tokenValues.get(IvyPatternHelper.ORGANISATION_KEY);
+        if (osgiType == null || osgiType.length() == 0) {
+            return Collections.emptyList();
         }
 
-        String osgiAtt = (String) tokenValues.get(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
         String rev = (String) tokenValues.get(IvyPatternHelper.REVISION_KEY);
 
         if (IvyPatternHelper.MODULE_KEY.equals(token)) {
             Map/* <String, Map<String, Set<ModuleDescriptor>>> */moduleByCapbilities = getRepoDescriptor()
                     .getModuleByCapbilities();
-            if (osgiAtt != null) {
+            if (osgiType != null) {
                 Map/* <String, Set<ModuleDescriptor>> */moduleByCapabilityValue = (Map) moduleByCapbilities
-                        .get(osgiAtt);
+                        .get(osgiType);
                 if (moduleByCapabilityValue == null) {
                     return Collections.EMPTY_LIST;
                 }
                 Set/* <String> */capabilityValues = new HashSet();
-                filterCapabilityValues(capabilityValues, moduleByCapbilities, tokenValues, rev);
-                return capabilityValues;
+                return moduleByCapabilityValue.keySet();
             } else {
                 Set/* <String> */capabilityValues = new HashSet();
                 Iterator/* <Map<String, Set<ModuleDescriptor>>> */it = ((Collection) moduleByCapbilities
@@ -286,7 +355,7 @@ public abstract class RepoDescriptorBase
         if (IvyPatternHelper.REVISION_KEY.equals(token)) {
             String name = (String) tokenValues.get(IvyPatternHelper.MODULE_KEY);
             List/* <String> */versions = new ArrayList/* <String> */();
-            Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiAtt, name);
+            Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiType, name);
             if (mds != null) {
                 Iterator itMd = mds.iterator();
                 while (itMd.hasNext()) {
@@ -302,11 +371,11 @@ public abstract class RepoDescriptorBase
             if (name == null) {
                 return Collections.EMPTY_LIST;
             }
-            if (osgiAtt.equals(BundleInfo.PACKAGE_TYPE)) {
+            if (osgiType.equals(BundleInfo.PACKAGE_TYPE)) {
                 return Collections.singletonList(BundleInfoAdapter.CONF_USE_PREFIX + name);
             }
             Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
-                    .findModule(osgiAtt, name);
+                    .findModule(osgiType, name);
             if (bundleCapabilities == null) {
                 return Collections.EMPTY_LIST;
             }
@@ -317,7 +386,7 @@ public abstract class RepoDescriptorBase
             Version v;
             try {
                 v = new Version(version);
-            } catch (NumberFormatException e) {
+            } catch (ParseException e) {
                 return Collections.EMPTY_LIST;
             }
             BundleCapabilityAndLocation found = null;
@@ -385,35 +454,32 @@ public abstract class RepoDescriptorBase
 
         Map/* <String, String> */values = new HashMap/* <String, String> */();
 
-        tokenSet.remove(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
-        String osgiAtt = (String) criteria.get(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
-        if (osgiAtt == null) {
+        tokenSet.remove(IvyPatternHelper.ORGANISATION_KEY);
+        String osgiType = (String) criteria.get(IvyPatternHelper.ORGANISATION_KEY);
+        if (osgiType == null || osgiType.length() == 0) {
+            return Collections.emptySet();
+        }
+        values.put(IvyPatternHelper.ORGANISATION_KEY, osgiType);
+
+        if (osgiType == null) {
             Set/* <Map<String, String>> */tokenValues = new HashSet/* <Map<String, String>> */();
             Map/* <String, String> */newCriteria = new HashMap/* <String, String> */(criteria);
-            newCriteria.put(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME, BundleInfo.BUNDLE_TYPE);
+            newCriteria.put(IvyPatternHelper.ORGANISATION_KEY, BundleInfo.BUNDLE_TYPE);
             tokenValues.addAll(listTokenValues(tokenSet, newCriteria));
             newCriteria = new HashMap/* <String, String> */(criteria);
-            newCriteria.put(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME, BundleInfo.PACKAGE_TYPE);
+            newCriteria.put(IvyPatternHelper.ORGANISATION_KEY, BundleInfo.PACKAGE_TYPE);
             tokenValues.addAll(listTokenValues(tokenSet, newCriteria));
             newCriteria = new HashMap/* <String, String> */(criteria);
-            newCriteria.put(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME, BundleInfo.SERVICE_TYPE);
+            newCriteria.put(IvyPatternHelper.ORGANISATION_KEY, BundleInfo.SERVICE_TYPE);
             tokenValues.addAll(listTokenValues(tokenSet, newCriteria));
             return tokenValues;
         }
-        values.put(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME, osgiAtt);
 
-        Set/* <String> */capabilities = getRepoDescriptor().getCapabilityValues(osgiAtt);
+        Set/* <String> */capabilities = getRepoDescriptor().getCapabilityValues(osgiType);
         if (capabilities == null || capabilities.isEmpty()) {
             return Collections.EMPTY_SET;
         }
 
-        tokenSet.remove(IvyPatternHelper.ORGANISATION_KEY);
-        String org = (String) criteria.get(IvyPatternHelper.ORGANISATION_KEY);
-        if (org != null && org.length() != 0) {
-            return Collections.EMPTY_SET;
-        }
-        values.put(IvyPatternHelper.ORGANISATION_KEY, "");
-
         tokenSet.remove(IvyPatternHelper.MODULE_KEY);
         String module = (String) criteria.get(IvyPatternHelper.MODULE_KEY);
         if (module == null) {
@@ -433,7 +499,7 @@ public abstract class RepoDescriptorBase
         String rev = (String) criteria.get(IvyPatternHelper.REVISION_KEY);
         if (rev == null) {
             Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
-                    .findModule(osgiAtt, module);
+                    .findModule(osgiType, module);
             if (bundleCapabilities == null) {
                 return Collections.EMPTY_SET;
             }
@@ -453,19 +519,19 @@ public abstract class RepoDescriptorBase
         tokenSet.remove(IvyPatternHelper.CONF_KEY);
         String conf = (String) criteria.get(IvyPatternHelper.CONF_KEY);
         if (conf == null) {
-            if (osgiAtt.equals(BundleInfo.PACKAGE_TYPE)) {
+            if (osgiType.equals(BundleInfo.PACKAGE_TYPE)) {
                 values.put(IvyPatternHelper.CONF_KEY, BundleInfoAdapter.CONF_USE_PREFIX + module);
                 return Collections./* <Map<String, String>> */singleton(values);
             }
             Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
-                    .findModule(osgiAtt, module);
+                    .findModule(osgiType, module);
             if (bundleCapabilities == null) {
                 return Collections.EMPTY_SET;
             }
             Version v;
             try {
                 v = new Version(rev);
-            } catch (NumberFormatException e) {
+            } catch (ParseException e) {
                 return Collections.EMPTY_SET;
             }
             BundleCapabilityAndLocation found = null;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java Wed Apr 11 17:06:36 2012
@@ -177,7 +177,14 @@ public class EclipseUpdateSiteParser {
         }
 
         protected void handleAttributes(Attributes atts) throws SAXException {
-            feature = new EclipseFeature(atts.getValue(ID), new Version(atts.getValue(VERSION)));
+            String id = atts.getValue(ID);
+            String version = atts.getValue(VERSION);
+            try {
+                feature = new EclipseFeature(id, new Version(version));
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version on the feature '" + id + "': " + version
+                        + " (" + e.getMessage() + ")");
+            }
 
             String url = atts.getValue(URL);
             if (url != null) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java Wed Apr 11 17:06:36 2012
@@ -116,7 +116,14 @@ public class FeatureParser {
         }
 
         protected void handleAttributes(Attributes atts) throws SAXException {
-            feature = new EclipseFeature(atts.getValue(ID), new Version(atts.getValue(VERSION)));
+            String id = atts.getValue(ID);
+            String version = atts.getValue(VERSION);
+            try {
+                feature = new EclipseFeature(id, new Version(version));
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version on feature '" + id + "': " + version
+                        + " (" + e.getMessage() + ")");
+            }
 
             feature.setOS(atts.getValue(OS));
             feature.setWS(atts.getValue(WS));
@@ -157,8 +164,16 @@ public class FeatureParser {
         protected void handleAttributes(Attributes atts) throws SAXException {
             plugin = new EclipsePlugin();
 
-            plugin.setId(atts.getValue(ID));
-            plugin.setVersion(new Version(atts.getValue(VERSION)));
+            String id = atts.getValue(ID);
+            String version = atts.getValue(VERSION);
+
+            plugin.setId(id);
+            try {
+                plugin.setVersion(new Version(version));
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version on feature's plugin '" + id + "': "
+                        + version + " (" + e.getMessage() + ")");
+            }
             plugin.setUnpack(Boolean.valueOf(atts.getValue(UNPACK)).booleanValue());
             plugin.setFragment(atts.getValue(FRAGMENT));
             plugin.setFilter(atts.getValue(FILTER));
@@ -253,9 +268,16 @@ public class FeatureParser {
         protected void handleAttributes(Attributes atts) throws SAXException {
             require = new Require();
 
+            String version = atts.getValue(VERSION);
+
             require.setFeature(atts.getValue(FEATURE));
             require.setPlugin(atts.getValue(PLUGIN));
-            require.setVersion(new Version(atts.getValue(VERSION)));
+            try {
+                require.setVersion(new Version(version));
+            } catch (ParseException e) {
+                throw new SAXException("Incorrect version on feature's import: " + version + " ("
+                        + e.getMessage() + ")");
+            }
             require.setMatch(atts.getValue(MATCH));
             require.setFilter(atts.getValue(FILTER));
         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/Version.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/Version.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/Version.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/Version.java Wed Apr 11 17:06:36 2012
@@ -17,6 +17,8 @@
  */
 package org.apache.ivy.osgi.util;
 
+import java.text.ParseException;
+
 /**
  * Provides OSGi version support.
  */
@@ -30,16 +32,31 @@ public class Version implements Comparab
 
     private final String qualifier;
 
-    public Version(String versionStr, String qualifier) throws NumberFormatException {
+    public Version(String versionStr, String qualifier) throws ParseException {
         this(versionStr + "." + (qualifier != null ? qualifier : ""));
     }
 
-    public Version(String versionStr) throws NumberFormatException {
-        final String[] tmp = versionStr.split("[\\.]");
-        major = Integer.parseInt(tmp[0]);
-        minor = tmp.length >= 2 ? Integer.parseInt(tmp[1]) : 0;
-        patch = tmp.length >= 3 ? Integer.parseInt(tmp[2]) : 0;
-        qualifier = tmp.length == 4 ? tmp[3] : null;
+    public Version(String versionStr) throws ParseException {
+        String[] splits = versionStr.split("\\.");
+        if (splits == null || splits.length == 0 || splits.length > 4) {
+            throw new ParseException("Ill formed OSGi version", 0);
+        }
+        try {
+            major = Integer.parseInt(splits[0]);
+        } catch (NumberFormatException e) {
+            throw new ParseException("Major part of an OSGi version should be an integer", 0);
+        }
+        try {
+            minor = splits.length >= 2 ? Integer.parseInt(splits[1]) : 0;
+        } catch (NumberFormatException e) {
+            throw new ParseException("Minor part of an OSGi version should be an integer", 0);
+        }
+        try {
+            patch = splits.length >= 3 ? Integer.parseInt(splits[2]) : 0;
+        } catch (NumberFormatException e) {
+            throw new ParseException("Patch part of an OSGi version should be an integer", 0);
+        }
+        qualifier = splits.length == 4 ? splits[3] : null;
     }
 
     public Version(int major, int minor, int patch, String qualifier) {
@@ -49,6 +66,20 @@ public class Version implements Comparab
         this.qualifier = qualifier;
     }
 
+    /**
+     * Build a version from another one while appending an extra qualifier
+     * 
+     * @param baseVersion
+     * @param qualifier
+     */
+    public Version(Version baseVersion, String extraQualifier) {
+        this.major = baseVersion.major;
+        this.minor = baseVersion.minor;
+        this.patch = baseVersion.patch;
+        this.qualifier = baseVersion.qualifier == null ? extraQualifier
+                : (baseVersion.qualifier + extraQualifier);
+    }
+
     public String toString() {
         return numbersAsString() + (qualifier == null ? "" : "." + qualifier);
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/util/VersionRange.java Wed Apr 11 17:06:36 2012
@@ -306,7 +306,7 @@ public class VersionRange {
         return startVersion.equals(endVersion);
     }
 
-    public boolean contains(String versionStr) {
+    public boolean contains(String versionStr) throws ParseException {
         return contains(new Version(versionStr));
     }
 

Copied: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiLatestStrategyTest.java (from r1311262, ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiRevisionStrategyTest.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiLatestStrategyTest.java?p2=ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiLatestStrategyTest.java&p1=ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiRevisionStrategyTest.java&r1=1311262&r2=1324865&rev=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiRevisionStrategyTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/OsgiLatestStrategyTest.java Wed Apr 11 17:06:36 2012
@@ -27,69 +27,50 @@ import junit.framework.TestCase;
 
 import org.apache.ivy.plugins.latest.ArtifactInfo;
 
-public class OsgiRevisionStrategyTest extends TestCase {
+public class OsgiLatestStrategyTest extends TestCase {
 
     public void testComparator() {
-        ArtifactInfo[] revs = toMockAI(new String[] {"0.2a", "0.2_b", "0.2rc1", "0.2-final",
-                "1.0-dev1", "1.0-dev2", "1.0-alpha1", "1.0-alpha2", "1.0-beta1", "1.0-beta2",
-                "1.0-gamma", "1.0-rc1", "1.0-rc2", "1.0", "1.0.1", "2.0", "2.0.0", "2.0.0.b006",
-                "2.0.0.b012", "2.0.0.xyz"});
+        ArtifactInfo[] revs = toMockAI(new String[] {"0.2.0.a", "0.2.0.b", "0.2.0.final", "1.0",
+                "1.0.0.gamma", "1.0.0.rc1", "1.0.0.rc2", "1.0.1", "2", "2.0.0.b006", "2.0.0.b012",
+                "2.0.0.xyz"});
 
         List shuffled = new ArrayList(Arrays.asList(revs));
         Collections.shuffle(shuffled);
-        Collections.sort(shuffled, new OsgiRevisionStrategy().new ArtifactInfoComparator());
+        Collections.sort(shuffled, new OsgiLatestStrategy().new ArtifactInfoComparator());
         assertEquals(Arrays.asList(revs), shuffled);
     }
 
     public void testSort() {
-        ArtifactInfo[] revs = toMockAI(new String[] {"0.2a", "0.2_b", "0.2rc1", "0.2-final",
-                "1.0-dev1", "1.0-dev2", "1.0-alpha1", "1.0-alpha2", "1.0-beta1", "1.0-beta2",
-                "1.0-gamma", "1.0-rc1", "1.0-rc2", "1.0", "1.0.1", "2.0"});
+        ArtifactInfo[] revs = toMockAI(new String[] {"0.2.0.a", "0.2.0.b", "0.2.0.final", "1.0",
+                "1.0.0.gamma", "1.0.0.rc1", "1.0.0.rc2", "1.0.1", "2", "2.0.0.b006", "2.0.0.b012",
+                "2.0.0.xyz"});
 
         List shuffled = new ArrayList(Arrays.asList(revs));
         ArtifactInfo[] shuffledRevs = (ArtifactInfo[]) shuffled
                 .toArray(new ArtifactInfo[revs.length]);
 
-        OsgiRevisionStrategy latestRevisionStrategy = new OsgiRevisionStrategy();
+        OsgiLatestStrategy latestRevisionStrategy = new OsgiLatestStrategy();
         List sorted = latestRevisionStrategy.sort(shuffledRevs);
         assertEquals(Arrays.asList(revs), sorted);
     }
 
     public void testFindLatest() {
-        ArtifactInfo[] revs = toMockAI(new String[] {"0.2a", "0.2_b", "0.2rc1", "0.2-final",
-                "1.0-dev1", "1.0-dev2", "1.0-alpha1", "1.0-alpha2", "1.0-beta1", "1.0-beta2",
-                "1.0-gamma", "1.0-rc1", "1.0-rc2", "1.0", "1.0.1", "2.0"});
+        ArtifactInfo[] revs = toMockAI(new String[] {"0.2.0.a", "0.2.0.b", "0.2.0.rc1",
+                "0.2.0.final", "1.0.0.dev1", "1.0.0.dev2", "1.0.0.alpha1", "1.0.0.alpha2",
+                "1.0.0.beta1", "1.0.0.beta2", "1.0.0.gamma", "1.0.0.rc1", "1.0.0.rc2", "1.0",
+                "1.0.1", "2.0"});
 
         List shuffled = new ArrayList(Arrays.asList(revs));
         Collections.shuffle(shuffled);
         ArtifactInfo[] shuffledRevs = (ArtifactInfo[]) shuffled
                 .toArray(new ArtifactInfo[revs.length]);
 
-        OsgiRevisionStrategy latestRevisionStrategy = new OsgiRevisionStrategy();
+        OsgiLatestStrategy latestRevisionStrategy = new OsgiLatestStrategy();
         ArtifactInfo latest = latestRevisionStrategy.findLatest(shuffledRevs, new Date());
         assertNotNull(latest);
         assertEquals("2.0", latest.getRevision());
     }
 
-    public void testSpecialMeaningComparator() {
-        ArtifactInfo[] revs = toMockAI(new String[] {"0.1", "0.2-pre", "0.2-dev", "0.2-rc1",
-                "0.2-final", "0.2-QA", "1.0-dev1"});
-
-        List shuffled = new ArrayList(Arrays.asList(revs));
-        Collections.shuffle(shuffled);
-        OsgiRevisionStrategy latestRevisionStrategy = new OsgiRevisionStrategy();
-        OsgiRevisionStrategy.SpecialMeaning specialMeaning = new OsgiRevisionStrategy.SpecialMeaning();
-        specialMeaning.setName("pre");
-        specialMeaning.setValue(new Integer(-2));
-        latestRevisionStrategy.addConfiguredSpecialMeaning(specialMeaning);
-        specialMeaning = new OsgiRevisionStrategy.SpecialMeaning();
-        specialMeaning.setName("QA");
-        specialMeaning.setValue(new Integer(4));
-        latestRevisionStrategy.addConfiguredSpecialMeaning(specialMeaning);
-        Collections.sort(shuffled, latestRevisionStrategy.new ArtifactInfoComparator());
-        assertEquals(Arrays.asList(revs), shuffled);
-    }
-
     private static class MockArtifactInfo implements ArtifactInfo {
 
         private long _lastModified;

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java Wed Apr 11 17:06:36 2012
@@ -55,27 +55,27 @@ import org.apache.ivy.plugins.resolver.F
 
 public class OBRResolverTest extends TestCase {
 
-    private static final ModuleRevisionId MRID_TEST_BUNDLE = ModuleRevisionId.newInstance("",
-        "org.apache.ivy.osgi.testbundle", "1.2.3", BundleInfoAdapter.OSGI_BUNDLE);
+    private static final ModuleRevisionId MRID_TEST_BUNDLE = ModuleRevisionId.newInstance(
+        BundleInfo.BUNDLE_TYPE, "org.apache.ivy.osgi.testbundle", "1.2.3");
 
     private static final ModuleRevisionId MRID_TEST_BUNDLE_IMPORTING = ModuleRevisionId
-            .newInstance("", "org.apache.ivy.osgi.testbundle.importing", "3.2.1",
-                BundleInfoAdapter.OSGI_BUNDLE);
+            .newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy.osgi.testbundle.importing",
+                "3.2.1");
 
     private static final ModuleRevisionId MRID_TEST_BUNDLE_IMPORTING_VERSION = ModuleRevisionId
-            .newInstance("", "org.apache.ivy.osgi.testbundle.importing.version", "3.2.1",
-                BundleInfoAdapter.OSGI_BUNDLE);
+            .newInstance(BundleInfo.BUNDLE_TYPE,
+                "org.apache.ivy.osgi.testbundle.importing.version", "3.2.1");
 
     private static final ModuleRevisionId MRID_TEST_BUNDLE_IMPORTING_OPTIONAL = ModuleRevisionId
-            .newInstance("", "org.apache.ivy.osgi.testbundle.importing.optional", "3.2.1",
-                BundleInfoAdapter.OSGI_BUNDLE);
+            .newInstance(BundleInfo.BUNDLE_TYPE,
+                "org.apache.ivy.osgi.testbundle.importing.optional", "3.2.1");
 
-    private static final ModuleRevisionId MRID_TEST_BUNDLE_USE = ModuleRevisionId.newInstance("",
-        "org.apache.ivy.osgi.testbundle.use", "2.2.2", BundleInfoAdapter.OSGI_BUNDLE);
+    private static final ModuleRevisionId MRID_TEST_BUNDLE_USE = ModuleRevisionId.newInstance(
+        BundleInfo.BUNDLE_TYPE, "org.apache.ivy.osgi.testbundle.use", "2.2.2");
 
     private static final ModuleRevisionId MRID_TEST_BUNDLE_EXPORTING_AMBIGUITY = ModuleRevisionId
-            .newInstance("", "org.apache.ivy.osgi.testbundle.exporting.ambiguity", "3.3.3",
-                BundleInfoAdapter.OSGI_BUNDLE);
+            .newInstance(BundleInfo.BUNDLE_TYPE,
+                "org.apache.ivy.osgi.testbundle.exporting.ambiguity", "3.3.3");
 
     private IvySettings settings;
 
@@ -146,20 +146,20 @@ public class OBRResolverTest extends Tes
     }
 
     public void testSimpleResolve() throws Exception {
-        ModuleRevisionId mrid = ModuleRevisionId.newInstance("", "org.apache.ivy.osgi.testbundle",
-            "1.2.3", BundleInfoAdapter.OSGI_BUNDLE);
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy.osgi.testbundle",
+            "1.2.3");
         genericTestResolveDownload(bundleResolver, mrid);
     }
 
     public void testSimpleUrlResolve() throws Exception {
-        ModuleRevisionId mrid = ModuleRevisionId.newInstance("", "org.apache.ivy.osgi.testbundle",
-            "1.2.3", BundleInfoAdapter.OSGI_BUNDLE);
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy.osgi.testbundle",
+            "1.2.3");
         genericTestResolveDownload(bundleUrlResolver, mrid);
     }
 
     public void testResolveDual() throws Exception {
-        ModuleRevisionId mrid = ModuleRevisionId.newInstance("", "org.apache.ivy.osgi.testbundle",
-            "1.2.3", BundleInfoAdapter.OSGI_BUNDLE);
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy.osgi.testbundle",
+            "1.2.3");
         genericTestResolveDownload(dualResolver, mrid);
     }
 

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolverTest.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolverTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteResolverTest.java Wed Apr 11 17:06:36 2012
@@ -37,7 +37,7 @@ import org.apache.ivy.core.resolve.Resol
 import org.apache.ivy.core.search.ModuleEntry;
 import org.apache.ivy.core.search.OrganisationEntry;
 import org.apache.ivy.core.settings.IvySettings;
-import org.apache.ivy.osgi.core.BundleInfoAdapter;
+import org.apache.ivy.osgi.core.BundleInfo;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 
 public class UpdateSiteResolverTest extends TestCase {
@@ -82,13 +82,18 @@ public class UpdateSiteResolverTest exte
 
     public void testListOrganization() throws Exception {
         OrganisationEntry[] orgs = resolver.listOrganisations();
-        assertEquals(1, orgs.length);
-        assertEquals("", orgs[0].getOrganisation());
+        assertEquals(2, orgs.length);
+        assertTrue((orgs[0].getOrganisation().equals(BundleInfo.BUNDLE_TYPE) && orgs[1]
+                .getOrganisation().equals(BundleInfo.PACKAGE_TYPE))
+                || (orgs[0].getOrganisation().equals(BundleInfo.PACKAGE_TYPE) && orgs[1]
+                        .getOrganisation().equals(BundleInfo.BUNDLE_TYPE)));
     }
 
     public void testListModules() throws Exception {
-        ModuleEntry[] modules = resolver.listModules(new OrganisationEntry(resolver, ""));
-        assertEquals(65, modules.length);
+        ModuleEntry[] modules = resolver.listModules(new OrganisationEntry(resolver, BundleInfo.BUNDLE_TYPE));
+        assertEquals(3, modules.length);
+        modules = resolver.listModules(new OrganisationEntry(resolver, BundleInfo.PACKAGE_TYPE));
+        assertEquals(64, modules.length);
     }
 
     private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid)
@@ -124,8 +129,8 @@ public class UpdateSiteResolverTest exte
     }
 
     public void testResolve() throws Exception {
-        ModuleRevisionId mrid = ModuleRevisionId.newInstance("", "org.apache.ivy",
-            "2.0.0.final_20090108225011", BundleInfoAdapter.OSGI_BUNDLE);
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
+            "org.apache.ivy", "2.0.0.final_20090108225011");
         genericTestResolveDownload(resolver, mrid);
     }
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/util/VersionTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/util/VersionTest.java?rev=1324865&r1=1324864&r2=1324865&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/util/VersionTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/util/VersionTest.java Wed Apr 11 17:06:36 2012
@@ -17,11 +17,13 @@
  */
 package org.apache.ivy.osgi.util;
 
+import java.text.ParseException;
+
 import junit.framework.TestCase;
 
 public class VersionTest extends TestCase {
 
-    public void testParsing() {
+    public void testParsing() throws Exception {
         Version v;
 
         v = new Version("1");
@@ -41,7 +43,7 @@ public class VersionTest extends TestCas
         assertEquals("abc", v.qualifier());
     }
 
-    public void testCompareTo() {
+    public void testCompareTo() throws Exception {
         assertTrue(new Version("1.2.3").compareTo(new Version("1.2.3")) == 0);
 
         assertTrue(new Version("1.2.3").compareTo(new Version("1.2.2")) > 0);