ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gscok...@apache.org
Subject svn commit: r683552 - in /ant/ivy/core/trunk: ./ doc/use/ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/report/ src/java/org/apache/ivy/core/resolve/ test/java/org/apache/ivy/ant/
Date Thu, 07 Aug 2008 08:41:53 GMT
Author: gscokart
Date: Thu Aug  7 01:41:52 2008
New Revision: 683552

URL: http://svn.apache.org/viewvc?rev=683552&view=rev
Log:
Give the possibility to not compute ivy.deps.changed (IVY-876)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/use/resolve.html
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=683552&r1=683551&r2=683552&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Aug  7 01:41:52 2008
@@ -101,6 +101,7 @@
 - IMPROVEMENT: Change allownomd and skipbuildwithoutivy into a more semantically correct
name (IVY-297)
 - IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher
and GlobPatternMatcher
 - IMPROVEMENT: Check branch consistency during resolve (IVY-858)
+- IMPROVEMENT: Give the possibility to not compute ivy.deps.changed (IVY-876)
 
 - FIX: Incorrect parsing artifactPattern attribute in a sftp resolver (IVY-661) (thanks to
Alexey Kiselev)
 - FIX: Maven2 "ejb" packaging is not supported (IVY-873)

Modified: ant/ivy/core/trunk/doc/use/resolve.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/resolve.html?rev=683552&r1=683551&r2=683552&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/resolve.html (original)
+++ ant/ivy/core/trunk/doc/use/resolve.html Thu Aug  7 01:41:52 2008
@@ -41,6 +41,8 @@
 </ul>
 <b>Since 1.2:</b>
 An additional property is set to true if the resolved dependencies are changes since the
last resolve, and to false otherwise: <code>ivy.deps.changed</code>
+<b>Since 2.0:</b>
+The property ivy.deps.changed will not be set (and not be computed) if you set the parameter
<i>checkIfCompiled</i> to false. (by default it is true to keep backward compatibility).
 This allow to optimize your build when you have multi-module build with multiple configurations.
 
 <b>Since 2.0:</b>
 In addition, if the <i>resolveId</i> attribute has been set, the following properties
are set as well:
@@ -148,6 +150,9 @@
 <li>quiet</li> disable all usual messages, making the whole resolve process quiet
unless errors occur
 </ul></td><td>No, defaults to 'default'.</td></tr>
 
+     <tr><td>checkIfChanged</td><td>When set to true, the resolve
will compare the result with the last resolution done on this module, with those configurations</td><td>No,
default to 'true'</td></tr>
+
+
 </tbody>
 </table>
 <h1>Examples</h1>

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java?rev=683552&r1=683551&r2=683552&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java Thu Aug  7 01:41:52 2008
@@ -77,6 +77,8 @@
     private String resolveId = null;
     
     private String log = ResolveOptions.LOG_DEFAULT;
+    
+    private boolean checkIfChanged = true; //for backward compatibility
 
     public boolean isUseOrigin() {
         return useOrigin;
@@ -256,9 +258,12 @@
                     md.getResolvedModuleRevisionId().getRevision());
                 settings.setVariable(
                     "ivy.revision", md.getResolvedModuleRevisionId().getRevision());
-                boolean hasChanged = report.hasChanged();
-                getProject().setProperty("ivy.deps.changed", String.valueOf(hasChanged));
-                settings.setVariable("ivy.deps.changed", String.valueOf(hasChanged));
+                Boolean hasChanged = null;
+                if (getCheckIfChanged()) {
+                    hasChanged = Boolean.valueOf(report.hasChanged());
+                    getProject().setProperty("ivy.deps.changed", hasChanged.toString());
+                    settings.setVariable("ivy.deps.changed", hasChanged.toString());
+                }
                 if (conf.trim().equals("*")) {
                     getProject().setProperty("ivy.resolved.configurations",
                         mergeConfs(md.getConfigurationsNames()));
@@ -285,10 +290,13 @@
                         md.getResolvedModuleRevisionId().getRevision());
                     settings.setVariable("ivy.revision." + resolveId, md
                             .getResolvedModuleRevisionId().getRevision());
