You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/05/22 22:41:56 UTC

svn commit: r540781 - in /incubator/ivy/core/trunk: ./ src/java/org/apache/ivy/core/resolve/ test/java/org/apache/ivy/core/resolve/ test/repositories/2/mod6.2/ test/repositories/2/mod6.3/

Author: xavier
Date: Tue May 22 15:41:55 2007
New Revision: 540781

URL: http://svn.apache.org/viewvc?view=rev&rev=540781
Log:
FIX: Some circular dependencies not retrieved (IVY-400)

Added:
    incubator/ivy/core/trunk/test/repositories/2/mod6.2/ivy-1.1.xml   (with props)
    incubator/ivy/core/trunk/test/repositories/2/mod6.2/mod6.2-1.1.jar   (with props)
    incubator/ivy/core/trunk/test/repositories/2/mod6.3/ivy-1.2.xml   (with props)
Modified:
    incubator/ivy/core/trunk/CHANGES.txt
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: incubator/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=540781&r1=540780&r2=540781
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Tue May 22 15:41:55 2007
@@ -54,6 +54,7 @@
 - IMPROVEMENT: Remove @author tags (thanks to Stephane Bailliez)
 - IMPROVEMENT: Remove use of deprecated elements in ivysettings.xml (IVY-505) (with contribution from Jan Materne)
 
+- FIX: Some circular dependencies not retrieved (IVY-400)
 - FIX: ${version} property not recognized in poms (IVY-512)
 - FIX: Bug on handling dependency artifacts when a module configuration is specified (IVY-507)
 - FIX: Configure fails when having httpclient in classpath without commons-logging (IVY-502)

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java?view=diff&rev=540781&r1=540780&r2=540781
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java Tue May 22 15:41:55 2007
@@ -131,7 +131,6 @@
     
     private boolean _downloaded = false;
     private boolean _searched = false;
-    private boolean _isCircular = false;
 
     private Collection _confsToFetch = new HashSet();
     private Collection _fetchedConfigurations = new HashSet();
@@ -865,14 +864,6 @@
     public boolean isLoaded() {
         return _md != null;
     }
