ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r667175 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/event/ src/java/org/apache/ivy/core/event/resolve/ src/java/org/apache/ivy/core/module/descriptor/ src/java/org/apache/ivy/core/module/id/ src/java/...
Date Thu, 12 Jun 2008 17:38:14 GMT
Author: xavier
Date: Thu Jun 12 10:38:13 2008
New Revision: 667175

URL: http://svn.apache.org/viewvc?rev=667175&view=rev
Log:
review handling of qualified extra attributes, especially during copies, to avoid losing the
qualifier

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
  (with props)
Modified:
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/ResolveDependencyEvent.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractArtifact.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultArtifact.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/MRIDTransformationRule.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java Thu Jun 12 10:38:13 2008
@@ -434,7 +434,7 @@
         }
         
         public Map getQualifiedExtraAttributes() {
-            return getExtraAttributes();
+            return new HashMap();
         }
 
         public String getStandardAttribute(String attName) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java Thu Jun 12 10:38:13
2008
@@ -66,6 +66,7 @@
     protected void addMridAttributes(ModuleRevisionId mrid) {
         addModuleIdAttributes(mrid.getModuleId());
         addAttribute("revision", mrid.getRevision());
+        addAttributes(mrid.getQualifiedExtraAttributes());
         addAttributes(mrid.getExtraAttributes());
     }
 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java
Thu Jun 12 10:38:13 2008
@@ -42,6 +42,9 @@
             // now that we have loaded the dependency descriptor, we can put the extra attributes
             // contained in the descriptor too
             addAttributes(
+                this.module.getDescriptor().getResolvedModuleRevisionId()
+                                                .getQualifiedExtraAttributes());
+            addAttributes(
                 this.module.getDescriptor().getResolvedModuleRevisionId().getExtraAttributes());
             
             addAttribute("resolved", "true");

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/ResolveDependencyEvent.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/ResolveDependencyEvent.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/ResolveDependencyEvent.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/ResolveDependencyEvent.java
Thu Jun 12 10:38:13 2008
@@ -34,6 +34,7 @@
         this.dd = dd;
         addAttribute("resolver", this.resolver.getName());
         addMridAttributes(this.dd.getDependencyRevisionId());
+        addAttributes(this.dd.getQualifiedExtraAttributes());
         addAttributes(this.dd.getExtraAttributes());
         addAttribute("req-revision", requestedRevisionId.getRevision());
         addAttribute("req-revision-default", 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractArtifact.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractArtifact.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractArtifact.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/AbstractArtifact.java
Thu Jun 12 10:38:13 2008
@@ -37,7 +37,7 @@
                 && getName().equals(art.getName())
                 && getExt().equals(art.getExt())
                 && getType().equals(art.getType())
-                && getExtraAttributes().equals(art.getExtraAttributes());
+                && getQualifiedExtraAttributes().equals(art.getQualifiedExtraAttributes());
     }
 
     public int hashCode() {
@@ -50,7 +50,7 @@
         hash = hash * 17 + getName().hashCode();
         hash = hash * 17 + getExt().hashCode();
         hash = hash * 17 + getType().hashCode();
-        hash = hash * 17 + getExtraAttributes().hashCode();
+        hash = hash * 17 + getQualifiedExtraAttributes().hashCode();
         //CheckStyle:MagicNumber| ON
         return hash;
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultArtifact.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultArtifact.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultArtifact.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultArtifact.java
Thu Jun 12 10:38:13 2008
@@ -51,7 +51,7 @@
             ArtifactRevisionId.newInstance(
                 artifact.getModuleRevisionId(), 
                 artifact.getName(), newType, newExt, 
-                artifact.getExtraAttributes()), 
+                artifact.getQualifiedExtraAttributes()), 
             artifact.getPublicationDate(), 
             artifact.getUrl(), artifact.isMetadata());
     }