-                    getProject().setProperty("ivy.deps.changed." + resolveId,
-                        String.valueOf(hasChanged));
-                    settings.setVariable("ivy.deps.changed." + resolveId, String
-                            .valueOf(hasChanged));
+                    if (getCheckIfChanged()) {
+                        //hasChanged has already been set earlier
+                        getProject().setProperty("ivy.deps.changed." + resolveId,
+                            hasChanged.toString());
+                        settings.setVariable("ivy.deps.changed." + resolveId, 
+                            hasChanged.toString());
+                    }
                     if (conf.trim().equals("*")) {
                         getProject().setProperty("ivy.resolved.configurations." + resolveId,
                             mergeConfs(md.getConfigurationsNames()));
@@ -340,7 +348,8 @@
                 .setRefresh(refresh)
                 .setTransitive(transitive)
                 .setResolveMode(resolveMode)
-                .setResolveId(resolveId);
+                .setResolveId(resolveId)
+                .setCheckIfChanged(checkIfChanged);
     }
 
     public String getModule() {
@@ -406,4 +415,12 @@
     public void setResolveMode(String resolveMode) {
         this.resolveMode = resolveMode;
     }
+
+    public boolean getCheckIfChanged() {
+        return checkIfChanged;
+    }
+
+    public void setCheckIfChanged(boolean checkIfChanged) {
+        this.checkIfChanged = checkIfChanged;
+    }
 }

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=683552&r1=683551&r2=683552&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
Thu Aug  7 01:41:52 2008
@@ -47,23 +47,25 @@
  */
 public class ConfigurationResolveReport {
 
-    private ModuleDescriptor md;
+    private final ModuleDescriptor md;
 
-    private String conf;
+    private final String conf;
 
-    private Date date;
+    private final Date date;
+
+    private final ResolveOptions options;
 
     private Map dependencyReports = new LinkedHashMap();
 
     private Map dependencies = new LinkedHashMap();
 
-    private ResolveEngine resolveEngine;
+    private final ResolveEngine resolveEngine;
 
     private Map modulesIdsMap = new LinkedHashMap();
 
     private List modulesIds;
 
-    private List previousDeps;
+    private Boolean hasChanged = null;
 
     public ConfigurationResolveReport(ResolveEngine resolveEngine, ModuleDescriptor md,
             String conf, Date date, ResolveOptions options) {
@@ -71,8 +73,21 @@
         this.md = md;
         this.conf = conf;
         this.date = date;
+        this.options = options;
+    }
 
-        // parse previous deps from previous report file if any
+    
+    /**
+     * Check if the set of dependencies has changed since the previous execution 
+     * of a resolution.<br/>
+     * This function use the report file found in the cache.  So the function must be called
+     * before the new report is serialized there.</br>
+     * This function also use the internal dependencies that must already be filled.
+     * This function might be 'heavy' because it may have to parse the previous 
+     * report.
+     * @return
+     */
+    public void checkIfChanged() {
         ResolutionCacheManager cache = resolveEngine.getSettings().getResolutionCacheManager();
         String resolveId = options.getResolveId();
         File previousReportFile = cache.getConfigurationResolveReportInCache(resolveId, conf);
@@ -80,23 +95,25 @@
             try {
                 XmlReportParser parser = new XmlReportParser();
                 parser.parse(previousReportFile);
-                previousDeps = Arrays.asList(parser.getDependencyRevisionIds());
+                List previousDeps = Arrays.asList(parser.getDependencyRevisionIds());
+                HashSet previousDepSet = new HashSet(previousDeps);
+                hasChanged = Boolean.valueOf(!previousDepSet.equals(getModuleRevisionIds()));
             } catch (Exception e) {
                 Message.warn("Error while parsing configuration resolve report "
                         + previousReportFile.getAbsolutePath());
                 e.printStackTrace();
-                previousDeps = null;
+                hasChanged = Boolean.TRUE;
             }
         } else {
-            previousDeps = null;
+            hasChanged = Boolean.TRUE;
         }
     }
