Browse Source

Remove unnecessary use of Project.resolveFile by converting arguments to

Files from Strings


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269286 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
54dc62a542
11 changed files with 63 additions and 85 deletions
  1. +16
    -7
      src/main/org/apache/tools/ant/AntClassLoader.java
  2. +1
    -1
      src/main/org/apache/tools/ant/Project.java
  3. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/GZip.java
  4. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/KeySubst.java
  5. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/Rename.java
  6. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  7. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/Untar.java
  8. +0
    -30
      src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  9. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
  10. +13
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java
  11. +8
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java

+ 16
- 7
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -152,14 +152,18 @@ public class AntClassLoader extends ClassLoader {
URL url = null;
while ((this.pathElementsIndex < this.pathElements.length) &&
(url == null)) {
File pathComponent = AntClassLoader.this.project.resolveFile(
(String)this.pathElements[this.pathElementsIndex]);
url = getResourceURL(pathComponent, this.resourceName);
this.pathElementsIndex++;
try {
File pathComponent = AntClassLoader.this.project.resolveFile(
(String)this.pathElements[this.pathElementsIndex]);
url = getResourceURL(pathComponent, this.resourceName);
this.pathElementsIndex++;
}
catch (BuildException e) {
// ignore path elements which are not valid relative to the project
}
}
this.nextResource = url;
}

}

