You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2005/03/02 00:04:39 UTC
cvs commit: ant/src/main/org/apache/tools/ant/types Path.java
mbenson 2005/03/01 15:04:39
Modified: src/main/org/apache/tools/ant/types Path.java
Log:
Simplify some file resolution code to rely on FileUtils.
Revision Changes Path
1.69 +8 -14 ant/src/main/org/apache/tools/ant/types/Path.java
Index: Path.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Path.java,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- Path.java 24 Feb 2005 16:48:45 -0000 1.68
+++ Path.java 1 Mar 2005 23:04:39 -0000 1.69
@@ -26,10 +26,10 @@
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.PathTokenizer;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
-
/**
* This object represents a path as used by CLASSPATH or PATH
* environment variable.
@@ -260,12 +260,8 @@
: null;
for (int i = 0; i < list.length; i++) {
- File f = null;
- if (getProject() != null) {
- f = getProject().resolveFile(list[i]);
- } else {
- f = new File(list[i]);
- }
+ File f = resolveFile(getProject(), list[i]);
+
// probably not the best choice, but it solves the problem of
// relative paths in CLASSPATH
if (tryUserDir && !f.exists()) {
@@ -383,7 +379,7 @@
while (tok.hasMoreTokens()) {
String pathElement = tok.nextToken();
try {
- element.append(resolveFile(project, pathElement));
+ element.append(resolveFile(project, pathElement).getPath());
} catch (BuildException e) {
project.log("Dropping path element " + pathElement
+ " as it is not valid relative to the project",
@@ -483,12 +479,10 @@
/**
* Resolve a filename with Project's help - if we know one that is.
- *
- * <p>Assume the filename is absolute if project is null.</p>
*/
- private static String resolveFile(Project project, String relativeName) {
- return (project == null) ? relativeName
- : project.resolveFile(relativeName).getAbsolutePath();
+ private static File resolveFile(Project project, String relativeName) {
+ return FileUtils.getFileUtils().resolveFile(
+ (project == null) ? null : project.getBaseDir(), relativeName);
}
/**
@@ -689,7 +683,7 @@
String[] dirs = extdirs.list();
for (int i = 0; i < dirs.length; i++) {
- File dir = getProject().resolveFile(dirs[i]);
+ File dir = resolveFile(getProject(), dirs[i]);
if (dir.exists() && dir.isDirectory()) {
FileSet fs = new FileSet();
fs.setDir(dir);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org