On 4/25/07, Maarten Coene <[EMAIL PROTECTED]> wrote:
I would go for option 2 (halt on any failure). I think there can be many reasons why something fails, adding a property for each possible cause seems a bit overkill to me.
I agree, but if you look at IVY-475, it was the first intention. Then Jeffrey went another way, so I lazily guessed there was a good reason without asking. My fault. So, Jeffrey, could elaborate on why you test the unresolved dependencies instead of a simple failure (report.hasError())?
If you really want to behave differently when the resolve fails, maybe you should do a manual ivy:resolve followed by an ivy:install?
This is not straightforward because in the ivy:install task you manually set the resolver to use to resolve your dependencies, which is not possible on the resolve task.
This behavior would also be the consistent with the post-resolve tasks. Which brings me to my next question: shouldn't the ivy:install task be a post-resolve task?
If we want to make it post resolve task, we have to add the feature to select the resolve in the resolve task. We would also have to add the feature of scanning a repository to resolve all modules matching a pattern. I think it's really different from the resolve task purpose, and therefore would prefer to stick with the current separation between resolve and install. WDYT? Xavier
regards, Maarten ----- Original Message ---- From: Xavier Hanin <[EMAIL PROTECTED]> To: [email protected] Sent: Wednesday, April 25, 2007 8:44:33 AM Subject: Re: svn commit: r532027 - in /incubator/ivy/core/trunk: CHANGES.txt doc/doc/use/install.html src/java/org/apache/ivy/ant/IvyInstall.java test/java/org/apache/ivy/ant/IvyInstallTest.java On 4/24/07, Maarten Coene <[EMAIL PROTECTED]> wrote: > To keep a more consistent naming, I would prefer to use "haltonfailure" instead of "haltonunresolved" Yes, I was wondering myself if haltonfailure would be better. The point is that it doesn't halt on any failure, it halts only on unresolved dependencies. So I see 3 options: - rename to haltonfailure and keep code as is - rename to haltonfailure and actually halt on any failure - add haltonfailure which halts on any failure, and keep haltonunresolved WDYT? Xavier > > regards, > Maarten > > ----- Original Message ---- > From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Sent: Tuesday, April 24, 2007 7:53:21 PM > Subject: svn commit: r532027 - in /incubator/ivy/core/trunk: CHANGES.txt doc/doc/use/install.html src/java/org/apache/ivy/ant/IvyInstall.java test/java/org/apache/ivy/ant/IvyInstallTest.java > > Author: xavier > Date: Tue Apr 24 10:53:20 2007 > New Revision: 532027 > > URL: http://svn.apache.org/viewvc?view=rev&rev=532027 > Log: > BUG: ivy:install ant task does not fail on error (IVY-475) (thanks to Jeffrey Blatttman) > > Added: > incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java > Modified: > incubator/ivy/core/trunk/CHANGES.txt > incubator/ivy/core/trunk/doc/doc/use/install.html > incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java > > Modified: incubator/ivy/core/trunk/CHANGES.txt > URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?view=diff&rev=532027&r1=532026&r2=532027 > ============================================================================== > --- incubator/ivy/core/trunk/CHANGES.txt (original) > +++ incubator/ivy/core/trunk/CHANGES.txt Tue Apr 24 10:53:20 2007 > @@ -13,6 +13,7 @@ > Ingo Adler > Stephane Baillez > Karl Baum > + Jeffrey Blatttman > Matthieu Brouillard > Kristian Cibulskis > Pierre Hägnestrand > @@ -43,6 +44,9 @@ > Johan Stuyts > John Williams > > + version in SVN > +===================================== > +- BUG: ivy:install ant task does not fail on error (IVY-475) (thanks to Jeffrey Blatttman) > > 2.0.0-alpha1-incubating > ===================================== > > Modified: incubator/ivy/core/trunk/doc/doc/use/install.html > URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/doc/doc/use/install.html?view=diff&rev=532027&r1=532026&r2=532027 > ============================================================================== > --- incubator/ivy/core/trunk/doc/doc/use/install.html (original) > +++ incubator/ivy/core/trunk/doc/doc/use/install.html Tue Apr 24 10:53:20 2007 > @@ -56,6 +56,8 @@ > <td>No, defaults to false</td></tr> > <tr><td>matcher</td><td>the name of the matcher to use to find the modules to install</td> > <td>No, defaults to exact</td></tr> > + <tr><td>haltonunresolved</td><td>true to fail build on unresolved dependencies <span class="since">since 2.0</span></td> > + <td>No, defaults to true</td></tr> > </tbody> > </table> > <h1>Examples</h1> > > Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java > URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java?view=diff&rev=532027&r1=532026&r2=532027 > ============================================================================== > --- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java (original) > +++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java Tue Apr 24 10:53:20 2007 > @@ -25,12 +25,13 @@ > import org.apache.ivy.plugins.matcher.PatternMatcher; > import org.apache.ivy.util.filter.FilterHelper; > import org.apache.tools.ant.BuildException; > - > +import org.apache.ivy.core.report.ResolveReport; > +import org.apache.tools.ant.BuildException; > > /** > * Allow to install a module or a set of module from repository to another one. > - * > - * > + * > + * > * @author Xavier Hanin > * > */ > @@ -38,13 +39,14 @@ > private String _organisation; > private String _module; > private String _revision; > - private File _cache; > + private File _cache; > private boolean _overwrite = false; > private String _from; > private String _to; > private boolean _transitive; > private String _type; > private String _matcher = PatternMatcher.EXACT; > + private boolean _haltOnUnresolved = true; > > public void execute() throws BuildException { > Ivy ivy = getIvyInstance(); > @@ -58,12 +60,12 @@ > if (_module == null && PatternMatcher.EXACT.equals(_matcher)) { > throw new BuildException("no module name provided for ivy publish task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>"); > } else if (_module == null && !PatternMatcher.EXACT.equals(_matcher)) { > - _module = PatternMatcher.ANY_EXPRESSION; > + _module = PatternMatcher.ANY_EXPRESSION; > } > if (_revision == null && PatternMatcher.EXACT.equals(_matcher)) { > throw new BuildException("no module revision provided for ivy publish task: It can either be set explicitely via the attribute 'revision' or via 'ivy.revision' property or a prior call to <resolve/>"); > } else if (_revision == null && !PatternMatcher.EXACT.equals(_matcher)) { > - _revision = PatternMatcher.ANY_EXPRESSION; > + _revision = PatternMatcher.ANY_EXPRESSION; > } > if (_from == null) { > throw new BuildException("no from resolver name: please provide it through parameter 'from'"); > @@ -72,13 +74,26 @@ > throw new BuildException("no to resolver name: please provide it through parameter 'to'"); > } > ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision); > + ResolveReport report; > try { > - ivy.install(mrid, _from, _to, _transitive, doValidate(settings), _overwrite, FilterHelper.getArtifactTypeFilter(_type), _cache, _matcher); > + report = ivy.install(mrid, _from, _to, _transitive, doValidate(settings), _overwrite, FilterHelper.getArtifactTypeFilter(_type), _cache, _matcher); > } catch (Exception e) { > throw new BuildException("impossible to install "+ mrid +": "+e, e); > } > + > + if (report.getUnresolvedDependencies().length > 0 && isHaltonunresolved()) { > + throw new BuildException(report.getUnresolvedDependencies().length > + +" unresolved dependencies - see output for details"); > + } > } > - > + > + public boolean isHaltonunresolved() { > + return _haltOnUnresolved; > + } > + public void setHaltonunresolved(boolean haltOnUnresolved) { > + _haltOnUnresolved = haltOnUnresolved; > + } > + > public File getCache() { > return _cache; > } > @@ -134,11 +149,11 @@ > public void setType(String type) { > _type = type; > } > - > + > public String getMatcher() { > return _matcher; > } > - > + > public void setMatcher(String matcher) { > _matcher = matcher; > } > > Added: incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java > URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java?view=auto&rev=532027 > ============================================================================== > --- incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java (added) > +++ incubator/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyInstallTest.java Tue Apr 24 10:53:20 2007 > @@ -0,0 +1,101 @@ > +/* > + * 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. > + * > + */ > +package org.apache.ivy.ant; > + > +import java.io.File; > + > +import junit.framework.TestCase; > + > +import org.apache.tools.ant.BuildException; > +import org.apache.tools.ant.Project; > +import org.apache.tools.ant.taskdefs.Delete; > + > + > +public class IvyInstallTest extends TestCase { > + private File _cache; > + private IvyInstall _install; > + private Project _project; > + > + protected void setUp() throws Exception { > + createCache(); > + cleanTestLib(); > + _project = new Project(); > + _project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); > + > + _install = new IvyInstall(); > + _install.setProject(_project); > + _install.setCache(_cache); > + } > + > + private void createCache() { > + _cache = new File("build/cache"); > + _cache.mkdirs(); > + } > + > + protected void tearDown() throws Exception { > + cleanCache(); > + cleanTestLib(); > + } > + > + private void cleanCache() { > + Delete del = new Delete(); > + del.setProject(new Project()); > + del.setDir(_cache); > + del.execute(); > + } > + > + private void cleanTestLib() { > + Delete del = new Delete(); > + del.setProject(new Project()); > + del.setDir(new File("build/test/lib")); > + del.execute(); > + } > + > + public void testDependencyNotFoundFailure() { > + _install.setOrganisation("xxx"); > + _install.setModule("yyy"); > + _install.setRevision("zzz"); > + _install.setFrom("test"); > + _install.setTo("1"); > + > + try { > + _install.execute(); > + fail("unknown dependency, failure expected (haltunresolved=true)"); > + } catch (BuildException be) { > + // success > + assertTrue("invalid exception message, it should contain '1 unresolved'," > + +" but it's: '"+be.getMessage()+"'", > + be.getMessage().indexOf("1 unresolved") != -1); > + } > + } > + > + public void testDependencyNotFoundSuccess() { > + _install.setOrganisation("xxx"); > + _install.setModule("yyy"); > + _install.setRevision("zzz"); > + _install.setFrom("test"); > + _install.setTo("1"); > + _install.setHaltonunresolved(false); > + > + try { > + _install.execute(); > + } catch (BuildException be) { > + fail("unknown dependency, failure unexepected (haltunresolved=false)"); > + } > + } > +} > > > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > -- Learn Ivy at ApacheCon: http://www.eu.apachecon.com/ Manage your dependencies with Ivy! http://incubator.apache.org/ivy/ __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
-- Learn Ivy at ApacheCon: http://www.eu.apachecon.com/ Manage your dependencies with Ivy! http://incubator.apache.org/ivy/
