diff options
author | Stefan Bodewig <bodewig@apache.org> | 2000-10-19 11:30:19 +0000 |
---|---|---|
committer | Stefan Bodewig <bodewig@apache.org> | 2000-10-19 11:30:19 +0000 |
commit | 205151486acb02a98f17a73c8367302d53fb56b8 (patch) | |
tree | b1ca9c1fe95ef8475d2524d1ac70e34d1bdc1855 | |
parent | 081d01391f8e9a6e9c1218e1dea279bd79e51fea (diff) | |
download | ant-205151486acb02a98f17a73c8367302d53fb56b8.tar.gz |
It seems far more plausible to interpret a relative file URI in SYSTEM
entities relative to the build file instead of basedir, doesn't it?
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268107 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/main/org/apache/tools/ant/ProjectHelper.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 6c7d0c845..027b33cb1 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -75,6 +75,7 @@ public class ProjectHelper { private org.xml.sax.Parser parser; private Project project; private File buildFile; + private File buildFileParent; private Locator locator; /** @@ -89,7 +90,8 @@ public class ProjectHelper { */ private ProjectHelper(Project project, File buildFile) { this.project = project; - this.buildFile = buildFile; + this.buildFile = new File(buildFile.getAbsolutePath()); + buildFileParent = new File(this.buildFile.getParent()); } /** @@ -181,16 +183,23 @@ public class ProjectHelper { private class RootHandler extends HandlerBase { /** - * resolve file: URIs as releative to the project's basedir. + * resolve file: URIs as relative to the build file. */ public InputSource resolveEntity(String publicId, String systemId) { if (systemId.startsWith("file:")) { + String path = systemId.substring(5); + File file = new File(path); + if (!file.isAbsolute()) { + file = new File(buildFileParent, path); + } + try { - return new InputSource(new FileInputStream(project.resolveFile(systemId.substring(5)))); + return new InputSource(new FileInputStream(file)); } catch (FileNotFoundException fne) { - project.log(fne.getMessage(), Project.MSG_WARN); + project.log(file.getAbsolutePath()+" could not be found", + Project.MSG_WARN); } } // use default if not file or file not found @@ -251,9 +260,8 @@ public class ProjectHelper { if (project.getProperty("basedir") != null) { project.setBasedir(project.getProperty("basedir")); } else { - String buildFileParent = (new File(buildFile.getAbsolutePath())).getParent(); if (baseDir == null) { - project.setBasedir((new File(buildFileParent)).getAbsolutePath()); + project.setBasedir(buildFileParent.getAbsolutePath()); } else { // check whether the user has specified an absolute path if ((new File(baseDir)).isAbsolute()) { |