ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r689034 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/core/search/ src/java/org/apache/ivy/plugins/resolver/ test/java/org/apache/ivy/ant/ test/repositories/namespace/
Date Tue, 26 Aug 2008 11:13:24 GMT
Author: xavier
Date: Tue Aug 26 04:13:23 2008
New Revision: 689034

URL: http://svn.apache.org/viewvc?rev=689034&view=rev
Log:
FIX: Failure to transitively install Maven2 artifacts with namespace (IVY-440)

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/AntTestHelper.java   (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/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java
    ant/ivy/core/trunk/test/repositories/namespace/ivysettings.xml

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=689034&r1=689033&r2=689034&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Aug 26 04:13:23 2008
@@ -108,6 +108,7 @@
 - IMPROVEMENT: Add a memory cache for the module descriptor that are parsed from the cache
(IVY-883)
 - IMPROVEMENT: Improve performance (IVY-872)
 
+- FIX: Failure to transitively install Maven2 artifacts with namespace (IVY-440)
 - FIX: Unwanted eviction of dependencies when optional attributes in dependency and info
tags are in consistent (IVY-745)
 - FIX: HTTP Handlers ignore unsuccessful response codes (IVY-864) (thanks to James P. White)
 - FIX: Deliver delivers the wrong version when a dynamic revision is evicted before being
resolved (IVY-707)

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=689034&r1=689033&r2=689034&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 Tue Aug 26 04:13:23
2008
@@ -23,6 +23,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -178,6 +179,9 @@
     /**
      * List module ids of the module accessible through the current resolvers matching the
given mid
      * criteria according to the given matcher.
+     * <p>
+     * ModuleId are returned in the system namespace.
+     * </p>
      * 
      * @param criteria
      * @param matcher
@@ -201,7 +205,8 @@
                 String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
                 String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
                 ModuleId modId = ModuleId.newInstance(org, name);
-                ret.add(modId);
+                ret.add(NameSpaceHelper.transform(
+                    modId, resolver.getNamespace().getToSystemTransformer()));
             }
         }
 
@@ -211,6 +216,9 @@
     /**
      * List module revision ids of the module accessible through the current resolvers matching
the
      * given mrid criteria according to the given matcher.
+     * <p>
+     * ModuleRevisionId are returned in the system namespace.
+     * </p>
      * 
      * @param criteria
      * @param matcher
@@ -239,13 +247,24 @@
                 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);
-                ret.add(modRevId);
+                ret.add(resolver.getNamespace().getToSystemTransformer().transform(modRevId));
             }
         }
 
         return (ModuleRevisionId[]) ret.toArray(new ModuleRevisionId[ret.size()]);
     }
 
+    /**
+     * List modules matching a given criteria, available in the given dependency resolver.
+     * <p>
+     * ModuleRevisionId are returned in the system namespace.
+     * </p>
+     *  
+     * @param resolver the resolver in which modules should looked up
+     * @param moduleCrit the criteria to match
+     * @param matcher the matcher to use to match criteria
+     * @return an array of matching module revision ids
+     */
     public ModuleRevisionId[] listModules(
             DependencyResolver resolver, ModuleRevisionId moduleCrit, PatternMatcher matcher)
{
         Map criteria = new HashMap();
@@ -260,16 +279,17 @@
                 IvyPatternHelper.BRANCH_KEY, IvyPatternHelper.REVISION_KEY};
 
         Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
-        ModuleRevisionId[] result = new ModuleRevisionId[moduleIdAsMap.length];
+        Set result = new LinkedHashSet(); // we use a Set to remove duplicates
         for (int i = 0; i < moduleIdAsMap.length; i++) {
             String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
             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[i] = ModuleRevisionId.newInstance(org, name, branch, rev);
+            result.add(resolver.getNamespace().getToSystemTransformer().transform(
+                ModuleRevisionId.newInstance(org, name, branch, rev)));
         }
         
-        return result;
+        return (ModuleRevisionId[]) result.toArray(new ModuleRevisionId[result.size()]);
     }
     
     private void addMatcher(

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java?rev=689034&r1=689033&r2=689034&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java Tue
Aug 26 04:13:23 2008
@@ -33,6 +33,7 @@
 import org.apache.ivy.core.search.ModuleEntry;
 import org.apache.ivy.core.search.OrganisationEntry;
 import org.apache.ivy.core.search.RevisionEntry;
+import org.apache.ivy.plugins.namespace.Namespace;
 import org.apache.ivy.plugins.resolver.util.ResolvedResource;
 
 /**
@@ -120,6 +121,11 @@
      * otherTokenValues map. For instance, if token = "revision" and the map contains
      * "organisation"->"foo" "module"->"bar" The results will be the list of revisions
of the module
      * bar from the org foo.
+     * <p>
+     * Note that listing does not take into account namespaces, and return raw 
+     * information without any namespace transformation. The caller is responsible for calling

+     * namespace transformation with the Namespace returned by {@link #getNamespace()}.
+     * </p>
      */
     String[] listTokenValues(String token, Map otherTokenValues);
     
@@ -131,6 +137,12 @@
 
     RevisionEntry[] listRevisions(ModuleEntry module);
     
+    /**
+     * Returns the namespace associated with this resolver.
+     * @return the namespace associated with this resolver.
+     */
+    Namespace getNamespace();
+    
     void dumpSettings();
     
     void setSettings(ResolverSettings settings);

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/AntTestHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/AntTestHelper.java?rev=689034&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/AntTestHelper.java (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/AntTestHelper.java Tue Aug 26 04:13:23
2008
@@ -0,0 +1,34 @@
+/*
+ *  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.
+ *
+ */
+package org.apache.ivy.ant;
+
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.Project;
+
+public class AntTestHelper {
+    // this is probably already available in some Ant class or helper... 
+    public static Project newProject() {
+        Project project = new Project();
+        DefaultLogger logger = new DefaultLogger();
+        logger.setMessageOutputLevel(Project.MSG_INFO);
+        logger.setOutputPrintStream(System.out);
+        logger.setErrorPrintStream(System.out);
+        project.addBuildListener(logger);
+        return project;
+    }
+}

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/AntTestHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/AntTestHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java?rev=689034&r1=689033&r2=689034&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java Tue Aug 26 04:13:23
2008
@@ -23,6 +23,7 @@
 
 import org.apache.ivy.util.FileUtil;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DefaultLogger;
 import org.apache.tools.ant.Project;
 
 public class IvyInstallTest extends TestCase {
@@ -35,7 +36,9 @@
     protected void setUp() throws Exception {
         createCache();
         cleanInstall();
-        project = new Project();
+        
+        project = AntTestHelper.newProject();
+        
         project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
 
         install = new IvyInstall();
@@ -115,6 +118,53 @@
         assertTrue(new File("build/test/install/foo/foo1/branch1/ivy-2.xml").exists());
     }
 
+    public void testInstallWithNamespace() {
+        project.setProperty("ivy.settings.file", "test/repositories/namespace/ivysettings.xml");
+        install.setOrganisation("systemorg");
+        install.setModule("systemmod2");
+        install.setRevision("1.0");
+        install.setTransitive(true);
+        install.setFrom("ns");
+        install.setTo("install");
+
+        install.execute();
+
+        assertTrue(new File("build/test/install/systemorg/systemmod2/ivy-1.0.xml").exists());
+        assertTrue(new File("build/test/install/systemorg/systemmod/ivy-1.0.xml").exists());
+    }
+
+    public void testInstallWithNamespace2() {
+        project.setProperty("ivy.settings.file", "test/repositories/namespace/ivysettings.xml");
+        install.setOrganisation("A");
+        install.setModule("B");
+        install.setRevision("1.0");
+        install.setTransitive(true);
+        install.setFrom("ns");
+        install.setTo("install");
+
+        try {
+            install.execute();
+            fail("installing module with namespace coordinates instead of system one should
fail");
+        } catch (BuildException ex) {
+            // expected
+        }
+    }
+
+    public void testInstallWithNamespace3() {
+        project.setProperty("ivy.settings.file", "test/repositories/namespace/ivysettings.xml");
+        install.setOrganisation("*");
+        install.setModule("*");
+        install.setRevision("*");
+        install.setTransitive(true);
+        install.setFrom("ns");
+        install.setTo("install");
+
+        install.execute();
+
+        assertTrue(new File("build/test/install/systemorg/systemmod2/ivy-1.0.xml").exists());
+        assertTrue(new File("build/test/install/systemorg/systemmod/ivy-1.0.xml").exists());
+    }
+
     public void testDependencyNotFoundFailure() {
         install.setOrganisation("xxx");
         install.setModule("yyy");

Modified: ant/ivy/core/trunk/test/repositories/namespace/ivysettings.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/namespace/ivysettings.xml?rev=689034&r1=689033&r2=689034&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/repositories/namespace/ivysettings.xml (original)
+++ ant/ivy/core/trunk/test/repositories/namespace/ivysettings.xml Tue Aug 26 04:13:23 2008
@@ -66,7 +66,11 @@
 		<filesystem name="ns" namespace="test" m2compatible="true">
 			<ivy pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/ivy.xml"/>
 			<ivy pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/[module]-[revision].pom"/>
-			<artifact pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/[artifact].[ext]"/>
+			<artifact pattern="${ivy.settings.dir}/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]"/>
+		</filesystem>
+		<filesystem name="install">
+			<ivy pattern="build/test/install/[organisation]/[module]/[artifact]-[revision].[ext]"/>
+			<artifact pattern="build/test/install/[organisation]/[module]/[artifact](-[classifier])-[revision].[ext]"/>
 		</filesystem>
 	</resolvers>
 </ivysettings>



Mime
View raw message