@@ -61,7 +61,7 @@
             ArtifactRevisionId.newInstance(
                 artifact.getModuleRevisionId(), 
                 name, artifact.getType(), artifact.getExt(), 
-                artifact.getExtraAttributes()), 
+                artifact.getQualifiedExtraAttributes()), 
             artifact.getPublicationDate(), 
             artifact.getUrl(), artifact.isMetadata());
     }
@@ -71,7 +71,7 @@
             ArtifactRevisionId.newInstance(
                 mrid, 
                 artifact.getName(), artifact.getType(), artifact.getExt(), 
-                artifact.getExtraAttributes()), 
+                artifact.getQualifiedExtraAttributes()), 
             artifact.getPublicationDate(), 
             artifact.getUrl(), artifact.isMetadata());
     }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/OverrideDependencyDescriptorMediator.java
Thu Jun 12 10:38:13 2008
@@ -73,6 +73,7 @@
         String branch = this.branch == null ? mrid.getBranch() : this.branch;
         
         return dd.clone(ModuleRevisionId.newInstance(
-            mrid.getOrganisation(), mrid.getName(), branch, version, mrid.getExtraAttributes()));
+            mrid.getOrganisation(), mrid.getName(), branch, version, 
+            mrid.getQualifiedExtraAttributes()));
     }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ArtifactRevisionId.java Thu
Jun 12 10:38:13 2008
@@ -68,7 +68,7 @@
         ArtifactRevisionId arid = (ArtifactRevisionId) obj;
         return getArtifactId().equals(arid.getArtifactId())
                 && getModuleRevisionId().equals(arid.getModuleRevisionId())
