diff --git a/WHATSNEW b/WHATSNEW index b380e25ba..fd0bfb959 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -24,6 +24,10 @@ Changes that could break older environments: * JUnitResultFormater has two additional methods that must be implemented by custom formatters. +* Ant will no longer use the canonical version of a path internally - + this may yield different results on filesystems that support + symbolic links. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index 08bbe5259..edc73c53c 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -314,19 +314,17 @@ public class Project { // match basedir attribute in xml public void setBasedir(String baseD) throws BuildException { - try { - setBaseDir(new File(new File(baseD).getCanonicalPath())); - } catch (IOException ioe) { - String msg = "Can't set basedir " + baseD + " due to " + - ioe.getMessage(); - throw new BuildException(msg); - } + setBaseDir(new File(baseD)); } - public void setBaseDir(File baseDir) { - this.baseDir = baseDir; - setProperty( "basedir", baseDir.getAbsolutePath()); - String msg = "Project base dir set to: " + baseDir; + public void setBaseDir(File baseDir) throws BuildException { + if (!baseDir.exists()) + throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " does not exist"); + if (!baseDir.isDirectory()) + throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " is not a directory"); + this.baseDir = new File(baseDir.getAbsolutePath()); + setProperty( "basedir", this.baseDir.getPath()); + String msg = "Project base dir set to: " + this.baseDir; log(msg, MSG_VERBOSE); } @@ -335,7 +333,7 @@ public class Project { try { setBasedir("."); } catch (BuildException ex) { - ex.printStackTrace(); + ex.printStackTrace(); } } return baseDir; @@ -553,13 +551,7 @@ public class Project { // deal with absolute files if (fileName.startsWith(File.separator)) { - try { - return new File(new File(fileName).getCanonicalPath()); - } catch (IOException e) { - log("IOException getting canonical path for " + fileName - + ": " + e.getMessage(), MSG_ERR); - return new File(fileName); - } + return new File(fileName); } // Eliminate consecutive slashes after the drive spec @@ -608,14 +600,7 @@ public class Project { } } - try { - return new File(file.getCanonicalPath()); - } - catch (IOException e) { - log("IOException getting canonical path for " + file + ": " + - e.getMessage(), MSG_ERR); - return new File(file.getAbsolutePath()); - } + return new File(file.getAbsolutePath()); } public File resolveFile(String fileName) { diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 0a29860a9..02ecdfba6 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -326,7 +326,7 @@ public class ProjectHelper { if ((new File(baseDir)).isAbsolute()) { project.setBasedir(baseDir); } else { - project.setBasedir((new File(buildFileParent, baseDir)).getAbsolutePath()); + project.setBaseDir(project.resolveFile(baseDir, buildFileParent)); } } } diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index d5e349335..97998e1ad 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -112,16 +112,7 @@ public class Path extends DataType implements Cloneable { private String[] parts; public void setLocation(File loc) { - try { - parts = new String[] {translateFile(loc.getCanonicalPath())}; - } catch(IOException e) { - // XXX I'd like to log something here but if I don't - // have a Project I can't - if (project != null) { - project.log(e.getMessage(), Project.MSG_WARN); - } - parts = new String[] {translateFile(loc.getAbsolutePath())}; - } + parts = new String[] {translateFile(loc.getAbsolutePath())}; } public void setPath(String path) { @@ -304,14 +295,9 @@ public class Path extends DataType implements Cloneable { String[] s = ds.getIncludedFiles(); File dir = fs.getDir(project); for (int j=0; j