You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-dev@incubator.apache.org by Maarten Coene <ma...@yahoo.com> on 2007/04/24 21:20:41 UTC
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
To keep a more consistent naming, I would prefer to use "haltonfailure" instead of "haltonunresolved"
regards,
Maarten
----- Original Message ----
From: "xavier@apache.org" <xa...@apache.org>
To: ivy-commits@incubator.apache.org
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
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
Posted by Gilles Scokart <gs...@gmail.com>.
I didn't see any scenario where the user wants to haltonunresolved but not
haltonfailure. Did you?
If not, the second option is better.
Gilles
> -----Original Message-----
> From: Xavier Hanin [mailto:xavier.hanin@gmail.com]
> Sent: mercredi 25 avril 2007 8:45
> To: ivy-dev@incubator.apache.org
> 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 <ma...@yahoo.com> 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: "xavier@apache.org" <xa...@apache.org>
> > To: ivy-commits@incubator.apache.org
> > 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=dif
> f&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/
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
Posted by Xavier Hanin <xa...@gmail.com>.
On 4/24/07, Maarten Coene <ma...@yahoo.com> 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: "xavier@apache.org" <xa...@apache.org>
> To: ivy-commits@incubator.apache.org
> 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/