-                && getExtraAttributes().equals(arid.getExtraAttributes());
+                && getQualifiedExtraAttributes().equals(arid.getQualifiedExtraAttributes());
     }
 
     public int hashCode() {
@@ -77,7 +77,7 @@
         int hash = 17;
         hash += getArtifactId().hashCode() * 37;
         hash += getModuleRevisionId().hashCode() * 37;
-        hash += getExtraAttributes().hashCode() * 37;
+        hash += getQualifiedExtraAttributes().hashCode() * 37;
         //CheckStyle:MagicNumber| ON
         
         return hash;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java Thu Jun
12 10:38:13 2008
@@ -125,7 +125,7 @@
     public static ModuleRevisionId newInstance(ModuleRevisionId mrid, String rev) {
         return intern(
             new ModuleRevisionId(mrid.getModuleId(), 
-                mrid.getBranch(), rev, mrid.getExtraAttributes()));
+                mrid.getBranch(), rev, mrid.getQualifiedExtraAttributes()));
     }
     
     /**
@@ -230,7 +230,7 @@
         } else if (!other.getModuleId().equals(getModuleId())) {
             return false;
         } else {
-            return other.getExtraAttributes().equals(getExtraAttributes());
+            return other.getQualifiedExtraAttributes().equals(getQualifiedExtraAttributes());
         }
     }
 
@@ -241,7 +241,7 @@
             hash = hash * 13 + (getBranch() == null ? 0 : getBranch().hashCode());
             hash = hash * 13 + getRevision().hashCode();
             hash = hash * 13 + getModuleId().hashCode();
-            hash = hash * 13 + getAttributes().hashCode();
+            hash = hash * 13 + getQualifiedExtraAttributes().hashCode();
             //CheckStyle:MagicNumber| ON
         }
         return hash;

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java Thu Jun 12
10:38:13 2008
@@ -183,7 +183,7 @@
             for (int i = 0; i < extraArtifacts.length; i++) {
                 artifactsSet.add(new MDArtifact(md, extraArtifacts[i].getName(), extraArtifacts[i]
                         .getType(), extraArtifacts[i].getExt(), extraArtifacts[i].getUrl(),
-                        extraArtifacts[i].getExtraAttributes()));
+                        extraArtifacts[i].getQualifiedExtraAttributes()));
             }
         }
         boolean successfullyPublished = false;

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=667175&r1=667174&r2=667175&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 Thu Jun 12 10:38:13
2008
@@ -832,7 +832,7 @@
         for (Iterator it = dependencyArtifacts.iterator(); it.hasNext();) {
             DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
             artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(),
-                    dad.getUrl(), dad.getExtraAttributes()));
+                    dad.getUrl(), dad.getQualifiedExtraAttributes()));
         }
     }
 
@@ -843,7 +843,7 @@
             if (mergedDependencyArtifacts != null) {
                 for (Iterator it = mergedDependencyArtifacts.iterator(); it.hasNext();) {
                     DependencyArtifactDescriptor dad = (DependencyArtifactDescriptor) it.next();
-                    Map extraAttributes = new HashMap(dad.getExtraAttributes());
+                    Map extraAttributes = new HashMap(dad.getQualifiedExtraAttributes());
                     // this is later used to know that this is a merged artifact
                     extraAttributes.put("ivy:merged", 
                         dad.getDependencyDescriptor().getParentRevisionId() 

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/MRIDTransformationRule.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/MRIDTransformationRule.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/MRIDTransformationRule.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/MRIDTransformationRule.java
Thu Jun 12 10:38:13 2008
@@ -67,7 +67,8 @@
             String branch = applyRules(dest.getBranch(), "b");
             String rev = applyRules(dest.getRev(), "r");
 
-            return ModuleRevisionId.newInstance(org, mod, branch, rev, mrid.getExtraAttributes());
+            return ModuleRevisionId.newInstance(org, mod, branch, rev, 
+                                                mrid.getQualifiedExtraAttributes());
         }
 
         private String applyRules(String str, String type) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java Thu
Jun 12 10:38:13 2008
@@ -67,7 +67,7 @@
         }
         return new DefaultArtifact(mrid, artifact.getPublicationDate(), artifact.getName(),
                 artifact.getType(), artifact.getExt(), artifact.getUrl(), artifact
-                        .getExtraAttributes());
+                        .getQualifiedExtraAttributes());
     }
 
     public static ArtifactId transform(ArtifactId artifactId, NamespaceTransformer t) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java?rev=667175&r1=667174&r2=667175&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
Thu Jun 12 10:38:13 2008
@@ -424,8 +424,9 @@
         if (mrid.getOrganisation().indexOf('.') == -1) {
             return mrid;
         }
-        return ModuleRevisionId.newInstance(mrid.getOrganisation().replace('.', '/'), mrid
-                .getName(), mrid.getBranch(), mrid.getRevision(), mrid.getExtraAttributes());
+        return ModuleRevisionId.newInstance(mrid.getOrganisation().replace('.', '/'), 
+            mrid.getName(), mrid.getBranch(), mrid.getRevision(), 
+            mrid.getQualifiedExtraAttributes());
     }
 
 }

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java?rev=667175&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
(added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/namespace/NameSpaceHelperTest.java
Thu Jun 12 10:38:13 2008
@@ -0,0 +1,47 @@
+/*
+ *  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.plugins.namespace;
+
+import java.util.Collections;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DefaultArtifact;
+import org.apache.ivy.core.module.id.ArtifactRevisionId;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+
+public class NameSpaceHelperTest extends TestCase {
+    public void testTransformArtifactWithExtraAttributes() throws Exception {
+        Artifact artifact = new DefaultArtifact(
+            ArtifactRevisionId.newInstance(
+                ModuleRevisionId.parse("org.apache#test;1.0"), "test", "jar", "jar", 
+                Collections.singletonMap("m:qualifier", "sources")),
+            new Date(), null, false);
+        
+        MRIDTransformationRule r = new MRIDTransformationRule();
+        r.addSrc(new MRIDRule("org.apache", "test", null));
+        r.addDest(new MRIDRule("apache", "test", null));
+        
+        Artifact transformed = NameSpaceHelper.transform(artifact, r);
+        assertEquals("apache#test;1.0", transformed.getModuleRevisionId().toString());
+        assertEquals(Collections.singletonMap("m:qualifier", "sources"), 
+                     transformed.getQualifiedExtraAttributes());
+    }
+}

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

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



Mime
View raw message