Index: test/java/org/apache/ivy/ant/IvyInstallTest.java
===================================================================
--- test/java/org/apache/ivy/ant/IvyInstallTest.java (revision 0)
+++ test/java/org/apache/ivy/ant/IvyInstallTest.java (revision 0)
@@ -0,0 +1,105 @@
+/*
+ * 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 java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.ivy.TestHelper;
+import org.apache.ivy.core.IvyPatternHelper;
+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 static final String IVY_RETRIEVE_PATTERN = "build/test/lib/[organisation]/[module]/ivy-[revision].xml";
+ private static final String RETRIEVE_PATTERN = "build/test/lib/[conf]/[artifact]-[revision].[type]";
+ 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
+ be.printStackTrace();
+ }
+ }
+
+ 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) {
+ be.printStackTrace();
+ fail("unknown dependency, failure unexepected (haltunresolved=false)");
+ }
+ }
+}
Index: src/java/org/apache/ivy/ant/IvyInstall.java
===================================================================
--- src/java/org/apache/ivy/ant/IvyInstall.java (revision 531541)
+++ src/java/org/apache/ivy/ant/IvyInstall.java (working copy)
@@ -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