You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Gilles Scokart <gs...@gmail.com> on 2008/08/14 10:46:55 UTC

Re: 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/

I remember a discussion about lower case / mixed case attributes of
the ivy ant task but I don't remind me the conclusion and I didn't
find it back.

For the next change (adding an option to tell to not compute
ivy.deps.changed) I have added an task attribute 'checkIfChanged'
mixed case.  Should I change that?

I also noticed that there is an other new attribute 'resolveMode' that
use mixed case.

Gilles

PS : It is not related, but my reply to on a notifiaction didn't point
to dev@ant.apache.org.  But it seems the header is set correctly.  Is
it my mail reader that is broken?  I'm using gmail on line.


2008/8/7  <gs...@apache.org>:
> 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();
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: 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/

Posted by Jeffrey E Care <ca...@us.ibm.com>.
"Gilles Scokart" <gs...@gmail.com> wrote on 08/14/2008 04:46:55 AM:

> I remember a discussion about lower case / mixed case attributes of
> the ivy ant task but I don't remind me the conclusion and I didn't
> find it back.

I don't think the parser cares, right? I've seen plenty of build.xml files 
where the same attribute of the same task was capitalized 10 different 
ways & they all work fine.

Unless you're asking about code style or something...

Re: 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/

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 14 Aug 2008, Gilles Scokart <gs...@gmail.com> wrote:

> I remember a discussion about lower case / mixed case attributes of
> the ivy ant task but I don't remind me the conclusion and I didn't
> find it back.

Ant doesn't care, it is not case sensitive on attributes.

> PS : It is not related, but my reply to on a notifiaction didn't
> point to dev@ant.apache.org.  But it seems the header is set
> correctly.

Yes, looks correct.

> Is it my mail reader that is broken?

Seems to be the case, maybe it has List-Post take precedence over
Reply-To.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: 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/

Posted by Xavier Hanin <xa...@gmail.com>.
On Thu, Aug 14, 2008 at 10:46 AM, Gilles Scokart <gs...@gmail.com> wrote:

> I remember a discussion about lower case / mixed case attributes of
> the ivy ant task but I don't remind me the conclusion and I didn't
> find it back.
>
> For the next change (adding an option to tell to not compute
> ivy.deps.changed) I have added an task attribute 'checkIfChanged'
> mixed case.  Should I change that?

As Stefan says, Ant doesn't care. But for Ivy settings parsing, our parser
is case sensitive, maybe we should make it case insensitive to make it
closer to Ant parser. WDYT?

Xavier

>
>
> I also noticed that there is an other new attribute 'resolveMode' that
> use mixed case.
>
> Gilles
>
> PS : It is not related, but my reply to on a notifiaction didn't point
> to dev@ant.apache.org.  But it seems the header is set correctly.  Is
> it my mail reader that is broken?  I'm using gmail on line.
>
>
> 2008/8/7  <gs...@apache.org>:
> > 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();
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>


-- 
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://ant.apache.org/ivy/
http://www.xoocode.org/