-
-    /**
-     * Returns true if this node can already be found among its callers
-     * @return
-     */
-    public boolean isCircular() {
-        return _isCircular;
-    }
     
     public boolean isFetched(String conf) {
         return _fetchedConfigurations.contains(conf);
@@ -992,8 +983,8 @@
 
     public void addCaller(String rootModuleConf, IvyNode callerNode, String callerConf, String[] dependencyConfs, DependencyDescriptor dd) {
     	_callers.addCaller(rootModuleConf, callerNode, callerConf, dependencyConfs, dd);
-        _isCircular = _callers.getAllCallersModuleIds().contains(getId().getModuleId());
-        if (_isCircular) {
+        boolean isCircular = _callers.getAllCallersModuleIds().contains(getId().getModuleId());
+        if (isCircular) {
         	IvyContext.getContext().getCircularDependencyStrategy().handleCircularDependency(
         			toMrids(findPath(getId().getModuleId()), this));
         }

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?view=diff&rev=540781&r1=540780&r2=540781
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java Tue May 22 15:41:55 2007
@@ -67,6 +67,17 @@
 import org.apache.ivy.util.Message;
 import org.apache.ivy.util.filter.Filter;
 
+/**
+ * The resolve engine which is the core of the dependency resolution
+ * mechanism used in Ivy.
+ * 
+ *  It features several resolve methods, some very simple, like {@link #resolve(File)} 
+ *  and {@link #resolve(URL)} which allow to simply resolve dependencies of a single
+ *  module descriptor, or more complete one, like the {@link #resolve(ModuleDescriptor, ResolveOptions)}
+ *  which allows to provide options to the resolution engine.
+ *  
+ *  @see ResolveOptions
+ */
 public class ResolveEngine {
 	private IvySettings _settings;
 	private EventManager _eventManager;
@@ -76,17 +87,34 @@
     private Set _fetchedSet = new HashSet();
 	private DependencyResolver _dictatorResolver;
 	
-	
+	/**
+	 * Constructs a ResolveEngine.
+	 * 
+	 * @param settings the settings to use to configure the engine. Must not be null.
+	 * @param eventManager the event manager to use to send events about the resolution process. Must not be null.
+	 * @param sortEngine the sort engine to use to sort modules before producing the dependency resolution report. Must not be null.
+	 */
     public ResolveEngine(IvySettings settings, EventManager eventManager, SortEngine sortEngine) {
 		_settings = settings;
 		_eventManager = eventManager;
 		_sortEngine = sortEngine;
 	}
 
+    /**
+     * Returns the currently configured dictator resolver, which when non
+     * null is used in place of any specified resolver in the {@link IvySettings}
+     * @return the currently configured dictator resolver, may be null.
+     */
 	public DependencyResolver getDictatorResolver() {
         return _dictatorResolver;
     }
 
+	/**
+	 * Sets a dictator resolver, which is used in place of regular dependency resolver 
+	 * for subsequent dependency resolution by this engine.
+	 * @param dictatorResolver the dictator resolver to use in this engine, 
+	 * 		  null if regular settings should used
+	 */
     public void setDictatorResolver(DependencyResolver dictatorResolver) {
         _dictatorResolver = dictatorResolver;
         _settings.setDictatorResolver(dictatorResolver);
@@ -366,7 +394,8 @@
         		throw new NullPointerException("null conf not allowed: confs where: "+Arrays.asList(confs));
         	}
         	
-            // for each configuration we clear the cache of what's been fetched
+        	Message.verbose("resolving dependencies for configuration '"+confs[i]+"'");
+        	// for each configuration we clear the cache of what's been fetched
             _fetchedSet.clear();     
             
             Configuration configuration = md.getConfiguration(confs[i]);
@@ -465,8 +494,10 @@
     private void fetchDependencies(VisitNode node, String conf, boolean shouldBePublic) {
     	checkInterrupted();
         long start = System.currentTimeMillis();
-        if (_settings.debugConflictResolution()) {
-            Message.debug(node.getId()+" => resolving dependencies in "+conf);
+        if (node.getParent() != null) {
+        	Message.verbose("== resolving dependencies "+node.getParent().getId()+"->"+node.getId()+" ["+node.getParentConf()+"->"+conf+"]");
+        } else {
+        	Message.verbose("== resolving dependencies for "+node.getId()+" ["+conf+"]");
         }
         resolveConflict(node);
         

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java?view=diff&rev=540781&r1=540780&r2=540781
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/VisitNode.java Tue May 22 15:41:55 2007
@@ -96,6 +96,13 @@
      * to get info on the current resolve process
      */
     private ResolveData _data;
+    /**
+     * Boolean.TRUE if a node with a same module id as the one visited 
+     * has already been visited in the current path.
+     * null if not computed yet
+     * Boolean.FALSE otherwise
+     */
+	private Boolean _isCircular;
 
     
     public VisitNode(ResolveData data, IvyNode node, VisitNode parent, String rootModuleConf, String parentConf) {
@@ -258,10 +265,12 @@
      * See getRealNode for details about what a 'real' node is.
      */
     public void useRealNode() {
-        IvyNode node = _data.getNode(_node.getId());
-        if (node != null && node != _node) {
-        	_node = node;
-        }
+    	if (_parent != null) { // use real node make sense only for non root module
+	        IvyNode node = _data.getNode(_node.getId());
+	        if (node != null && node != _node) {
+	        	_node = node;
+	        }
+    	}
     }
 
     public boolean loadData(String conf, boolean shouldBePublic) {
@@ -384,9 +393,28 @@
 		return _parent==null?null:_parent.getNode();
 	}
 
-	public boolean isCircular() {
-		return _node.isCircular();
-	}
+
+    /**
+     * Returns true if this node can already be found in the path
+     * @return
+     */
+    public boolean isCircular() {
+    	if (_isCircular == null) {
+            if (_parent != null) {
+            	_isCircular = Boolean.FALSE; // asumme it's false, and see if it isn't by checking the parent path
+                for (Iterator iter = _parent.getPath().iterator(); iter.hasNext();) {
+    				VisitNode ancestor = (VisitNode) iter.next();
+    				if (getId().getModuleId().equals(ancestor.getId().getModuleId())) {
+    					_isCircular = Boolean.TRUE;
+    					break;
+    				}
+    			}
+            } else {
+				_isCircular = Boolean.FALSE;
+            }
+    	}
+    	return _isCircular.booleanValue();
+    }
 
 	public String[] getConfsToFetch() {
 		return _node.getConfsToFetch();

Modified: incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?view=diff&rev=540781&r1=540780&r2=540781
==============================================================================
--- incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original)
+++ incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Tue May 22 15:41:55 2007
@@ -2051,6 +2051,43 @@
         }
     }
     
+    public void testCircular3() throws Exception {
+    	// test case for IVY-400
+        // mod6.3 depends on mod6.2, which itself depends on mod6.3, 
+    	// in both configuration default and test
+    	
+        ResolveReport report = _ivy.resolve(new File("test/repositories/2/mod6.3/ivy-1.2.xml").toURL(),
+                getResolveOptions(new String[] {"default","test"}));
+        assertFalse(report.hasError());
+        // we should have mod 6.2 artifact in both configurations
+        assertEquals(1, report.getConfigurationReport("default").getArtifactsNumber()); 
+        assertEquals(1, report.getConfigurationReport("test").getArtifactsNumber()); 
+        
+        _settings.setCircularDependencyStrategy(IgnoreCircularDependencyStrategy.getInstance());
+        report = _ivy.resolve(new File("test/repositories/2/mod6.3/ivy-1.2.xml").toURL(),
+                getResolveOptions(new String[] {"default","test"}));
+        assertFalse(report.hasError());
+        assertEquals(1, report.getConfigurationReport("default").getArtifactsNumber()); 
+        assertEquals(1, report.getConfigurationReport("test").getArtifactsNumber()); 
+        
+        _settings.setCircularDependencyStrategy(WarnCircularDependencyStrategy.getInstance());
+        report = _ivy.resolve(new File("test/repositories/2/mod6.3/ivy-1.2.xml").toURL(),
+        		getResolveOptions(new String[] {"default","test"}));
+        assertFalse(report.hasError());
+        assertEquals(1, report.getConfigurationReport("default").getArtifactsNumber()); 
+        assertEquals(1, report.getConfigurationReport("test").getArtifactsNumber()); 
+        
+        _settings.setCircularDependencyStrategy(ErrorCircularDependencyStrategy.getInstance());
+        try {
+	        _ivy.resolve(new File("test/repositories/2/mod6.3/ivy-1.2.xml").toURL(),
+	                getResolveOptions(new String[] {"default","test"}));
+	        fail("no exception with circular dependency strategy set to error");
+        } catch (CircularDependencyException ex)  {
+        	assertEquals("[ org6 | mod6.3 | 1.2 ]->[ org6 | mod6.2 | 1.1 ]->[ org6 | mod6.3 | 1.2 ]", ex.getMessage());
+        }
+    }
+    
+    
     public void testRegularCircular() throws Exception {
         // mod11.1 depends on mod11.2 but excludes itself
         // mod11.2 depends on mod11.1

Added: incubator/ivy/core/trunk/test/repositories/2/mod6.2/ivy-1.1.xml
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/2/mod6.2/ivy-1.1.xml?view=auto&rev=540781
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/2/mod6.2/ivy-1.1.xml (added)
+++ incubator/ivy/core/trunk/test/repositories/2/mod6.2/ivy-1.1.xml Tue May 22 15:41:55 2007
@@ -0,0 +1,33 @@
+<!--
+   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="org6"
+	       module="mod6.2"
+	       revision="1.1"
+	       status="integration"
+	       publication="20070501110000"
+	/>
+	<configurations>
+		<conf name="default"/>
+		<conf name="test"/>
+	</configurations>
+	<dependencies>
+		<dependency name="mod6.3" rev="1.2"/>
+	</dependencies>
+</ivy-module>

Propchange: incubator/ivy/core/trunk/test/repositories/2/mod6.2/ivy-1.1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/ivy/core/trunk/test/repositories/2/mod6.2/mod6.2-1.1.jar
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/2/mod6.2/mod6.2-1.1.jar?view=auto&rev=540781
==============================================================================
Binary file - no diff available.

Propchange: incubator/ivy/core/trunk/test/repositories/2/mod6.2/mod6.2-1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/ivy/core/trunk/test/repositories/2/mod6.3/ivy-1.2.xml
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/repositories/2/mod6.3/ivy-1.2.xml?view=auto&rev=540781
==============================================================================
--- incubator/ivy/core/trunk/test/repositories/2/mod6.3/ivy-1.2.xml (added)
+++ incubator/ivy/core/trunk/test/repositories/2/mod6.3/ivy-1.2.xml Tue May 22 15:41:55 2007
@@ -0,0 +1,33 @@
+<!--
+   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="org6"
+	       module="mod6.3"
+	       revision="1.2"
+	       status="integration"
+	       publication="20070502110000"
+	/>
+	<configurations>
+		<conf name="default"/>
+		<conf name="test"/>
+	</configurations>
+	<dependencies>
+		<dependency name="mod6.2" rev="1.1"/>
+	</dependencies>
+</ivy-module>

Propchange: incubator/ivy/core/trunk/test/repositories/2/mod6.3/ivy-1.2.xml
------------------------------------------------------------------------------
    svn:eol-style = native