ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r689014 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/plugins/resolver/ test/java/org/apache/ivy/core/resolve/ test/repositories/extra-attributes/mymodule/task2/1749/
Date Tue, 26 Aug 2008 09:59:30 GMT
Author: xavier
Date: Tue Aug 26 02:59:29 2008
New Revision: 689014

URL: http://svn.apache.org/viewvc?rev=689014&view=rev
Log:
FIX: Unwanted eviction of dependencies when optional attributes in dependency and info tags
are in consistent (IVY-745)

Added:
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-extra-att3.xml   (with props)
    ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/
    ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/ivy.xml   (with
props)
    ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-linux.jar
  (with props)
    ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-windows.jar
  (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=689014&r1=689013&r2=689014&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Aug 26 02:59:29 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: 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)
 - FIX: Inconsistency with "multi-project" tutorial (IVY-667)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?rev=689014&r1=689013&r2=689014&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java Tue Aug
26 02:59:29 2008
@@ -33,6 +33,7 @@
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.IvyPatternHelper;
@@ -273,9 +274,10 @@
                         checkDescriptorConsistency(nsMrid, nsMd, ivyRef);
                     } else {
                         if (systemMd instanceof DefaultModuleDescriptor) {
-                            String revision = getRevision(ivyRef, systemMrid, systemMd);
-                            ((DefaultModuleDescriptor) systemMd).setModuleRevisionId(
-                                ModuleRevisionId.newInstance(systemMrid, revision));
+                            DefaultModuleDescriptor defaultMd = (DefaultModuleDescriptor)
systemMd;
+                            ModuleRevisionId revision = getRevision(ivyRef, systemMrid, systemMd);
+                            defaultMd.setModuleRevisionId(revision);
+                            defaultMd.setResolvedModuleRevisionId(revision);
                         } else {
                             Message.warn(
                               "consistency disabled with instance of non DefaultModuleDescriptor..."
@@ -466,24 +468,25 @@
         checkModuleDescriptorRevision(systemMd, dependencyConstraint);
     }
 
-    private String getRevision(ResolvedResource ivyRef, ModuleRevisionId askedMrid,
+    private ModuleRevisionId getRevision(ResolvedResource ivyRef, ModuleRevisionId askedMrid,
             ModuleDescriptor md) throws ParseException {
         String revision = ivyRef.getRevision();
         if (revision == null) {
             Message.debug("no revision found in reference for " + askedMrid);
             if (getSettings().getVersionMatcher().isDynamic(askedMrid)) {
                 if (md.getModuleRevisionId().getRevision() == null) {
-                    return "working@" + getName();
+                    return ModuleRevisionId.newInstance(askedMrid, "working@" + getName());
                 } else {
                     Message.debug("using  " + askedMrid);
-                    revision = md.getModuleRevisionId().getRevision();
+                    return askedMrid;
                 }
             } else {
                 Message.debug("using  " + askedMrid);
-                revision = askedMrid.getRevision();
+                return askedMrid;
             }
+        } else {
+            return ModuleRevisionId.newInstance(askedMrid, revision);
         }
-        return revision;
     }
 
     public ResolvedModuleRevision parse(final ResolvedResource mdRef, DependencyDescriptor
dd,
@@ -596,7 +599,7 @@
             Message.error("\t" + getName() + ": bad branch name found in " + ivyRef.getResource()
                     + ": expected='" + mrid.getBranch() + " found='"
                     + md.getModuleRevisionId().getBranch() + "'");
-            errors.append("bad module name: expected='" + mrid.getBranch() + "' found='"
+            errors.append("bad branch name: expected='" + mrid.getBranch() + "' found='"
                     + md.getModuleRevisionId().getBranch() + "'; ");
             ok = false;
         }
@@ -618,6 +621,18 @@
             errors.append("bad status: '" + md.getStatus() + "'; ");
             ok = false;
         }
+        for (Iterator it = mrid.getExtraAttributes().entrySet().iterator(); it.hasNext();)
{
+            Entry extra = (Entry) it.next();
+            if (extra.getValue() != null && !extra.getValue().equals(
+                                                md.getExtraAttribute((String) extra.getKey())))
{
+                String errorMsg = "bad " + extra.getKey() + " found in " + ivyRef.getResource()
+                                        + ": expected='" + extra.getValue() + "' found='"
+                                        + md.getExtraAttribute((String) extra.getKey()) +
"'";
+                Message.error("\t" + getName() + ": " + errorMsg);
+                errors.append(errorMsg + ";");
+                ok = false;
+            }
+        }
         if (!ok) {
             throw new ParseException("inconsistent module descriptor file found in '"
                     + ivyRef.getResource() + "': " + errors, 0);

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=689014&r1=689013&r2=689014&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Tue Aug 26 02:59:29
2008
@@ -59,6 +59,7 @@
 import org.apache.ivy.plugins.resolver.FileSystemResolver;
 import org.apache.ivy.util.CacheCleaner;
 import org.apache.ivy.util.FileUtil;
+import org.apache.ivy.util.MockMessageLogger;
 import org.apache.ivy.util.StringUtils;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
@@ -4137,6 +4138,42 @@
         assertTrue(new File(cache, "apache/module2/task2/1976/module2-linux.jar").exists());
     }
 
+    public void testExtraAttributes3() throws Exception {
+        // test case for IVY-745
+        MockMessageLogger mockLogger = new MockMessageLogger();
+        Ivy ivy = new Ivy();
+        ivy.getLoggerEngine().setDefaultLogger(mockLogger);
+        ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
+        ivy.getSettings().setDefaultCache(cache);
+        ivy.getSettings().validate();
+
+        ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att3.xml"),
+            getResolveOptions(ivy.getSettings(), new String[] {"*"}).setValidate(false));
+        
+        assertTrue(report.hasError());
+        // should report error about missing extra attribute in dependency module descriptor
+        mockLogger.assertLogContains("expected='task2' found='null'");
+    }
+
+    public void testExtraAttributes4() throws Exception {
+        // second test case for IVY-745: now we disable consistency checking, everything
should work fine
+        Ivy ivy = new Ivy();
+        ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
+        ivy.getSettings().setDefaultCache(cache);
+        ((FileSystemResolver) ivy.getSettings().getResolver("default")).setCheckconsistency(false);
+        ivy.getSettings().validate();
+
+        ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att3.xml"),
+            getResolveOptions(ivy.getSettings(), new String[] {"*"}).setValidate(false));
+        
+        assertFalse(report.hasError());
+
+        assertTrue(new File(cache, "apache/mymodule/task2/1749/ivy.xml").exists());
+        assertTrue(new File(cache, "apache/mymodule/task2/1749/ivy.xml.original").exists());
+        assertTrue(new File(cache, "apache/mymodule/task2/1749/mymodule-windows.jar").exists());
+        assertTrue(new File(cache, "apache/mymodule/task2/1749/mymodule-linux.jar").exists());
+    }
+
     public void testNamespaceExtraAttributes() throws Exception {
         Ivy ivy = new Ivy();
         ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-extra-att3.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-extra-att3.xml?rev=689014&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-extra-att3.xml (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-extra-att3.xml Tue Aug 26
02:59:29 2008
@@ -0,0 +1,24 @@
+<!--
+   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.0">
+    <info organisation="apache" module="extra-att" revision="1.0"/>
+    <dependencies>
+		<dependency name="mymodule" eatt="task2" rev="1749" />
+    </dependencies>
+</ivy-module>

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-extra-att3.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ivy-extra-att3.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/ivy.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/ivy.xml?rev=689014&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/ivy.xml (added)
+++ ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/ivy.xml Tue
Aug 26 02:59:29 2008
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+   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.0">
+    <info 
+        organisation="apache"
+        module="mymodule"
+        revision="1749"
+        status="integration">
+	</info>
+	<publications>
+		<artifact name="mymodule" platform="windows" type="jar"/>
+		<artifact name="mymodule" platform="linux" type="jar"/>
+	</publications>
+</ivy-module>

Propchange: ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/ivy.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/ivy.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-linux.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-linux.jar?rev=689014&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-linux.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-windows.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-windows.jar?rev=689014&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ant/ivy/core/trunk/test/repositories/extra-attributes/mymodule/task2/1749/mymodule-windows.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message