Browse Source

File paths to imported build files should not be canonicalized

PR: 28505
Obtained from: Jesse Glick


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276422 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
1cac66df9a
5 changed files with 39 additions and 10 deletions
  1. +4
    -0
      src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml
  2. +1
    -0
      src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml
  3. +1
    -0
      src/etc/testcases/taskdefs/import/symlinks/d3a/p3.xml
  4. +0
    -9
      src/main/org/apache/tools/ant/taskdefs/ImportTask.java
  5. +33
    -1
      src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java

+ 4
- 0
src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml View File

@@ -0,0 +1,4 @@
<project name="p1" default="run">
<import file="../d2/p2.xml"/>
<import file="../d3b/p3.xml"/>
</project>

+ 1
- 0
src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml View File

@@ -0,0 +1 @@
<project name="p2"/>

+ 1
- 0
src/etc/testcases/taskdefs/import/symlinks/d3a/p3.xml View File

@@ -0,0 +1 @@
<project name="p3"/>

+ 0
- 9
src/main/org/apache/tools/ant/taskdefs/ImportTask.java View File

@@ -131,8 +131,6 @@ public class ImportTask extends Task {
}
}

importedFile = new File(getPath(importedFile));

if (importStack.contains(importedFile)) {
getProject().log(
"Skipped already imported file:\n "
@@ -148,11 +146,4 @@ public class ImportTask extends Task {
}
}

private static String getPath(File file) {
try {
return file.getCanonicalPath();
} catch (IOException e) {
return file.getAbsolutePath();
}
}
}

+ 33
- 1
src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java View File

@@ -17,6 +17,9 @@

package org.apache.tools.ant.taskdefs;

import java.io.File;
import java.io.IOException;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.Location;
@@ -109,5 +112,34 @@ public class ImportTest extends BuildFileTest {
"Did not see build exception",
false);
}
}

public void testSymlinkedImports() throws Exception {
String ln = "/usr/bin/ln";
if (!new File(ln).exists()) {
ln = "/bin/ln";
}
if (!new File(ln).exists()) {
// Running on Windows or something, so skip it.
return;
}
String symlink = "src/etc/testcases/taskdefs/import/symlinks/d3b";
if (Runtime.getRuntime().exec(new String[] {ln, "-s", "d3a", symlink}).waitFor() != 0) {
throw new IOException("'" + ln + " -s d3a " + symlink + "' failed");
}
try {
configureProject(
"src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml");
assertPropertyEquals(
"ant.file.p2",
new File("src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml")
.getAbsolutePath());
assertPropertyEquals(
"ant.file.p3",
new File("src/etc/testcases/taskdefs/import/symlinks/d3b/p3.xml")
.getAbsolutePath());
} finally {
new File(symlink).delete();
}
}

}

Loading…
Cancel
Save