Browse Source

Use FileUtils#resolveFile instead of doing it by hand

Should work now on windows and netware
PR: 24296
Obtained from: Matt Lennon


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275596 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
916ad103bc
1 changed files with 3 additions and 6 deletions
  1. +3
    -6
      src/main/org/apache/tools/ant/taskdefs/ImportTask.java

+ 3
- 6
src/main/org/apache/tools/ant/taskdefs/ImportTask.java View File

@@ -58,6 +58,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.util.FileUtils;


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -95,6 +96,7 @@ import java.util.Vector;
public class ImportTask extends Task { public class ImportTask extends Task {
private String file; private String file;
private boolean optional; private boolean optional;
private static final FileUtils FILE_UTILS = FileUtils.newFileUtils();


/** /**
* sets the optional attribute * sets the optional attribute
@@ -147,17 +149,12 @@ public class ImportTask extends Task {
File buildFile = new File(getLocation().getFileName()); File buildFile = new File(getLocation().getFileName());
buildFile = new File(buildFile.getAbsolutePath()); buildFile = new File(buildFile.getAbsolutePath());


File buildFileParent = new File(buildFile.getParent());

getProject().log("Importing file " + file + " from " getProject().log("Importing file " + file + " from "
+ buildFile.getAbsolutePath(), Project.MSG_VERBOSE); + buildFile.getAbsolutePath(), Project.MSG_VERBOSE);


// Paths are relative to the build file they're imported from, // Paths are relative to the build file they're imported from,
// *not* the current directory (same as entity includes). // *not* the current directory (same as entity includes).
File importedFile = new File(file);
if (!importedFile.isAbsolute()) {
importedFile = new File(buildFileParent, file);
}
File importedFile = FILE_UTILS.resolveFile(buildFile, file);


if (!importedFile.exists()) { if (!importedFile.exists()) {
String message = String message =


Loading…
Cancel
Save