diff --git a/WHATSNEW b/WHATSNEW
index 66f261025..fe28cf9c0 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -8,6 +8,10 @@ Changes that could break older environments:
Fixed bugs:
-----------
+* / failed when the importing file was loaded from an
+ URI or a jar and it imported a file from the local file system via
+ an absolute path.
+ Bugzilla Report 50953
Other changes:
--------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ImportTask.java b/src/main/org/apache/tools/ant/taskdefs/ImportTask.java
index 2da7f55b4..2234dd54b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ImportTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ImportTask.java
@@ -248,6 +248,10 @@ public class ImportTask extends Task {
// *not* the current directory (same as entity includes).
if (file != null) {
+ if (isExistingAbsoluteFile(file)) {
+ return new FileResource(new File(file));
+ }
+
File buildFile =
new File(getLocation().getFileName()).getAbsoluteFile();
if (buildFile.exists()) {
@@ -271,6 +275,11 @@ public class ImportTask extends Task {
return null;
}
+ private boolean isExistingAbsoluteFile(String name) {
+ File f = new File(name);
+ return f.isAbsolute() && f.exists();
+ }
+
/**
* Whether the task is in include (as opposed to import) mode.
*
diff --git a/src/tests/antunit/taskdefs/import-url-test.xml b/src/tests/antunit/taskdefs/import-url-test.xml
index f8001dd37..103ece3ec 100644
--- a/src/tests/antunit/taskdefs/import-url-test.xml
+++ b/src/tests/antunit/taskdefs/import-url-test.xml
@@ -18,6 +18,7 @@
+
]]>
+
+
+
+]]>
+
+
+ In imported
+
+
]]>
@@ -55,6 +68,11 @@ foo=bar
+
+
+
+
+
@@ -62,6 +80,11 @@ foo=bar
+
+
+
+
@@ -73,5 +96,6 @@ foo=bar
+