-
-    public boolean hasChanged() {
-        if (previousDeps == null) {
-            return true;
-        }
-        return !new HashSet(previousDeps).equals(getModuleRevisionIds());
+    
+    /**
+     * @pre checkIfChanged has been called.
+     */
+    public boolean hasChanged() {        
+        return hasChanged.booleanValue();
     }
 
     /**

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java?rev=683552&r1=683551&r2=683552&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java Thu Aug  7 01:41:52
2008
@@ -176,6 +176,16 @@
         return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
     }
 
+    
+    public void checkIfChanged() {
+        for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
+            ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
+            report.checkIfChanged();
+        }
+    }
+
+    
+    /** Can only be called if checkIfChanged has been called */
     public boolean hasChanged() {
         for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
             ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
@@ -310,4 +320,5 @@
     public String getResolveId() {
         return resolveId;
     }
+
 }

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=683552&r1=683551&r2=683552&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 Thu Aug  7
01:41:52 2008
@@ -231,6 +231,10 @@
             // resolve dependencies
             IvyNode[] dependencies = getDependencies(md, options, report);
             report.setDependencies(Arrays.asList(dependencies), options.getArtifactFilter());
+            
+            if (options.getCheckIfChanged()) {
+                report.checkIfChanged();
+            }
 
             // produce resolved ivy file and ivy properties in cache
             ResolutionCacheManager cacheManager = settings.getResolutionCacheManager();
@@ -528,8 +532,8 @@
             List sortedDependencies = sortEngine.sortNodes(dependencies);
             Collections.reverse(sortedDependencies);
     
-            handleTransiviteEviction(md, confs, data, sortedDependencies);
-    
+            handleTransiviteEviction(md, confs, data, sortedDependencies);    
+            
             return (IvyNode[]) dependencies.toArray(new IvyNode[dependencies.size()]);
         } finally {
             IvyContext.popContext();

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java?rev=683552&r1=683551&r2=683552&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java Thu Aug  7
01:41:52 2008
@@ -112,6 +112,11 @@
     private String resolveId;
 
     private boolean refresh;
+    
+    /**
+     *  True if the resolve should compare the new resolution against the previous report

+     **/  
+    private boolean checkIfChanged = false;
 
     public ResolveOptions() {
     }
@@ -130,6 +135,7 @@
         resolveMode = options.resolveMode;
         artifactFilter = options.artifactFilter;
         resolveId = options.resolveId;
+        checkIfChanged = options.checkIfChanged;
     }
 
     public Filter getArtifactFilter() {
@@ -281,6 +287,15 @@
         return refresh;
     }
 
+    public ResolveOptions setCheckIfChanged(boolean checkIfChanged) {
+        this.checkIfChanged = checkIfChanged;
+        return this;
+    }
+    
+    public boolean getCheckIfChanged() {
+        return checkIfChanged;
+    }
+
 
     public static String getDefaultResolveId(ModuleDescriptor md) {
         ModuleId module = md.getModuleRevisionId().getModuleId();
@@ -291,4 +306,6 @@
         return moduleId.getOrganisation() + "-" + moduleId.getName();
     }
 
+
+
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java?rev=683552&r1=683551&r2=683552&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResolveTest.java Thu Aug  7 01:41:52
2008
@@ -194,6 +194,18 @@
         assertEquals("false", getIvy().getVariable("ivy.deps.changed"));
     }
 
+    public void testDontCheckIfChanged() throws Exception {
+        resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
+        resolve.setCheckIfChanged(false);
+        resolve.execute();
+        assertNull(getIvy().getVariable("ivy.deps.changed"));
+        resolve.execute();
+        assertNull(getIvy().getVariable("ivy.deps.changed"));
+        //To be complete, we should also check that the XmlReportParser is not invoked
+        //but this would require a too big refactoring to inject a mock object   
+    }
+
+    
     public void testConflictingDepsChanged() throws Exception {
         resolve.setFile(new File("test/repositories/2/mod4.1/ivy-4.1.xml"));
         resolve.execute();



Mime
View raw message