ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r608922 - in /ant/ivy/core/trunk: ./ doc/configuration/ src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/ src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/repository/ src/java/org/apache/ivy/core/resolve/ src...
Date Fri, 04 Jan 2008 17:05:57 GMT
Author: xavier
Date: Fri Jan  4 09:05:55 2008
New Revision: 608922

URL: http://svn.apache.org/viewvc?rev=608922&view=rev
Log:
IMPROVEMENT: use ModuleRevisionId instead of ModuleId in IvySettings#getResolver (IVY-591)

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java
      - copied, changed from r608162, ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java
Removed:
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-no-name-in-module.xml
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-no-org-in-module.xml
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/configuration/module.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngineSettings.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngineSettings.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ivy-report.xsl
    ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-test.xml

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Jan  4 09:05:55 2008
@@ -60,6 +60,7 @@
 =====================================
 - NEW: Introduce RepositoryManagementEngine (IVY-665 - not completed yet)
 
+- IMPROVEMENT: use ModuleRevisionId instead of ModuleId in IvySettings#getResolver (IVY-591)
 - IMPROVEMENT: Flexible cache management (IVY-399 - not completed yet)
 - IMPROVEMENT: Decrease memory footprint (IVY-662)
 - IMPROVEMENT: Downgrade Ant version requirement to 1.6 to build Ivy (IVY-687)

Modified: ant/ivy/core/trunk/doc/configuration/module.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/configuration/module.html?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/configuration/module.html (original)
+++ ant/ivy/core/trunk/doc/configuration/module.html Fri Jan  4 09:05:55 2008
@@ -27,7 +27,9 @@
 	<textarea id="xooki-source">
 <b>Tag:</b> module
 
-Define a module set rule. The tag defines a module set, by giving an expression and the matcher
to use for organisation and name (for instance, you can use * to specify all). 
+Define a module set rule. The tag defines a module set, by giving an expression and the matcher
to use for organisation, name, revision and any extra attribute identifying your modules.
The rule matching is performed in order, and is using a pattern matcher. Hence you can use
* to specify all, or simply avoid specifying the attribute. 
+
+The revision and extra attributes are only used for rules defining the resolver to use. For
other settings, use only organisation and module name.
 
 It also gives the specific setting to use for this module set.
 
@@ -44,10 +46,14 @@
     <tr><th class="ivy-att">Attribute</th><th class="ivy-att-desc">Description</th><th
class="ivy-att-req">Required</th></tr>
 </thead>
 <tbody>
-    <tr><td>organisation</td><td>the name of the organisation to
which apply the resolver. May be an expression depending on the matcher used (see matcher
attribute below).</td>
-        <td>Yes</td></tr>
-    <tr><td>name</td><td>the name of the module to which apply the
resolver. May be an expression depending on the matcher used (see matcher attribute below).</td>
-        <td>Yes</td></tr>
+    <tr><td>organisation</td><td>the organisation to match to apply
the rule.</td>
+        <td>No, defaults to *</td></tr>
+    <tr><td>name</td><td>the module's name to match to apply the
rule.</td>
+        <td>No, defaults to *</td></tr>
+    <tr><td>revision</td><td>the module's revision to match to apply
the rule. Note that the version may not be resolved yet (be latest.integration for instance),
so be very careful when using this attribute. <span class="since">since 2.0</span></td>
+        <td>No, defaults to *</td></tr>
+    <tr><td><em>any extra attribute</em></td><td>an extra
attribute to match to apply the rule. <span class="since">since 2.0</span></td>
+        <td>No, defaults to *</td></tr>
     <tr><td>matcher</td><td>the <a href="../concept.html#matcher">matcher</a>
to use to match the modules to which the resolver should be applied <span class="since">since
1.3</span></td>
         <td>No, defaults to exactOrRegexp</td></tr>
     <tr><td>resolver</td><td>the name of the resolver to apply. The
resolver must have been defined in the resolvers section of the configuration file.</td>
@@ -75,10 +81,10 @@
 <hr/>
 <code type="xml">
 <modules>
-  <module organisation="apache" name="commons-[a-z]+" matcher="regexp" resolver="myapachecommonsresolver"/>
+  <module organisation="apache" name="commons-[a-z]+" myextra="val.*" matcher="regexp"
resolver="myapachecommonsresolver"/>
 </modules>
 </code>
