ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r820829 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/core/search/ test/java/org/apache/ivy/core/search/ test/repositories/IVY-1128/ test/repositories/IVY-1128/test/ test/repositories/IVY-1128/test/a/ test/repositories/IVY-1128/test/...
Date Thu, 01 Oct 2009 22:44:26 GMT
Author: maartenc
Date: Thu Oct  1 22:44:26 2009
New Revision: 820829

URL: http://svn.apache.org/viewvc?rev=820829&view=rev
Log:
FIX: SearchEngine.listModules returns MRID without extra attributes (IVY-1128) (thanks to
Michael Scheetz)

Added:
    ant/ivy/core/trunk/test/repositories/IVY-1128/
    ant/ivy/core/trunk/test/repositories/IVY-1128/ivysettings.xml   (with props)
    ant/ivy/core/trunk/test/repositories/IVY-1128/test/
    ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/
    ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/
    ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/
    ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-1.xml   (with
props)
    ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-2.xml   (with
props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/search/SearchTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=820829&r1=820828&r2=820829&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Oct  1 22:44:26 2009
@@ -94,6 +94,7 @@
 	
    trunk
 =====================================
+- FIX: SearchEngine.listModules returns MRID without extra attributes (IVY-1128) (thanks
to Michael Scheetz)
 - FIX: IvyBuildNumber non-deterministic behaviour (IVY-1120)
 - FIX: Change spelling of 'occured' to 'occurred' (IVY-1123)
 - FIX: Ivy deliver fails to replace dynamic revision when using extra attributes (IVY-1111)
(thanks to Michael Scheetz)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java?rev=820829&r1=820828&r2=820829&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java Thu Oct  1 22:44:26
2009
@@ -233,10 +233,9 @@
         addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);
         addMatcher(matcher, moduleCrit.getBranch(), criteria, IvyPatternHelper.BRANCH_KEY);
         addMatcher(matcher, moduleCrit.getRevision(), criteria, IvyPatternHelper.REVISION_KEY);
-        
-        String[] tokensToList = new String[] {
-                IvyPatternHelper.ORGANISATION_KEY, IvyPatternHelper.MODULE_KEY, 
-                IvyPatternHelper.BRANCH_KEY, IvyPatternHelper.REVISION_KEY};
+
+        String[] tokensToList = (String[]) moduleCrit.getAttributes().keySet().toArray(
+                    new String[moduleCrit.getAttributes().size()]);
 
         for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
             DependencyResolver resolver = (DependencyResolver) iter.next();
@@ -246,7 +245,24 @@
                 String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
                 String branch = (String) moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
                 String rev = (String) moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
-                ModuleRevisionId modRevId = ModuleRevisionId.newInstance(org, name, branch,
rev);
+                
+                Map foundExtraAtts = new HashMap();
+                for (Iterator iter2 = moduleCrit.getQualifiedExtraAttributes().keySet().iterator();
iter2.hasNext(); ) {
+                    String qualifiedKey = (String) iter2.next();
+                    String value = null;
+                    int colonIndex = qualifiedKey.indexOf(':');
+                    if (colonIndex == -1) {
+                        value = (String) moduleIdAsMap[i].get(qualifiedKey);
+                    } else {
+                        value = (String) moduleIdAsMap[i].get(qualifiedKey.substring(colonIndex
+ 1));
+                    }
+
+                    if (value != null) {
+                        foundExtraAtts.put(qualifiedKey, value);
+                    }
+                }
+                
+                ModuleRevisionId modRevId = ModuleRevisionId.newInstance(org, name, branch,
rev, foundExtraAtts);
                 ret.add(resolver.getNamespace().getToSystemTransformer().transform(modRevId));
             }
         }
@@ -274,9 +290,8 @@
         addMatcher(matcher, moduleCrit.getBranch(), criteria, IvyPatternHelper.BRANCH_KEY);
         addMatcher(matcher, moduleCrit.getRevision(), criteria, IvyPatternHelper.REVISION_KEY);
         
-        String[] tokensToList = new String[] {
-                IvyPatternHelper.ORGANISATION_KEY, IvyPatternHelper.MODULE_KEY, 
-                IvyPatternHelper.BRANCH_KEY, IvyPatternHelper.REVISION_KEY};
+        String[] tokensToList = (String[]) moduleCrit.getAttributes().keySet().toArray(
+            new String[moduleCrit.getAttributes().size()]);
 
         Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
         Set result = new LinkedHashSet(); // we use a Set to remove duplicates
@@ -285,8 +300,25 @@
             String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
             String branch = (String) moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
             String rev = (String) moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