/**
@@ -386,8 +390,13 @@ public class AntClassLoader extends ClassLoader {
String[] pathElements = classpath.list();
for (int i = 0; i < pathElements.length && stream == null; ++i) {
File pathComponent = project.resolveFile((String)pathElements[i]);
stream = getResourceStream(pathComponent, name);
try {
File pathComponent = project.resolveFile((String)pathElements[i]);
stream = getResourceStream(pathComponent, name);
}
catch {BuildException e) {
// ignore path elements which are invalid relative to the project
}
}

return stream;


+ 1
- 1
src/main/org/apache/tools/ant/Project.java View File

@@ -598,7 +598,7 @@ public class Project {
if (part.equals("..")) {
String parentFile = file.getParent();
if (parentFile == null) {
throw new BuildException("The file or path you specified (" + fileName + ") is invalid releative to " + rootDir.getAbsolutePath());
throw new BuildException("The file or path you specified (" + fileName + ") is invalid relative to " + rootDir.getAbsolutePath());
}
file = new File(parentFile);
} else if (part.equals(".")) {


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/GZip.java View File

@@ -72,12 +72,12 @@ public class GZip extends Task {
private File zipFile;
private File source;
public void setZipfile(String zipFilename) {
zipFile = project.resolveFile(zipFilename);
public void setZipfile(File zipFilename) {
zipFile = zipFilename;
}

public void setSrc(String src) {
source = project.resolveFile(src);
public void setSrc(File src) {
source = src;
}

public void execute() throws BuildException {


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/KeySubst.java View File

@@ -115,15 +115,15 @@ public class KeySubst extends Task {
/**
Set the source file.
*/
public void setSrc(String s) {
this.source=project.resolveFile(s);
public void setSrc(File s) {
this.source = s;
}

/**
Set the destination file.
*/
public void setDest(String dest) {
this.dest = project.resolveFile(dest);
public void setDest(File dest) {
this.dest = dest;
}

/**


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/Rename.java View File

@@ -77,16 +77,16 @@ public class Rename extends Task {
* Sets the file to be renamed.
* @param src the file to rename
*/
public void setSrc(String src) {
this.src = project.resolveFile(src);
public void setSrc(File src) {
this.src = src;
}

/**
* Sets the new name of the file.
* @param dest the new name of the file.
*/
public void setDest(String dest) {
this.dest = project.resolveFile(dest);
public void setDest(File dest) {
this.dest = dest;
}

/**


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -411,8 +411,8 @@ public class Replace extends MatchingTask {
/**
* Sets a file to be searched for property values.
*/
public void setPropertyFile(String filename) {
propertyFile = project.resolveFile(filename);
public void setPropertyFile(File filename) {
propertyFile = filename;
}

/**


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/Untar.java View File

@@ -66,8 +66,8 @@ import java.io.*;
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class Untar extends Task {
private String dest; // req
private String source; // req
private File dest; // req
private File source; // req

/**
* Do the work.
@@ -81,7 +81,7 @@ public class Untar extends Task {
touch.setTaskName(getTaskName());
touch.setLocation(getLocation());
File srcF=project.resolveFile(source);
File srcF = source;

TarInputStream tis = null;
try {
@@ -96,7 +96,7 @@ public class Untar extends Task {
if (dest == null) {
throw new BuildException("No destination specified", location);
}
File dir=project.resolveFile(dest);
File dir = dest;

log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
tis = new TarInputStream(new FileInputStream(srcF));
@@ -154,8 +154,8 @@ public class Untar extends Task {
*
* @param d Path to the directory.
*/
public void setDest(String d) {
this.dest=d;
public void setDest(File d) {
this.dest = d;
}

/**
@@ -163,7 +163,7 @@ public class Untar extends Task {
*
* @param s Path to tar-file.
*/
public void setSrc(String s) {
public void setSrc(File s) {
this.source = s;
}
}

+ 0
- 30
src/main/org/apache/tools/ant/taskdefs/optional/Javah.java View File

@@ -433,35 +433,5 @@ public class Javah extends Task {

log(prefix.toString() + niceClassList.toString(), Project.MSG_VERBOSE);
}

///**
// * Emulation of extdirs feature in java >= 1.2.
// * This method adds all files in the given
// * directories (but not in sub-directories!) to the classpath,
// * so that you don't have to specify them all one by one.
// * @param classpath - Path to append files to
// */
//protected void addExtdirsToClasspath(Path classpath) {
// if (extdirs == null) {
// String extProp = System.getProperty("java.ext.dirs");
// if (extProp != null) {
// extdirs = new Path(project, extProp);
// } else {
// return;
// }
// }
//
// String[] dirs = extdirs.list();
// for (int i=0; i<dirs.length; i++) {
// if (!dirs[i].endsWith(File.separator)) {
// dirs[i] += File.separator;
// }
// File dir = project.resolveFile(dirs[i]);
// FileSet fs = new FileSet();
// fs.setDir(dir);
// fs.setIncludes("*");
// classpath.addFileset(fs);
// }
//}
}


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java View File

@@ -221,8 +221,8 @@ public class NetRexxC extends MatchingTask {
* Set the destination directory into which the NetRexx source
* files should be copied and then compiled.
*/
public void setDestDir(String destDirName) {
destDir = project.resolveFile(destDirName);
public void setDestDir(File destDirName) {
destDir = destDirName;
}

/**
@@ -308,8 +308,8 @@ public class NetRexxC extends MatchingTask {
/**
* Set the source dir to find the source Java files.
*/
public void setSrcDir(String srcDirName) {
srcDir = project.resolveFile(srcDirName);
public void setSrcDir(File srcDirName) {
srcDir = srcDirName;
}

/**


+ 13
- 13
src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java View File

@@ -388,8 +388,8 @@ public class CSharp
/** file for generated XML documentation
* @param f output file
*/
public void setDocFile(String f) {
_docFile=project.resolveFile(f);
public void setDocFile(File f) {
_docFile = f;
}
/** get the argument or null for no argument needed
@@ -526,8 +526,8 @@ public class CSharp
* Set the source dir to find the files to be compiled
* @param srcDirName The new SrcDir value
*/
public void setSrcDir(String srcDirName){
_srcDir = project.resolveFile(srcDirName);
public void setSrcDir(File srcDirName){
_srcDir = srcDirName;
}
/** destination directory (null means use the source directory)
@@ -539,8 +539,8 @@ public class CSharp
* Set the destination dir to find the files to be compiled
* @param dirName The new DestDir value
*/
public void setDestDir(String dirName) {
_destDir = project.resolveFile(dirName);
public void setDestDir(File dirName) {
_destDir = dirName;
}
/** type of target. Should be one of exe|library|module|winexe|(null)
@@ -593,8 +593,8 @@ public class CSharp
* Set the win32 icon
* @param fileName path to the file. Can be relative, absolute, whatever.
*/
public void setWin32Icon(String fileName) {
_win32icon = project.resolveFile(fileName);
public void setWin32Icon(File fileName) {
_win32icon = fileName;
}
/**
@@ -660,22 +660,22 @@ public class CSharp
/** output file. If not supplied this is derived from the
* source file
*/
protected String _outputFile;
protected File _outputFile;
/**
* Set the definitions
* @param list of definitions split by ; or , or even :
*/
public void setOutputFile(String params) {
_outputFile=params;
public void setOutputFile(File params) {
_outputFile = params;
}
/** get the argument or null for no argument needed
* @return The OutputFile Parameter to CSC
*/
protected String getOutputFileParameter() {
if (notEmpty(_outputFile)) {
File f=project.resolveFile(_outputFile);
if (_outputFile != null) {
File f = _outputFile;
return "/out:"+f.toString();
}
else


+ 8
- 9
src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java View File

@@ -160,8 +160,8 @@ public class Ilasm
* Set the source dir to find the files to be compiled
* @param srcDirName The new SrcDir value
*/
public void setSrcDir(String srcDirName){
_srcDir = project.resolveFile(srcDirName);
public void setSrcDir(File srcDirName){
_srcDir = srcDirName;
}

@@ -293,15 +293,14 @@ public class Ilasm
* output file. If not supplied this is derived from the
* source file
*/
protected String _outputFile;
protected File _outputFile;
/**
* Set the definitions
* @param list of definitions split by ; or , or even :
*/
public void setOutputFile(String params) {
_outputFile=params;
public void setOutputFile(File params) {
_outputFile = params;
}
/**
@@ -311,7 +310,7 @@ public class Ilasm
protected String getOutputFileParameter() {
if (_outputFile==null || _outputFile.length()==0)
return null;
File f=project.resolveFile(_outputFile);
File f = _outputFile;
return "/output="+f.toString();
}
@@ -322,8 +321,8 @@ public class Ilasm
/**
* Set the resource file
* @param fileName path to the file. Can be relative, absolute, whatever.
*/public void setResourceFile(String fileName) {
_resourceFile = project.resolveFile(fileName);
*/public void setResourceFile(File fileName) {
_resourceFile = fileName;
}
protected String getResourceFileParameter() {


Loading…
Cancel
Save