Author: maartenc
Date: Wed Mar 28 14:38:13 2007
New Revision: 523471

URL: http://svn.apache.org/viewvc?view=rev&rev=523471
Log:
Refactoring: moved some post-resolve specific code to the IvyPostResolveTask 
class.

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java

Modified: 
incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java?view=diff&rev=523471&r1=523470&r2=523471
==============================================================================
--- 
incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java 
(original)
+++ 
incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java 
Wed Mar 28 14:38:13 2007
@@ -18,8 +18,11 @@
 package org.apache.ivy.ant;
 
 import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
 
 import org.apache.ivy.Ivy;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.core.report.ResolveReport;
@@ -143,6 +146,84 @@
         
         _artifactFilter = FilterHelper.getArtifactTypeFilter(_type);
     }
+
+    protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, 
boolean transitive, String org, String module, String conf, String resolveId, 
File cache) {
+        ensureMessageInitialised();
+        
+        String[] confs = null;
+        if (resolveId != null) {
+               confs = getConfsToResolve(resolveId, conf);
+        } else {
+               confs = getConfsToResolve(org, module, conf, false);
+        }
+        
+        if (confs.length > 0)  {
+               IvyResolve resolve = createResolve(haltOnFailure, useOrigin);
+               resolve.setCache(cache);
+               resolve.setTransitive(transitive);
+               resolve.setConf(StringUtils.join(confs, ", "));
+               resolve.setResolveId(resolveId);
+               resolve.execute();
+        } 
+    }
+    
+    protected String[] getConfsToResolve(String org, String module, String 
conf, boolean strict) {
+        ModuleDescriptor reference = (ModuleDescriptor) 
getResolvedDescriptor(org, module, strict);
+        String[] rconfs = getResolvedConfigurations(org, module, strict);
+        return getConfsToResolve(reference, conf, rconfs);
+    }
+    
+    protected String[] getConfsToResolve(String resolveId, String conf) {
+        ModuleDescriptor reference = (ModuleDescriptor) 
getResolvedDescriptor(resolveId, false);
+        if (reference == null) {
+               // assume the module has been resolved outside this build
+               // TODO: find a way to discover which confs were resolved by 
that previous resolve
+               return new String[0];
+        }
+        String[] rconfs = (String[]) 
getProject().getReference("ivy.resolved.configurations.ref." + resolveId);
+        return getConfsToResolve(reference, conf, rconfs);
+    }
+
+    private String[] getConfsToResolve(ModuleDescriptor reference, String 
conf, String[] rconfs) {
+               Message.debug("calculating configurations to resolve");
+        
+        if (reference == null)  {
+               Message.debug("module not yet resolved, all confs still need to 
be resolved");
+               if (conf == null) {
+                       return new String[] {"*"};
+               } else {
+                       return splitConfs(conf);
+               }
+        } else if (conf != null) {
+               String[] confs;
+               if ("*".equals(conf)) {
+                       confs = reference.getConfigurationsNames();
+               } else {
+                       confs = splitConfs(conf);
+               }
+               HashSet rconfsSet = new HashSet(Arrays.asList(rconfs));
+                       HashSet confsSet = new HashSet(Arrays.asList(confs));
+                       Message.debug("resolved configurations:   "+rconfsSet);
+                       Message.debug("asked configurations:      "+confsSet);
+                       confsSet.removeAll(rconfsSet);
+                       Message.debug("to resolve configurations: "+confsSet);
+                       return (String[]) confsSet.toArray(new 
String[confsSet.size()]);
+        } else {
+               Message.debug("module already resolved, no configuration to 
resolve");
+               return new String[0];
+        }
+       
+    }
+
+    protected IvyResolve createResolve(boolean haltOnFailure, boolean 
useOrigin) {
+               Message.verbose("no resolved descriptor found: launching 
default resolve");
+               IvyResolve resolve = new IvyResolve();
+               resolve.setProject(getProject());
+               resolve.setHaltonfailure(haltOnFailure);
+               resolve.setUseOrigin(useOrigin);
+               resolve.setValidate(isValidate());
+               return resolve;
+       }
 
     protected ModuleRevisionId getResolvedMrid() {
        return new ModuleRevisionId(getResolvedModuleId(), getRevision() == 
null ?Ivy.getWorkingRevision():getRevision());

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
URL: 
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java?view=diff&rev=523471&r1=523470&r2=523471
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java Wed Mar 
28 14:38:13 2007
@@ -17,13 +17,10 @@
  */
 package org.apache.ivy.ant;
 
-import java.io.File;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 
 import org.apache.ivy.Ivy;
@@ -136,77 +133,6 @@
        }
     }
     
-       protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, 
String org, String module, String resolveId, File cache) {
-       ensureResolved(haltOnFailure, useOrigin, true, org, module, null, 
resolveId, cache);
-    }
-    protected void ensureResolved(boolean haltOnFailure, boolean useOrigin, 
boolean transitive, String org, String module, String conf, String resolveId, 
File cache) {
-        ensureMessageInitialised();
-        
-        String[] confs = null;
-        if (resolveId != null) {
-               confs = getConfsToResolve(resolveId, conf);
-        } else {
-               confs = getConfsToResolve(org, module, conf, false);
-        }
-        
-        if (confs.length > 0)  {
-               IvyResolve resolve = createResolve(haltOnFailure, useOrigin);
-               resolve.setCache(cache);
-               resolve.setTransitive(transitive);
-               resolve.setConf(StringUtils.join(confs, ", "));
-               resolve.setResolveId(resolveId);
-               resolve.execute();
-        } 
-    }
-    
-    protected String[] getConfsToResolve(String org, String module, String 
conf, boolean strict) {
-        ModuleDescriptor reference = (ModuleDescriptor) 
getResolvedDescriptor(org, module, strict);
-        String[] rconfs = (String[]) 
getReference("ivy.resolved.configurations.ref", org, module, strict);
-        return getConfsToResolve(reference, conf, rconfs);
-    }
-    
-    protected String[] getConfsToResolve(String resolveId, String conf) {
-        ModuleDescriptor reference = (ModuleDescriptor) 
getResolvedDescriptor(resolveId, false);
-        if (reference == null) {
-               // assume the module has been resolved outside this build
-               // TODO: find a way to discover which confs were resolved by 
that previous resolve
-               return new String[0];
-        }
-        String[] rconfs = (String[]) 
getProject().getReference("ivy.resolved.configurations.ref." + resolveId);
-        return getConfsToResolve(reference, conf, rconfs);
-    }
-
-    private String[] getConfsToResolve(ModuleDescriptor reference, String 
conf, String[] rconfs) {
-               Message.debug("calculating configurations to resolve");
-        
-        if (reference == null)  {
-               Message.debug("module not yet resolved, all confs still need to 
be resolved");
-               if (conf == null) {
-                       return new String[] {"*"};
-               } else {
-                       return splitConfs(conf);
-               }
-        } else if (conf != null) {
-               String[] confs;
-               if ("*".equals(conf)) {
-                       confs = reference.getConfigurationsNames();
-               } else {
-                       confs = splitConfs(conf);
-               }
-               HashSet rconfsSet = new HashSet(Arrays.asList(rconfs));
-                       HashSet confsSet = new HashSet(Arrays.asList(confs));
-                       Message.debug("resolved configurations:   "+rconfsSet);
-                       Message.debug("asked configurations:      "+confsSet);
-                       confsSet.removeAll(rconfsSet);
-                       Message.debug("to resolve configurations: "+confsSet);
-                       return (String[]) confsSet.toArray(new 
String[confsSet.size()]);
-        } else {
-               Message.debug("module already resolved, no configuration to 
resolve");
-               return new String[0];
-        }
-       
-    }
-    
     protected String[] getResolvedConfigurations(String org, String module, 
boolean strict) {
                return (String[]) 
getReference("ivy.resolved.configurations.ref", org, module, strict);
        }
@@ -252,27 +178,6 @@
                return result;
        }
     
-       protected IvyResolve createResolve(boolean haltOnFailure, boolean 
useOrigin) {
-               Message.verbose("no resolved descriptor found: launching 
default resolve");
-               IvyResolve resolve = new IvyResolve();
-               resolve.setProject(getProject());
-               resolve.setHaltonfailure(haltOnFailure);
-               resolve.setUseOrigin(useOrigin);
-               if (_validate != null) {
-                   resolve.setValidate(_validate.booleanValue());
-               }
-               return resolve;
-       }
-
-    protected boolean shouldResolve(String org, String module) {
-        ensureMessageInitialised();
-        if (org != null  && module != null) {
-            return false;
-        }
-        Object reference = getResolvedDescriptor(org, module); 
-        return (reference == null);
-    }
-
     protected String[] splitConfs(String conf) {
        if (conf == null) {
                return null;


Reply via email to