-            result.add(resolver.getNamespace().getToSystemTransformer().transform(
-                ModuleRevisionId.newInstance(org, name, branch, rev)));
+            
+            Map foundExtraAtts = new HashMap();
+            for (Iterator iter2 = moduleCrit.getQualifiedExtraAttributes().keySet().iterator();
iter2.hasNext(); ) {
+                String qualifiedKey = (String) iter2.next();
+                String value = null;
+                int colonIndex = qualifiedKey.indexOf(':');
+                if (colonIndex == -1) {
+                    value = (String) moduleIdAsMap[i].get(qualifiedKey);
+                } else {
+                    value = (String) moduleIdAsMap[i].get(qualifiedKey.substring(colonIndex
+ 1));
+                }
+
+                if (value != null) {
+                    foundExtraAtts.put(qualifiedKey, value);
+                }
+            }
+            
+            ModuleRevisionId modRevId = ModuleRevisionId.newInstance(org, name, branch, rev,
foundExtraAtts);
+            result.add(resolver.getNamespace().getToSystemTransformer().transform(modRevId));
         }
         
         return (ModuleRevisionId[]) result.toArray(new ModuleRevisionId[result.size()]);

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/search/SearchTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/search/SearchTest.java?rev=820829&r1=820828&r2=820829&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/search/SearchTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/search/SearchTest.java Thu Oct  1 22:44:26
2009
@@ -18,6 +18,8 @@
 package org.apache.ivy.core.search;
 
 import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -27,6 +29,9 @@
 
 import org.apache.ivy.Ivy;
 import org.apache.ivy.core.IvyPatternHelper;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.plugins.resolver.IBiblioResolver;
 
 public class SearchTest extends TestCase {
@@ -58,4 +63,31 @@
             new HashSet(Arrays.asList(new String[] {"1.0","1.1","1.2"})), 
             new HashSet(Arrays.asList(revs)));
     }
+
+    public void testListModulesWithExtraAttributes() throws ParseException, IOException {
+        Ivy ivy = Ivy.newInstance();
+        ivy.configure(new File("test/repositories/IVY-1128/ivysettings.xml"));
+        IvySettings settings = ivy.getSettings();
+
+        Map extendedAttributes = new HashMap();
+        extendedAttributes.put("e:att1","extraatt");
+        extendedAttributes.put("e:att2","extraatt2");
+        ModuleRevisionId criteria = ModuleRevisionId.newInstance("test", "a", "*", extendedAttributes);
+
+        ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(PatternMatcher.REGEXP));
+
+        assertEquals(2, mrids.length);
+        ModuleRevisionId mrid = mrids[0];
+        assertEquals("extraatt", mrid.getExtraAttribute("att1"));
+
+        Map extraAttributes = mrid.getExtraAttributes();
+        assertEquals(2, extraAttributes.size());
+        assertTrue(extraAttributes.toString(), extraAttributes.keySet().contains("att1"));
+        assertTrue(extraAttributes.toString(), extraAttributes.keySet().contains("att2"));
+
+        Map qualifiedExtraAttributes = mrid.getQualifiedExtraAttributes();
+        assertEquals(2, qualifiedExtraAttributes.size());
+        assertTrue(qualifiedExtraAttributes.toString(), qualifiedExtraAttributes.keySet().contains("e:att1"));
+        assertTrue(qualifiedExtraAttributes.toString(), qualifiedExtraAttributes.keySet().contains("e:att2"));
+    }
 }

Added: ant/ivy/core/trunk/test/repositories/IVY-1128/ivysettings.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1128/ivysettings.xml?rev=820829&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1128/ivysettings.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1128/ivysettings.xml Thu Oct  1 22:44:26 2009
@@ -0,0 +1,27 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+-->
+<ivysettings>
+   <settings defaultResolver="local" />
+   <resolvers>
+        <filesystem name="local" >
+            <ivy pattern="${ivy.settings.dir}/[organisation]/[module]/[att1]/[att2]/ivy-[revision].xml"/>
+            <artifact pattern="${ivy.settings.dir}/[organisation]/[module]/[att1]/[att2]/[artifact]-[revision].[ext]"/>
+        </filesystem>
+    </resolvers>
+</ivysettings>

Propchange: ant/ivy/core/trunk/test/repositories/IVY-1128/ivysettings.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-1.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-1.xml?rev=820829&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-1.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-1.xml Thu
Oct  1 22:44:26 2009
@@ -0,0 +1,22 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.4" xmlns:e="http://ant.apache.org/ivy/extra">
+   <info organisation="test" module="a" revision="1" status="integration" publication="20090108103716"
e:att1="extraatt" e:att2="extraatt2"/>
+   <publications/>
+</ivy-module>

Propchange: ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-2.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-2.xml?rev=820829&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-2.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-2.xml Thu
Oct  1 22:44:26 2009
@@ -0,0 +1,22 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivy-module version="1.4" xmlns:e="http://ant.apache.org/ivy/extra">
+   <info organisation="test" module="a" revision="2" status="integration" publication="20090108103716"
e:att1="extraatt" e:att2="extraatt2"/>
+   <publications/>
+</ivy-module>

Propchange: ant/ivy/core/trunk/test/repositories/IVY-1128/test/a/extraatt/extraatt2/ivy-2.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message