peterreilly 2003/11/03 08:39:34
Modified: src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
ImportTask.java
src/testcases/org/apache/tools/ant/taskdefs Tag:
ANT_16_BRANCH ImportTest.java
Added: src/etc/testcases/taskdefs/import Tag: ANT_16_BRANCH bad.xml
import_bad_import.xml
Log:
Sync with HEAD
Revision Changes Path
No revision
No revision
1.1.2.1 +0 -0 ant/src/etc/testcases/taskdefs/import/bad.xml
Index: bad.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/import/bad.xml,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
1.1.2.1 +0 -0 ant/src/etc/testcases/taskdefs/import/import_bad_import.xml
Index: import_bad_import.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/import/import_bad_import.xml,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
No revision
No revision
1.16.2.4 +14 -1 ant/src/main/org/apache/tools/ant/taskdefs/ImportTask.java
Index: ImportTask.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ImportTask.java,v
retrieving revision 1.16.2.3
retrieving revision 1.16.2.4
diff -u -r1.16.2.3 -r1.16.2.4
--- ImportTask.java 3 Nov 2003 10:16:38 -0000 1.16.2.3
+++ ImportTask.java 3 Nov 2003 16:39:34 -0000 1.16.2.4
@@ -55,6 +55,7 @@
package org.apache.tools.ant.taskdefs;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task;
@@ -179,7 +180,19 @@
return;
}
- helper.parse(getProject(), importedFile);
+ try {
+ helper.parse(getProject(), importedFile);
+ } catch (BuildException ex) {
+ Location exLocation = ex.getLocation();
+ if (exLocation == null) {
+ throw ex;
+ }
+ throw new BuildException(
+ "Error executing import file"
+ + System.getProperty("line.separator")
+ + exLocation.toString()
+ + " " + ex.getMessage());
+ }
}
private static String getPath(File file) {
No revision
No revision
1.6.2.1 +24 -0 ant/src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java
Index: ImportTest.java
===================================================================
RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- ImportTest.java 19 Sep 2003 09:36:22 -0000 1.6
+++ ImportTest.java 3 Nov 2003 16:39:34 -0000 1.6.2.1
@@ -54,7 +54,9 @@
package org.apache.tools.ant.taskdefs;
+import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project;
/**
@@ -118,6 +120,28 @@
"src/etc/testcases/taskdefs/import/subdir/importinsequential.xml");
expectPropertySet("within-imported", "foo", "bar");
assertNotNull(getProject().getReference("baz"));
+ }
+
+ public void testImportError() {
+ try {
+ configureProject(
+ "src/etc/testcases/taskdefs/import/import_bad_import.xml");
+ } catch (BuildException ex) {
+ Location lo = ex.getLocation();
+ assertTrue(
+ "expected location of build exception to be set",
+ (lo != null));
+ assertTrue(
+ "expected location to contain calling file",
+ lo.getFileName().indexOf("import_bad_import.xml") != -1);
+ assertTrue(
+ "expected message of ex to contain called file",
+ ex.getMessage().indexOf("bad.xml") != -1);
+ return;
+ }
+ assertTrue(
+ "Did not see build exception",
+ false);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
|