symbolic links are present (but in a way that is probably closer to what the user expects) and remove some problems on platforms that use "uncommon" native file names like OS/390 or VMS. Submitted by: Jesse Glick <Jesse.Glick@netbeans.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269309 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -24,6 +24,10 @@ Changes that could break older environments: | |||||
| * JUnitResultFormater has two additional methods that must be | * JUnitResultFormater has two additional methods that must be | ||||
| implemented by custom formatters. | 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: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -314,19 +314,17 @@ public class Project { | |||||
| // match basedir attribute in xml | // match basedir attribute in xml | ||||
| public void setBasedir(String baseD) throws BuildException { | 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); | log(msg, MSG_VERBOSE); | ||||
| } | } | ||||
| @@ -335,7 +333,7 @@ public class Project { | |||||
| try { | try { | ||||
| setBasedir("."); | setBasedir("."); | ||||
| } catch (BuildException ex) { | } catch (BuildException ex) { | ||||
| ex.printStackTrace(); | |||||
| ex.printStackTrace(); | |||||
| } | } | ||||
| } | } | ||||
| return baseDir; | return baseDir; | ||||
| @@ -553,13 +551,7 @@ public class Project { | |||||
| // deal with absolute files | // deal with absolute files | ||||
| if (fileName.startsWith(File.separator)) { | 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 | // 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) { | public File resolveFile(String fileName) { | ||||
| @@ -326,7 +326,7 @@ public class ProjectHelper { | |||||
| if ((new File(baseDir)).isAbsolute()) { | if ((new File(baseDir)).isAbsolute()) { | ||||
| project.setBasedir(baseDir); | project.setBasedir(baseDir); | ||||
| } else { | } else { | ||||
| project.setBasedir((new File(buildFileParent, baseDir)).getAbsolutePath()); | |||||
| project.setBaseDir(project.resolveFile(baseDir, buildFileParent)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -112,16 +112,7 @@ public class Path extends DataType implements Cloneable { | |||||
| private String[] parts; | private String[] parts; | ||||
| public void setLocation(File loc) { | 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) { | public void setPath(String path) { | ||||
| @@ -304,14 +295,9 @@ public class Path extends DataType implements Cloneable { | |||||
| String[] s = ds.getIncludedFiles(); | String[] s = ds.getIncludedFiles(); | ||||
| File dir = fs.getDir(project); | File dir = fs.getDir(project); | ||||
| for (int j=0; j<s.length; j++) { | for (int j=0; j<s.length; j++) { | ||||
| String canonicalPath; | |||||
| File f = new File(dir, s[j]); | File f = new File(dir, s[j]); | ||||
| try { | |||||
| canonicalPath = f.getCanonicalPath(); | |||||
| } catch(IOException e) { | |||||
| canonicalPath = f.getAbsolutePath(); | |||||
| } | |||||
| addUnlessPresent(result, translateFile(canonicalPath)); | |||||
| String absolutePath = f.getAbsolutePath(); | |||||
| addUnlessPresent(result, translateFile(absolutePath)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -454,12 +440,7 @@ public class Path extends DataType implements Cloneable { | |||||
| private static String resolveFile(Project project, String relativeName) { | private static String resolveFile(Project project, String relativeName) { | ||||
| if (project != null) { | if (project != null) { | ||||
| File f = project.resolveFile(relativeName); | File f = project.resolveFile(relativeName); | ||||
| try { | |||||
| return f.getCanonicalPath(); | |||||
| } catch(IOException e) { | |||||
| project.log(e.getMessage(), Project.MSG_WARN); | |||||
| return f.getAbsolutePath(); | |||||
| } | |||||
| return f.getAbsolutePath(); | |||||
| } | } | ||||
| return relativeName; | return relativeName; | ||||
| } | } | ||||