incubator-ivy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r512068 - in /incubator/ivy/core/trunk: src/java/org/apache/ivy/Ivy.java src/java/org/apache/ivy/Ivy14.java src/java/org/apache/ivy/core/resolve/ResolveEngine.java test/java/org/apache/ivy/core/resolve/ResolveTest.java
Date Mon, 26 Feb 2007 23:15:06 GMT
Author: maartenc
Date: Mon Feb 26 15:15:05 2007
New Revision: 512068

URL: http://svn.apache.org/viewvc?view=rev&rev=512068
Log:
Use the cache specified in the options instead of the default cache.

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    incubator/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java?view=diff&rev=512068&r1=512067&r2=512068
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java Mon Feb 26 15:15:05 2007
@@ -318,7 +318,7 @@
     /////////////////////////////////////////////////////////////////////////
     
     public ResolvedModuleRevision findModule(ModuleRevisionId mrid) {
-    	return _resolveEngine.findModule(mrid);
+    	return _resolveEngine.findModule(mrid, CacheManager.getInstance(_settings));
     }
     
 	public ModuleEntry[] listModuleEntries(OrganisationEntry org) {

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java?view=diff&rev=512068&r1=512067&r2=512068
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java Mon Feb 26 15:15:05 2007
@@ -134,7 +134,7 @@
 	}
 
 	public ResolvedModuleRevision findModule(ModuleRevisionId id) {
-		return _ivy.getResolveEngine().findModule(id);
+		return _ivy.getResolveEngine().findModule(id, CacheManager.getInstance(_ivy.getSettings()));
 	}
 
 	public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs, File cache, Date date,
ResolveReport report, boolean validate, boolean transitive) {

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=512068&r1=512067&r2=512068
==============================================================================
--- 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 Mon Feb
26 15:15:05 2007
@@ -105,7 +105,7 @@
 		DefaultModuleDescriptor md;
 		String[] confs = options.getConfs();
 		if (confs.length == 1 && confs[0].equals("*")) {
-			ResolvedModuleRevision rmr = findModule(mrid);
+			ResolvedModuleRevision rmr = findModule(mrid, options.getCache());
 			if (rmr == null) {
 				md = DefaultModuleDescriptor.newCallerInstance(mrid, confs, options.isTransitive(), changing);
 				return new ResolveReport(md){
@@ -736,7 +736,7 @@
         return false;
     }
 
-	public ResolvedModuleRevision findModule(ModuleRevisionId id) {
+	public ResolvedModuleRevision findModule(ModuleRevisionId id, CacheManager cache) {
 		DependencyResolver r = _settings.getResolver(id.getModuleId());
 		if (r == null) {
 			throw new IllegalStateException("no resolver found for "+id.getModuleId());
@@ -749,8 +749,8 @@
 							this, 
 							new ResolveOptions()
 								.setValidate(false)
-								.setCache(CacheManager.getInstance(_settings)), 
-							new ConfigurationResolveReport(this, md, "default", null, _settings.getDefaultCache())));
+								.setCache(cache), 
+							new ConfigurationResolveReport(this, md, "default", null, cache.getCache())));
 		} catch (ParseException e) {
 			throw new RuntimeException("problem while parsing repository module descriptor for "+id+":
"+e, e);
 		}

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=512068&r1=512067&r2=512068
==============================================================================
--- 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 Mon Feb
26 15:15:05 2007
@@ -2688,6 +2688,38 @@
         assertTrue(getArchiveFileInCache("apache", "C", "3.0", "C", "jar", "jar").exists());
       
     }
 
+    public void testResolveWithSpecifiedCache() throws Exception {
+    	File cache2 = new File("build/cache2");
+    	try {
+	    	_ivy.getSettings().setDefaultCache(_cache);
+	    	
+	    	// the module to resolve
+	    	ModuleRevisionId module = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
+	    	
+	    	// use a non-default cache
+	    	ResolveOptions options = getResolveOptions(new String[] {"*"});
+	    	options.setTransitive(false);
+	    	options.setUseOrigin(true);
+	    	options.setCache(CacheManager.getInstance(_ivy.getSettings(), cache2));
+	    	ResolveReport report = _ivy.getResolveEngine().resolve(module, options, false);
+	    	
+	    	// the resolved module
+	    	ModuleRevisionId resolvedModule = report.getModuleDescriptor().getResolvedModuleRevisionId();
+	    	
+	    	// verify that the module in the default cache doesn't exist
+	    	assertEquals("Default cache is not empty", _cache.list().length, 0);
+	    	
+	    	// verify the artifact does exist in the non-default cache.
+	    	CacheManager nonDefaultManager = _ivy.getCacheManager(cache2);
+	        assertTrue(TestHelper.getArchiveFileInCache(nonDefaultManager, "org1", "mod1.1",
"1.0", "mod1.1", "jar", "jar").exists());
+	        assertTrue(nonDefaultManager.getResolvedIvyFileInCache(resolvedModule).exists());
+	        assertTrue(nonDefaultManager.getResolvedIvyPropertiesInCache(resolvedModule).exists());
+	        assertNotNull(nonDefaultManager.getSavedArtifactOrigin((Artifact) report.getArtifacts().get(0)));
+    	} finally {
+    		// delete the non-default cache
+   			cache2.delete();
+    	}
+    }
 
     ////////////////////////////////////////////////////////////
     // helper methods to ease the tests



Mime
View raw message