ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r689060 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/report/ src/java/org/apache/ivy/core/resolve/ src/java/org/apache/ivy/core/sort/ test/java/org/apache/ivy/core/sort/
Date Tue, 26 Aug 2008 13:05:45 GMT
Author: xavier
Date: Tue Aug 26 06:05:43 2008
New Revision: 689060

URL: http://svn.apache.org/viewvc?rev=689060&view=rev
Log:
FIX: Circular Dependency messages in a resolve do not reflect the configuration used during
the resolve (IVY-708)

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortOptions.java   (with props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortEngine.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/core/sort/SortTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=689060&r1=689059&r2=689060&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Aug 26 06:05:43 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: Circular Dependency messages in a resolve do not reflect the configuration used during
the resolve (IVY-708)
 - 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)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java?rev=689060&r1=689059&r2=689060&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java Tue Aug 26 06:05:43 2008
@@ -56,8 +56,8 @@
 import org.apache.ivy.core.search.RevisionEntry;
 import org.apache.ivy.core.search.SearchEngine;
 import org.apache.ivy.core.settings.IvySettings;
-import org.apache.ivy.core.sort.NonMatchingVersionReporter;
 import org.apache.ivy.core.sort.SortEngine;
+import org.apache.ivy.core.sort.SortOptions;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.plugins.repository.TransferEvent;
 import org.apache.ivy.plugins.repository.TransferListener;
@@ -610,10 +610,10 @@
     /**
      * Sorts the collection of IvyNode from the less dependent to the more dependent
      */