-Uses myapachecommonsresolver for all modules from apache beginning by commons- followed by
any number of alphabetic lowercase characters.
+Uses myapachecommonsresolver for all modules from 'apache' beginning by 'commons-' followed
by any number of alphabetic lowercase characters, and with the extra attribute 'myextra' having
a value starting with 'val'.
 <hr/>
 <code type="xml">
 <modules>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java Fri Jan  4 09:05:55
2008
@@ -432,7 +432,7 @@
                 // TODO cache: see how we could know which actual cache manager to use, since
this 
                 // will fail when using a resolver in a chain with a specific cache manager
                 RepositoryCacheManager cacheManager = IvyContext.getContext().getSettings()
-                        .getResolver(revId.getModuleId()).getRepositoryCacheManager(); 
+                        .getResolver(revId).getRepositoryCacheManager(); 
 
                 origin = cacheManager.getSavedArtifactOrigin(artifact);
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
Fri Jan  4 09:05:55 2008
@@ -369,8 +369,7 @@
                         if (resolver == null) {
                             Message.debug("\tresolver not found: " + resolverName
                                 + " => trying to use the one configured for " + mrid);
-                            resolver = settings.getResolver(depMD.getResolvedModuleRevisionId()
-                                .getModuleId());
+                            resolver = settings.getResolver(depMD.getResolvedModuleRevisionId());
                             if (resolver != null) {
                                 Message.debug("\tconfigured resolver found for "
                                     + depMD.getResolvedModuleRevisionId() + ": "

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java Fri Jan  4 09:05:55
2008
@@ -93,7 +93,8 @@
                     }
                 }
                 // resolve
-                DependencyResolver resolver = settings.getResolver(dds[i].getDependencyId());
+                DependencyResolver resolver = 
+                    settings.getResolver(dds[i].getDependencyRevisionId());
                 ResolvedModuleRevision rmr = resolver.getDependency(dds[i], data);
                 if (rmr == null) {
                     Message.info("dependency not found in " + ivyFile + ":\n\t" + dds[i]);

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngineSettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngineSettings.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngineSettings.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngineSettings.java Fri Jan
 4 09:05:55 2008
@@ -17,7 +17,6 @@
  */
 package org.apache.ivy.core.check;
 
-import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.plugins.parser.ParserSettings;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 
@@ -26,7 +25,5 @@
     boolean doValidate();
 
     DependencyResolver getResolver(String resolvername);
-
-    DependencyResolver getResolver(ModuleId dependencyId);
 
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/repository/RepositoryManagementEngine.java
Fri Jan  4 09:05:55 2008
@@ -283,7 +283,7 @@
     }
 
     private void loadModuleRevision(ModuleRevisionId mrid) throws Exception {
-        ResolvedModuleRevision module = settings.getResolver(mrid.getModuleId())
+        ResolvedModuleRevision module = settings.getResolver(mrid)
                     .getDependency(new DefaultDependencyDescriptor(mrid, false), 
                 newResolveData());
         if (module == null) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java Fri Jan  4 09:05:55
2008
@@ -206,7 +206,7 @@
         } else {
             markRootModuleConfLoaded(rootModuleConf);
             if (md == null) {
-                DependencyResolver resolver = data.getSettings().getResolver(getModuleId());
+                DependencyResolver resolver = data.getSettings().getResolver(getId());
                 if (resolver == null) {
                     Message.error("no resolver found for " + getModuleId()
                             + ": check your configuration");

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java Fri Jan  4
09:05:55 2008
@@ -55,6 +55,7 @@
 import org.apache.ivy.core.report.DownloadStatus;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData;
+import org.apache.ivy.core.settings.IvySettings;
 import org.apache.ivy.core.sort.SortEngine;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
@@ -367,8 +368,7 @@
      * @return a report concerning the download
      */
     public ArtifactDownloadReport download(Artifact artifact, boolean useOrigin) {
-        DependencyResolver resolver = settings.getResolver(artifact.getModuleRevisionId()
-                .getModuleId());
+        DependencyResolver resolver = settings.getResolver(artifact.getModuleRevisionId());
         DownloadReport r = resolver.download(new Artifact[] {artifact}, 
             new DownloadOptions(useOrigin));
         return r.getArtifactReport(artifact);
@@ -911,7 +911,7 @@
     }
 
     public ResolvedModuleRevision findModule(ModuleRevisionId id, ResolveOptions options)
{
-        DependencyResolver r = settings.getResolver(id.getModuleId());
+        DependencyResolver r = settings.getResolver(id);
         if (r == null) {
             throw new IllegalStateException("no resolver found for " + id.getModuleId());
         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngineSettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngineSettings.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngineSettings.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngineSettings.java Fri
Jan  4 09:05:55 2008
@@ -18,6 +18,7 @@
 package org.apache.ivy.core.resolve;
 
 import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 import org.apache.ivy.plugins.report.ReportOutputter;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
@@ -31,9 +32,7 @@
 
     ReportOutputter[] getReportOutputters();
 
-    DependencyResolver getResolver(ModuleId moduleId);
-
-    String getResolverName(ModuleId mid);
+    String getResolverName(ModuleRevisionId mid);
 
     boolean logNotConvertedExclusionRule();
 

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=608922&r1=608921&r2=608922&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 Fri Jan  4 09:05:55
2008
@@ -48,6 +48,7 @@
 import org.apache.ivy.core.deliver.DeliverEngineSettings;
 import org.apache.ivy.core.install.InstallEngineSettings;
 import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.module.status.StatusManager;
 import org.apache.ivy.core.publish.PublishEngineSettings;
 import org.apache.ivy.core.repository.RepositoryManagementEngineSettings;
@@ -73,7 +74,7 @@
 import org.apache.ivy.plugins.lock.NoLockStrategy;
 import org.apache.ivy.plugins.matcher.ExactOrRegexpPatternMatcher;
 import org.apache.ivy.plugins.matcher.ExactPatternMatcher;
-import org.apache.ivy.plugins.matcher.ModuleIdMatcher;
+import org.apache.ivy.plugins.matcher.MapMatcher;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.plugins.matcher.RegexpPatternMatcher;
 import org.apache.ivy.plugins.namespace.Namespace;
@@ -506,7 +507,7 @@
         if (!moduleSettings.isEmpty()) {
             Message.debug("\tmodule settings:");
             for (Iterator iter = moduleSettings.keySet().iterator(); iter.hasNext();) {
-                ModuleIdMatcher midm = (ModuleIdMatcher) iter.next();
+                MapMatcher midm = (MapMatcher) iter.next();
                 ModuleSettings s = (ModuleSettings) moduleSettings.get(midm);
                 Message.debug("\t\t" + midm + " -> " + s);
             }
@@ -689,18 +690,14 @@
     }
 
     /**
-     * regular expressions as explained in Pattern class may be used in ModuleId organisation
and
-     * name
-     * 
-     * @param moduleId
-     * @param resolverName
-     * @param branch
+     * regular expressions as explained in Pattern class may be used in attributes
      */
-    public void addModuleConfiguration(ModuleId mid, PatternMatcher matcher, String resolverName,
+    public void addModuleConfiguration(Map attributes, PatternMatcher matcher, String resolverName,
             String branch, String conflictManager) {
         checkResolverName(resolverName);
-        moduleSettings.put(new ModuleIdMatcher(mid, matcher), new ModuleSettings(resolverName,
-                branch, conflictManager));
+        moduleSettings.put(
+            new MapMatcher(attributes, matcher), 
+            new ModuleSettings(resolverName, branch, conflictManager));
     }
 
     public File getDefaultIvyUserDir() {
@@ -766,11 +763,11 @@
         dictatorResolver = resolver;
     }
 
-    public DependencyResolver getResolver(ModuleId moduleId) {
+    public DependencyResolver getResolver(ModuleRevisionId mrid) {
         if (dictatorResolver != null) {
             return dictatorResolver;
         }
-        String resolverName = getResolverName(moduleId);
+        String resolverName = getResolverName(mrid);
         return getResolver(resolverName);
     }
 
@@ -795,10 +792,10 @@
         return defaultResolver;
     }
 
-    public String getResolverName(ModuleId moduleId) {
+    public String getResolverName(ModuleRevisionId mrid) {
         for (Iterator iter = moduleSettings.keySet().iterator(); iter.hasNext();) {
-            ModuleIdMatcher midm = (ModuleIdMatcher) iter.next();
-            if (midm.matches(moduleId)) {
+            MapMatcher midm = (MapMatcher) iter.next();
+            if (midm.matches(mrid.getAttributes())) {
                 ModuleSettings ms = (ModuleSettings) moduleSettings.get(midm);
                 if (ms.getResolverName() != null) {
                     return ms.getResolverName();
@@ -810,8 +807,8 @@
 
     public String getDefaultBranch(ModuleId moduleId) {
         for (Iterator iter = moduleSettings.keySet().iterator(); iter.hasNext();) {
-            ModuleIdMatcher midm = (ModuleIdMatcher) iter.next();
-            if (midm.matches(moduleId)) {
+            MapMatcher midm = (MapMatcher) iter.next();
+            if (midm.matches(getAttributes(moduleId))) {
                 ModuleSettings ms = (ModuleSettings) moduleSettings.get(midm);
                 if (ms.getBranch() != null) {
                     return ms.getBranch();
@@ -831,8 +828,8 @@
 
     public ConflictManager getConflictManager(ModuleId moduleId) {
         for (Iterator iter = moduleSettings.keySet().iterator(); iter.hasNext();) {
-            ModuleIdMatcher midm = (ModuleIdMatcher) iter.next();
-            if (midm.matches(moduleId)) {
+            MapMatcher midm = (MapMatcher) iter.next();
+            if (midm.matches(getAttributes(moduleId))) {
                 ModuleSettings ms = (ModuleSettings) moduleSettings.get(midm);
                 if (ms.getConflictManager() != null) {
                     ConflictManager cm = getConflictManager(ms.getConflictManager());
@@ -846,6 +843,21 @@
             }
         }
         return getDefaultConflictManager();
+    }
+
+    /**
+     * Converts the given module id to a Map containing entries for the organisation and
module
+     * name.
+     * 
+     * @param moduleId
+     *            the module id to convert
+     * @return a Map with exactly two entries, one for the organisation, one for the module
name.
+     */
+    private Map getAttributes(ModuleId moduleId) {
+        Map att = new HashMap();
+        att.put(IvyPatternHelper.ORGANISATION_KEY, moduleId.getOrganisation());
+        att.put(IvyPatternHelper.MODULE_KEY, moduleId.getName());
+        return att;
     }
 
     public void addConfigured(ConflictManager cm) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java Fri Jan
 4 09:05:55 2008
@@ -30,8 +30,8 @@
 
 import javax.xml.parsers.SAXParserFactory;
 
+import org.apache.ivy.core.IvyPatternHelper;
 import org.apache.ivy.core.cache.RepositoryCacheManager;
-import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.status.StatusManager;
 import org.apache.ivy.plugins.circular.CircularDependencyStrategy;
 import org.apache.ivy.plugins.conflict.ConflictManager;
@@ -125,7 +125,7 @@
         // we first copy attributes in a Map to be able to modify them
         Map attributes = new HashMap();
         for (int i = 0; i < att.getLength(); i++) {
-            attributes.put(att.getQName(i), att.getValue(i));
+            attributes.put(att.getQName(i), ivy.substitute(att.getValue(i)));
         }
 
         try {
@@ -183,15 +183,15 @@
                     configurator.startCreateChild(qName);
                     for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();)
{
                         String attName = (String) iter.next();
-                        configurator.setAttribute(attName, ivy.substitute((String) attributes
-                                .get(attName)));
+                        configurator.setAttribute(attName, (String) attributes
+                                .get(attName));
                     }
                 }
             } else if ("classpath".equals(qName)) {
-                String urlStr = ivy.substitute((String) attributes.get("url"));
+                String urlStr = (String) attributes.get("url");
                 URL url = null;
                 if (urlStr == null) {
-                    String file = ivy.substitute((String) attributes.get("file"));
+                    String file = (String) attributes.get("file");
                     if (file == null) {
                         throw new IllegalArgumentException(
                                 "either url or file should be given for classpath element");
@@ -203,14 +203,14 @@
                 }
                 ivy.addClasspathURL(url);
             } else if ("typedef".equals(qName)) {
-                String name = ivy.substitute((String) attributes.get("name"));
-                String className = ivy.substitute((String) attributes.get("classname"));
+                String name = (String) attributes.get("name");
+                String className = (String) attributes.get("classname");
                 Class clazz = ivy.typeDef(name, className);
                 configurator.typeDef(name, clazz);
             } else if ("property".equals(qName)) {
-                String name = ivy.substitute((String) attributes.get("name"));
-                String value = ivy.substitute((String) attributes.get("value"));
-                String override = ivy.substitute((String) attributes.get("override"));
+                String name = (String) attributes.get("name");
+                String value = (String) attributes.get("value");
+                String override = (String) attributes.get("override");
                 if (name == null) {
                     throw new IllegalArgumentException("missing attribute name on property
tag");
                 }
@@ -220,8 +220,8 @@
                 ivy.setVariable(name, value, override == null ? true : Boolean.valueOf(override)
                         .booleanValue());
             } else if ("properties".equals(qName)) {
-                String propFilePath = ivy.substitute((String) attributes.get("file"));
-                String override = ivy.substitute((String) attributes.get("override"));
+                String propFilePath = (String) attributes.get("file");
+                String override = (String) attributes.get("override");
                 try {
                     Message.verbose("loading properties: " + propFilePath);
                     ivy.loadProperties(new File(propFilePath), override == null ? true :
Boolean
@@ -244,10 +244,10 @@
                 IvyVariableContainer variables = (IvyVariableContainer) ivy.getVariableContainer()
                         .clone();
                 try {
-                    String propFilePath = ivy.substitute((String) attributes.get("file"));
+                    String propFilePath = (String) attributes.get("file");
                     URL settingsURL = null;
                     if (propFilePath == null) {
-                        propFilePath = ivy.substitute((String) attributes.get("url"));
+                        propFilePath = (String) attributes.get("url");
                         if (propFilePath == null) {
                             Message.error("bad include tag: specify file or url to include");
                             return;
@@ -279,42 +279,42 @@
                 }
                 String cache = (String) attributes.get("defaultCache");
                 if (cache != null) {
-                    ivy.setDefaultCache(new File(ivy.substitute(cache)));
+                    ivy.setDefaultCache(new File(cache));
                 }
                 String defaultBranch = (String) attributes.get("defaultBranch");
                 if (defaultBranch != null) {
-                    ivy.setDefaultBranch(ivy.substitute(defaultBranch));
+                    ivy.setDefaultBranch(defaultBranch);
                 }
                 String validate = (String) attributes.get("validate");
                 if (validate != null) {
-                    ivy.setValidate(Boolean.valueOf(ivy.substitute(validate)).booleanValue());
+                    ivy.setValidate(Boolean.valueOf(validate).booleanValue());
                 }
                 String up2d = (String) attributes.get("checkUpToDate");
                 if (up2d != null) {
-                    ivy.setCheckUpToDate(Boolean.valueOf(ivy.substitute(up2d)).booleanValue());
+                    ivy.setCheckUpToDate(Boolean.valueOf(up2d).booleanValue());
                 }
                 String useRemoteConfig = (String) attributes.get("useRemoteConfig");
                 if (useRemoteConfig != null) {
-                    ivy.setUseRemoteConfig(Boolean.valueOf(ivy.substitute(useRemoteConfig))
+                    ivy.setUseRemoteConfig(Boolean.valueOf(useRemoteConfig)
                             .booleanValue());
                 }
                 String resolutionDir = (String) attributes.get("resolutionCacheDir");
                 if (resolutionDir != null) {
-                    ivy.setDefaultResolutionCacheBasedir(ivy.substitute(resolutionDir));
+                    ivy.setDefaultResolutionCacheBasedir(resolutionDir);
                 }
                 String cacheIvyPattern = (String) attributes.get("cacheIvyPattern");
                 if (cacheIvyPattern != null) {
                     Message.deprecated(
                         "'cacheIvyPattern' is deprecated, use 'caches[@ivyPattern]' instead"
                         + " (" + settings + ")");
-                    ivy.setDefaultCacheIvyPattern(ivy.substitute(cacheIvyPattern));
+                    ivy.setDefaultCacheIvyPattern(cacheIvyPattern);
                 }
                 String cacheArtPattern = (String) attributes.get("cacheArtifactPattern");
                 if (cacheArtPattern != null) {
                     Message.deprecated(
                         "'cacheArtifactPattern' is deprecated, "
                         + "use 'caches[@artifactPattern]' instead (" + settings + ")");
-                    ivy.setDefaultCacheArtifactPattern(ivy.substitute(cacheArtPattern));
+                    ivy.setDefaultCacheArtifactPattern(cacheArtPattern);
                 }
 
                 // we do not set following defaults here since no instances has been registered
yet
@@ -331,26 +331,26 @@
                 
                 String cacheIvyPattern = (String) attributes.get("ivyPattern");
                 if (cacheIvyPattern != null) {
-                    ivy.setDefaultCacheIvyPattern(ivy.substitute(cacheIvyPattern));
+                    ivy.setDefaultCacheIvyPattern(cacheIvyPattern);
                 }
                 String cacheArtPattern = (String) attributes.get("artifactPattern");
                 if (cacheArtPattern != null) {
-                    ivy.setDefaultCacheArtifactPattern(ivy.substitute(cacheArtPattern));
+                    ivy.setDefaultCacheArtifactPattern(cacheArtPattern);
                 }
                 String repositoryDir = (String) attributes.get("basedir");
                 if (repositoryDir != null) {
-                    ivy.setDefaultRepositoryCacheBasedir(ivy.substitute(repositoryDir));

+                    ivy.setDefaultRepositoryCacheBasedir(repositoryDir); 
                 }
            } else if ("version-matchers".equals(qName)) {
                 currentConfiguratorTag = qName;
                 configurator.setRoot(ivy);
-                if ("true".equals(ivy.substitute((String) attributes.get("usedefaults"))))
{
+                if ("true".equals((String) attributes.get("usedefaults"))) {
                     ivy.configureDefaultVersionMatcher();
                 }
             } else if ("statuses".equals(qName)) {
                 currentConfiguratorTag = qName;
                 StatusManager m = new StatusManager();
-                String defaultStatus = ivy.substitute((String) attributes.get("default"));
+                String defaultStatus = (String) attributes.get("default");
                 if (defaultStatus != null) {
                     m.setDefaultStatus(defaultStatus);
                 }
@@ -365,22 +365,13 @@
                         .get("name"));
                 macrodef.addAttribute("name", null);
             } else if ("module".equals(qName)) {
-                String organisation = ivy.substitute((String) attributes.get("organisation"));
-                String module = ivy.substitute((String) attributes.get("name"));
-                String resolver = ivy.substitute((String) attributes.get("resolver"));
-                String branch = ivy.substitute((String) attributes.get("branch"));
-                String cm = ivy.substitute((String) attributes.get("conflict-manager"));
-                String matcher = ivy.substitute((String) attributes.get("matcher"));
+                attributes.put(IvyPatternHelper.MODULE_KEY, attributes.remove("name"));
+                String resolver = (String) attributes.remove("resolver");
+                String branch = (String) attributes.remove("branch");
+                String cm = (String) attributes.remove("conflict-manager");
+                String matcher = (String) attributes.remove("matcher");
                 matcher = matcher == null ? PatternMatcher.EXACT_OR_REGEXP : matcher;
-                if (organisation == null) {
-                    throw new IllegalArgumentException(
-                         "'organisation' is mandatory in module element: check your configuration");
-                }
-                if (module == null) {
-                    throw new IllegalArgumentException(
-                            "'name' is mandatory in module element: check your configuration");
-                }
-                ivy.addModuleConfiguration(new ModuleId(organisation, module), ivy
+                ivy.addModuleConfiguration(attributes, ivy
                         .getMatcher(matcher), resolver, branch, cm);
             }
         } catch (ParseException ex) {
@@ -409,7 +400,7 @@
             ivy.setDefaultResolver(ivy.substitute(defaultResolver));
         }
         if (defaultCM != null) {
-            ConflictManager conflictManager = ivy.getConflictManager(ivy.substitute(defaultCM));
+            ConflictManager conflictManager = ivy.getConflictManager(defaultCM);
             if (conflictManager == null) {
                 throw new IllegalArgumentException("unknown conflict manager "
                         + ivy.substitute(defaultCM));

Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java (from r608162,
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java&r1=608162&r2=608922&rev=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/ModuleIdMatcher.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java Fri Jan  4
09:05:55 2008
@@ -17,32 +17,39 @@
  */
 package org.apache.ivy.plugins.matcher;
 
-import org.apache.ivy.core.module.id.ModuleId;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
 
-public class ModuleIdMatcher {
-    // TODO this class should be moved out of this package
-    private Matcher orgMatcher;
-
-    private Matcher moduleMatcher;
-
-    private ModuleId mid;
+public class MapMatcher {
+    private Map/*<String, Matcher>*/ matchers = new HashMap();
 
     private PatternMatcher pm;
 
-    public ModuleIdMatcher(ModuleId mid, PatternMatcher pm) {
-        this.mid = mid;
+    private Map attributes;
+
+    public MapMatcher(Map attributes, PatternMatcher pm) {
+        this.attributes = attributes;
         this.pm = pm;
-        this.orgMatcher = pm.getMatcher(mid.getOrganisation() == null 
-                ? PatternMatcher.ANY_EXPRESSION
-                : mid.getOrganisation());
-        this.moduleMatcher = pm.getMatcher(mid.getName());
+        for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
+            Entry entry = (Entry) iter.next();
+            matchers.put(entry.getKey(), pm.getMatcher((String) entry.getValue()));
+        }
     }
 
-    public boolean matches(ModuleId mid) {
-        return orgMatcher.matches(mid.getOrganisation()) && moduleMatcher.matches(mid.getName());
+    public boolean matches(Map/*<String,String>*/ m) {
+        for (Iterator iter = matchers.entrySet().iterator(); iter.hasNext();) {
+            Entry entry = (Entry) iter.next();
+            if (!((Matcher) entry.getValue())
+                    .matches((String) m.get(entry.getKey()))) {
+                return false;
+            }
+        }
+        return true;
     }
 
     public String toString() {
-        return mid + " (" + pm.getName() + ")";
+        return attributes + " (" + pm.getName() + ")";
     }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java Fri Jan
 4 09:05:55 2008
@@ -19,7 +19,7 @@
 
 import org.apache.ivy.core.RelativeUrlResolver;
 import org.apache.ivy.core.cache.ResolutionCacheManager;
-import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.module.status.StatusManager;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
@@ -42,6 +42,6 @@
 
     RelativeUrlResolver getRelativeUrlResolver();
     
-    DependencyResolver getResolver(ModuleId mRevId);
+    DependencyResolver getResolver(ModuleRevisionId mRevId);
 
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
Fri Jan  4 09:05:55 2008
@@ -546,7 +546,7 @@
         }
 
         private Parser parserOtherPom(ModuleRevisionId other) throws SAXException {
-            DependencyResolver resolver = settings.getResolver(other.getModuleId());
+            DependencyResolver resolver = settings.getResolver(other);
             if (resolver == null) {
                 // TODO: Maybe log warning or throw exception here?
                 return null;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java Fri Jan
 4 09:05:55 2008
@@ -84,9 +84,7 @@
             ModuleId mid = (ModuleId) iter.next();
             out.println("\t\t<module organisation=\"" 
                 + XMLHelper.escape(mid.getOrganisation()) + "\"" + " name=\""
-                    + XMLHelper.escape(mid.getName()) + "\"" + " resolver=\""
-                    + XMLHelper.escape(
-                        report.getResolveEngine().getSettings().getResolverName(mid)) + "\">");
+                    + XMLHelper.escape(mid.getName()) + "\"" + "\">");
             for (Iterator it2 = report.getNodes(mid).iterator(); it2.hasNext();) {
                 IvyNode dep = (IvyNode) it2.next();
                 ouputRevision(report, out, dependencies, dep);

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ivy-report.xsl
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ivy-report.xsl?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ivy-report.xsl (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ivy-report.xsl Fri Jan  4 09:05:55
2008
@@ -386,7 +386,6 @@
          <xsl:attribute name="name"><xsl:value-of select="@organisation"/>-<xsl:value-of
select="@name"/></xsl:attribute>
       </xsl:element>
       <xsl:value-of select="@name"/> by <xsl:value-of select="@organisation"/>
-      <span class="resolved">resolved by <b><xsl:value-of select="@resolver"/></b></span>
     </h3>    
       <xsl:for-each select="revision">
         <h4>

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/TestHelper.java Fri Jan  4 09:05:55 2008
@@ -70,7 +70,7 @@
         // WARN: this doesn't work if the resolver registered is a compound resolver (chain
or dual)
         // and a sub resolver doesn't use the same cache manager as the parent
         return (DefaultRepositoryCacheManager) 
-            ivy.getSettings().getResolver(id.getModuleId()).getRepositoryCacheManager();
+            ivy.getSettings().getResolver(id).getRepositoryCacheManager();
     }
 
     /**

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java Fri
Jan  4 09:05:55 2008
@@ -27,6 +27,7 @@
 import org.apache.ivy.core.cache.ResolutionCacheManager;
 import org.apache.ivy.core.module.descriptor.Artifact;
 import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.plugins.latest.LatestRevisionStrategy;
 import org.apache.ivy.plugins.latest.LatestStrategy;
@@ -103,36 +104,16 @@
         assertNotNull(strategy);
         assertTrue(strategy instanceof LatestTimeStrategy);
 
-        assertEquals("libraries", settings.getResolver(new ModuleId("unknown", "lib")).getName());
-        assertEquals("internal", settings.getResolver(new ModuleId("apache", "ant")).getName());
-        assertEquals("int1", settings.getResolver(new ModuleId("apache", "ivy")).getName());
-        assertEquals("int1", settings.getResolver(new ModuleId("apache", "ivyde")).getName());
-    }
-
-    public void testNoOrgInModule() throws Exception {
-        IvySettings settings = new IvySettings();
-        XmlSettingsParser parser = new XmlSettingsParser(settings);
-        try {
-            parser.parse(XmlSettingsParserTest.class
-                    .getResource("ivysettings-no-org-in-module.xml"));
-            fail("no organisation in module is supposed to raise an exception");
-        } catch (ParseException e) {
-            assertTrue("bad exception message: " + e.getMessage(), e.getMessage().indexOf(
-                "'organisation'") != -1);
-        }
-    }
-
-    public void testNoNameInModule() throws Exception {
-        IvySettings settings = new IvySettings();
-        XmlSettingsParser parser = new XmlSettingsParser(settings);
-        try {
-            parser.parse(XmlSettingsParserTest.class
-                    .getResource("ivysettings-no-name-in-module.xml"));
-            fail("no name in module is supposed to raise an exception");
-        } catch (ParseException e) {
-            assertTrue("bad exception message: " + e.getMessage(),
-                e.getMessage().indexOf("'name'") != -1);
-        }
+        assertEquals("libraries", 
+            settings.getResolver(ModuleRevisionId.newInstance("unknown", "lib", "1.0")).getName());
+        assertEquals("internal", 
+            settings.getResolver(ModuleRevisionId.newInstance("apache", "ant", "1.0")).getName());
+        assertEquals("int2", 
+            settings.getResolver(ModuleRevisionId.newInstance("apache", "ivy", "2.0")).getName());
+        assertEquals("int1", 
+            settings.getResolver(ModuleRevisionId.newInstance("apache", "ivy", "1.0")).getName());
+        assertEquals("int1", 
+            settings.getResolver(ModuleRevisionId.newInstance("apache", "ivyde", "1.0")).getName());
     }
 
     public void testTypedef() throws Exception {

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-test.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-test.xml?rev=608922&r1=608921&r2=608922&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-test.xml (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-test.xml Fri Jan
 4 09:05:55 2008
@@ -46,6 +46,7 @@
 		</filesystem>
 	</resolvers>
 	<modules>
+		<module organisation="apache" name="ivy*" revision="2*" matcher="glob" resolver="int2"/>
 		<module organisation="apache" name="ivy*" matcher="glob" resolver="int1"/>
 		<module organisation="apache" name=".*" resolver="internal"/>
 	</modules>



Mime
View raw message