-    public List sortNodes(Collection nodes) {
+    public List sortNodes(Collection nodes, SortOptions options) {
         pushContext();
         try {
-            return getSortEngine().sortNodes(nodes);
+            return getSortEngine().sortNodes(nodes, options);
         } finally {
             popContext();
         }
@@ -626,18 +626,17 @@
      * 
      * @param moduleDescriptors
      *            a Collection of ModuleDescriptor to sort
-     * @param nonMatchingVersionReporter
-     *            Used to report some non matching version (when a modules depends on a specific
-     *            revision of an other modules present in the of modules to sort with a different
-     *            revision.
+     * @param options
+     *            Options to use to sort the descriptors.
      * @return a List of sorted ModuleDescriptors
+     * @throws CircularDependencyException
+     *             if a circular dependency exists and circular dependency strategy decide
to throw
+     *             an exception
      */
-    public List sortModuleDescriptors(Collection moduleDescriptors,
-            NonMatchingVersionReporter nonMatchingVersionReporter) {
+    public List sortModuleDescriptors(Collection moduleDescriptors, SortOptions options)
{
         pushContext();
         try {
-            return getSortEngine().sortModuleDescriptors(
-                moduleDescriptors, nonMatchingVersionReporter);
+            return getSortEngine().sortModuleDescriptors(moduleDescriptors, options);
         } finally {
             popContext();
         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java?rev=689060&r1=689059&r2=689060&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java Tue Aug 26 06:05:43 2008
@@ -46,6 +46,7 @@
 import org.apache.ivy.core.search.OrganisationEntry;
 import org.apache.ivy.core.search.RevisionEntry;
 import org.apache.ivy.core.sort.SilentNonMatchingVersionReporter;
+import org.apache.ivy.core.sort.SortOptions;
 import org.apache.ivy.plugins.matcher.PatternMatcher;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 import org.apache.ivy.util.Message;
@@ -454,11 +455,14 @@
     }
 
     public List sortModuleDescriptors(Collection moduleDescriptors) {
-        return ivy.sortModuleDescriptors(moduleDescriptors, new SilentNonMatchingVersionReporter());
+        return ivy.sortModuleDescriptors(moduleDescriptors, 
+            new SortOptions()
+                .setNonMatchingVersionReporter(new SilentNonMatchingVersionReporter()));
     }
 
     public List sortNodes(Collection nodes) {
-        return ivy.sortNodes(nodes);
+        return ivy.sortNodes(nodes, new SortOptions()
+                .setNonMatchingVersionReporter(new SilentNonMatchingVersionReporter()));
     }
 
     public String substitute(String str) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java?rev=689060&r1=689059&r2=689060&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java Tue Aug 26 06:05:43 2008
@@ -36,7 +36,7 @@
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.settings.IvySettings;
-import org.apache.ivy.core.sort.WarningNonMatchingVersionReporter;
+import org.apache.ivy.core.sort.SortOptions;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
 import org.apache.ivy.util.Message;
 import org.apache.tools.ant.BuildException;
@@ -205,7 +205,8 @@
                 } else {
                     try {
                         ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance()
-                                .parseDescriptor(settings, ivyFile.toURI().toURL(), doValidate(settings));
+                                .parseDescriptor(
+                                    settings, ivyFile.toURI().toURL(), doValidate(settings));
                         buildFiles.put(md, buildFile);
                         mds.add(md);
                         Message.debug("Add " + md.getModuleRevisionId().getModuleId());
@@ -240,9 +241,7 @@
             mds = filterModulesFromLeaf(mds, leafModuleDescriptors);
         }
 
-        WarningNonMatchingVersionReporter nonMatchingVersionReporter =
-            new WarningNonMatchingVersionReporter();
-        List sortedModules = ivy.sortModuleDescriptors(mds, nonMatchingVersionReporter);
+        List sortedModules = ivy.sortModuleDescriptors(mds, SortOptions.DEFAULT);
 
         if (!OnMissingDescriptor.TAIL.equals(onMissingDescriptor)) {
             for (ListIterator iter = noDescriptor.listIterator(); iter.hasNext();) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java?rev=689060&r1=689059&r2=689060&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
Tue Aug 26 06:05:43 2008
@@ -39,6 +39,7 @@
 import org.apache.ivy.core.resolve.IvyNode;
 import org.apache.ivy.core.resolve.ResolveEngine;
 import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.core.sort.SortOptions;
 import org.apache.ivy.plugins.report.XmlReportParser;
 import org.apache.ivy.util.Message;
 
@@ -247,7 +248,8 @@
      */
     public List getModuleIds() {
         if (modulesIds == null) {
-            List sortedDependencies = resolveEngine.getSortEngine().sortNodes(getDependencies());
+            List sortedDependencies = resolveEngine.getSortEngine().sortNodes(
+                getDependencies(), SortOptions.SILENT);
             Collections.reverse(sortedDependencies);
             for (Iterator iter = sortedDependencies.iterator(); iter.hasNext();) {
                 IvyNode dependency = (IvyNode) iter.next();

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=689060&r1=689059&r2=689060&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 Tue Aug 26
06:05:43 2008
@@ -57,6 +57,7 @@
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData;
 import org.apache.ivy.core.sort.SortEngine;
+import org.apache.ivy.core.sort.SortOptions;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
 import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
@@ -530,7 +531,7 @@
                     dependencies.add(node);
                 }
             }
-            List sortedDependencies = sortEngine.sortNodes(dependencies);
+            List sortedDependencies = sortEngine.sortNodes(dependencies, SortOptions.SILENT);
             Collections.reverse(sortedDependencies);
     
             handleTransiviteEviction(md, confs, data, sortedDependencies);    

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortEngine.java?rev=689060&r1=689059&r2=689060&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortEngine.java Tue Aug 26 06:05:43
2008
@@ -26,9 +26,10 @@
 
 import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.resolve.IvyNode;
-import org.apache.ivy.plugins.circular.CircularDependencyException;
 import org.apache.ivy.plugins.circular.CircularDependencyStrategy;
+import org.apache.ivy.plugins.circular.IgnoreCircularDependencyStrategy;
 import org.apache.ivy.plugins.version.VersionMatcher;
+import org.apache.ivy.util.Checks;
 
 public class SortEngine {
 
@@ -43,7 +44,7 @@
 
     
 
-    public List sortNodes(Collection nodes) throws CircularDependencyException {
+    public List sortNodes(Collection nodes, SortOptions options) {
         /*
          * here we want to use the sort algorithm which work on module descriptors : so we
first put
          * dependencies on a map from descriptors to dependency, then we sort the keySet
(i.e. a
@@ -66,8 +67,7 @@
                 n.add(node);
             }
         }
-        List list = sortModuleDescriptors(dependenciesMap.keySet(),
-            new SilentNonMatchingVersionReporter());
+        List list = sortModuleDescriptors(dependenciesMap.keySet(), options);
         final double adjustFactor = 1.3;
         List ret = new ArrayList((int) (list.size() * adjustFactor + nulls.size()));
         // attempt to adjust the size to avoid too much list resizing
@@ -87,22 +87,19 @@
      * 
      * @param moduleDescriptors
      *            a Collection of ModuleDescriptor to sort
-     * @param nonMatchingVersionReporter
-     *            Used to report some non matching version (when a modules depends on a specific
-     *            revision of an other modules present in the of modules to sort with a different
-     *            revision.
+     * @param options
+     *            Options to use to sort the descriptors.
      * @return a List of sorted ModuleDescriptors
      * @throws CircularDependencyException
-     *             if a circular dependency exists
+     *             if a circular dependency exists and circular dependency strategy decide
to throw
+     *             an exception
      */
-    public List sortModuleDescriptors(Collection moduleDescriptors,
-            NonMatchingVersionReporter nonMatchingVersionReporter)
-            throws CircularDependencyException {
-        if (nonMatchingVersionReporter == null) {
-            throw new NullPointerException("nonMatchingVersionReporter can not be null");
-        }
+    public List sortModuleDescriptors(Collection moduleDescriptors, SortOptions options)
{
+        Checks.checkNotNull(options, "options");
         ModuleDescriptorSorter sorter = new ModuleDescriptorSorter(moduleDescriptors,
-                getVersionMatcher(), nonMatchingVersionReporter, getCircularStrategy());
+                getVersionMatcher(), options.getNonMatchingVersionReporter(), 
+                options.isUseCircularDependencyStrategy() 
+                    ? getCircularStrategy() : IgnoreCircularDependencyStrategy.getInstance());
         return sorter.sortModuleDescriptors();
     }
 

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortOptions.java?rev=689060&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortOptions.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortOptions.java Tue Aug 26 06:05:43
2008
@@ -0,0 +1,55 @@
+/*
+ *  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.core.sort;
+
+public class SortOptions {
+    public static final SortOptions DEFAULT = new SortOptions();
+    public static final SortOptions SILENT = new SortOptions()
+            .setNonMatchingVersionReporter(new SilentNonMatchingVersionReporter())
+            .setUseCircularDependencyStrategy(false);
+    
+    /**
+     * Used to report some non matching version (when a modules depends on a specific revision
of an
+     * other modules present in the of modules to sort with a different revision.
+     */
+    private NonMatchingVersionReporter nonMatchingVersionReporter 
+                                            = new WarningNonMatchingVersionReporter();
+
+    /**
+     * Should the default circular dependency strategy be used when a circular dependency
is found,
+     * or should circular dependencies be ignored?
+     */
+    private boolean useCircularDependencyStrategy = true;
+    
+    
+    public NonMatchingVersionReporter getNonMatchingVersionReporter() {
+        return nonMatchingVersionReporter;
+    }
+    public SortOptions setNonMatchingVersionReporter(
+                                NonMatchingVersionReporter nonMatchingVersionReporter) {
+        this.nonMatchingVersionReporter = nonMatchingVersionReporter;
+        return this;
+    }
+    public boolean isUseCircularDependencyStrategy() {
+        return useCircularDependencyStrategy;
+    }
+    public SortOptions setUseCircularDependencyStrategy(boolean useCircularDependencyStrategy)
{
+        this.useCircularDependencyStrategy = useCircularDependencyStrategy;
+        return this;
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortOptions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/sort/SortOptions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/sort/SortTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/sort/SortTest.java?rev=689060&r1=689059&r2=689060&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/sort/SortTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/sort/SortTest.java Tue Aug 26 06:05:43
2008
@@ -87,7 +87,7 @@
         Collection permutations = getAllLists(md1, md3, md2, md4);
         for (Iterator it = permutations.iterator(); it.hasNext();) {
             List toSort = (List) it.next();
-            assertSorted(expectedOrder, sortEngine.sortModuleDescriptors(toSort, nonMatchReporter));
+            assertSorted(expectedOrder, sortModuleDescriptors(toSort, nonMatchReporter));
         }
     }
 
@@ -109,7 +109,7 @@
         Collection permutations = getAllLists(md1, md3, md2, md4);
         for (Iterator it = permutations.iterator(); it.hasNext();) {
             List toSort = (List) it.next();
-            assertSorted(possibleOrder, sortEngine.sortModuleDescriptors(toSort, nonMatchReporter));
+            assertSorted(possibleOrder, sortModuleDescriptors(toSort, nonMatchReporter));
         }
     }
 
@@ -126,7 +126,7 @@
         Collection permutations = getAllLists(md1, md3, md2, md4);
         for (Iterator it = permutations.iterator(); it.hasNext();) {
             List toSort = (List) it.next();
-            assertSorted(possibleOrder, sortEngine.sortModuleDescriptors(toSort, nonMatchReporter));
+            assertSorted(possibleOrder, sortModuleDescriptors(toSort, nonMatchReporter));
         }
     }
 
@@ -139,7 +139,7 @@
         addDependency(md4, "md1", "rev1");
         addDependency(md4, "md2", "rev2");
         List toSort = Arrays.asList(new Object[] {md1, md2, md3, md4});
-        sortEngine.sortModuleDescriptors(toSort, nonMatchReporter);
+        sortModuleDescriptors(toSort, nonMatchReporter);
         //If it ends, it's ok.
     }
     
@@ -186,7 +186,7 @@
         settings.setCircularDependencyStrategy(circularDepReportMock);
 
         List toSort = Arrays.asList(new ModuleDescriptor[] {md4, md3, md2, md1});
-        sortEngine.sortModuleDescriptors(toSort, nonMatchReporter);
+        sortModuleDescriptors(toSort, nonMatchReporter);
 
         circularDepReportMock.validate();
     }
@@ -209,7 +209,7 @@
         Collection permutations = getAllLists(md1, md3, md2, md4);
         for (Iterator it = permutations.iterator(); it.hasNext();) {
             List toSort = (List) it.next();
-            assertSorted(expectedOrder, sortEngine.sortModuleDescriptors(toSort, nonMatchReporter));
+            assertSorted(expectedOrder, sortModuleDescriptors(toSort, nonMatchReporter));
         }
 
     }
@@ -235,7 +235,7 @@
         Collection permutations = getAllLists(md1, md3, md2, md4);
         for (Iterator it = permutations.iterator(); it.hasNext();) {
             List toSort = (List) it.next();
-            assertSorted(possibleOrder, sortEngine.sortModuleDescriptors(toSort, nonMatchReporter));
+            assertSorted(possibleOrder, sortModuleDescriptors(toSort, nonMatchReporter));
         }
 
     }
@@ -269,10 +269,16 @@
         NonMatchingVersionReporterMock nonMatchingVersionReporterMock = 
             new NonMatchingVersionReporterMock();
         List toSort = Arrays.asList(new ModuleDescriptor[] {md4, md3, md2, md1});
-        sortEngine.sortModuleDescriptors(toSort, nonMatchingVersionReporterMock);
+        sortModuleDescriptors(toSort, nonMatchingVersionReporterMock);
         nonMatchingVersionReporterMock.validate();
     }
 
+    private List sortModuleDescriptors(List toSort,
+            NonMatchingVersionReporter nonMatchingVersionReporter) {
+        return sortEngine.sortModuleDescriptors(toSort, 
+            new SortOptions().setNonMatchingVersionReporter(nonMatchingVersionReporter));
+    }
+
     private DefaultModuleDescriptor createModuleDescriptorToSort(String moduleName,
             String revision) {
         ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", moduleName, revision);



Mime
View raw message