Files from Strings git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269286 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -152,14 +152,18 @@ public class AntClassLoader extends ClassLoader { | |||||
| URL url = null; | URL url = null; | ||||
| while ((this.pathElementsIndex < this.pathElements.length) && | while ((this.pathElementsIndex < this.pathElements.length) && | ||||
| (url == null)) { | (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; | this.nextResource = url; | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| @@ -386,8 +390,13 @@ public class AntClassLoader extends ClassLoader { | |||||
| String[] pathElements = classpath.list(); | String[] pathElements = classpath.list(); | ||||
| for (int i = 0; i < pathElements.length && stream == null; ++i) { | 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; | return stream; | ||||
| @@ -598,7 +598,7 @@ public class Project { | |||||
| if (part.equals("..")) { | if (part.equals("..")) { | ||||
| String parentFile = file.getParent(); | String parentFile = file.getParent(); | ||||
| if (parentFile == null) { | 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); | file = new File(parentFile); | ||||
| } else if (part.equals(".")) { | } else if (part.equals(".")) { | ||||
| @@ -72,12 +72,12 @@ public class GZip extends Task { | |||||
| private File zipFile; | private File zipFile; | ||||
| private File source; | 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 { | public void execute() throws BuildException { | ||||
| @@ -115,15 +115,15 @@ public class KeySubst extends Task { | |||||
| /** | /** | ||||
| Set the source file. | 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. | Set the destination file. | ||||
| */ | */ | ||||
| public void setDest(String dest) { | |||||
| this.dest = project.resolveFile(dest); | |||||
| public void setDest(File dest) { | |||||
| this.dest = dest; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -77,16 +77,16 @@ public class Rename extends Task { | |||||
| * Sets the file to be renamed. | * Sets the file to be renamed. | ||||
| * @param src the file to rename | * @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. | * Sets the new name of the file. | ||||
| * @param dest 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; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -411,8 +411,8 @@ public class Replace extends MatchingTask { | |||||
| /** | /** | ||||
| * Sets a file to be searched for property values. | * 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; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -66,8 +66,8 @@ import java.io.*; | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| */ | */ | ||||
| public class Untar extends Task { | public class Untar extends Task { | ||||
| private String dest; // req | |||||
| private String source; // req | |||||
| private File dest; // req | |||||
| private File source; // req | |||||
| /** | /** | ||||
| * Do the work. | * Do the work. | ||||
| @@ -81,7 +81,7 @@ public class Untar extends Task { | |||||
| touch.setTaskName(getTaskName()); | touch.setTaskName(getTaskName()); | ||||
| touch.setLocation(getLocation()); | touch.setLocation(getLocation()); | ||||
| File srcF=project.resolveFile(source); | |||||
| File srcF = source; | |||||
| TarInputStream tis = null; | TarInputStream tis = null; | ||||
| try { | try { | ||||
| @@ -96,7 +96,7 @@ public class Untar extends Task { | |||||
| if (dest == null) { | if (dest == null) { | ||||
| throw new BuildException("No destination specified", location); | throw new BuildException("No destination specified", location); | ||||
| } | } | ||||
| File dir=project.resolveFile(dest); | |||||
| File dir = dest; | |||||
| log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); | log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); | ||||
| tis = new TarInputStream(new FileInputStream(srcF)); | tis = new TarInputStream(new FileInputStream(srcF)); | ||||
| @@ -154,8 +154,8 @@ public class Untar extends Task { | |||||
| * | * | ||||
| * @param d Path to the directory. | * @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. | * @param s Path to tar-file. | ||||
| */ | */ | ||||
| public void setSrc(String s) { | |||||
| public void setSrc(File s) { | |||||
| this.source = s; | this.source = s; | ||||
| } | } | ||||
| } | } | ||||
| @@ -433,35 +433,5 @@ public class Javah extends Task { | |||||
| log(prefix.toString() + niceClassList.toString(), Project.MSG_VERBOSE); | 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); | |||||
| // } | |||||
| //} | |||||
| } | } | ||||
| @@ -221,8 +221,8 @@ public class NetRexxC extends MatchingTask { | |||||
| * Set the destination directory into which the NetRexx source | * Set the destination directory into which the NetRexx source | ||||
| * files should be copied and then compiled. | * 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. | * 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; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -388,8 +388,8 @@ public class CSharp | |||||
| /** file for generated XML documentation | /** file for generated XML documentation | ||||
| * @param f output file | * @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 | /** 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 | * Set the source dir to find the files to be compiled | ||||
| * @param srcDirName The new SrcDir value | * @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) | /** 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 | * Set the destination dir to find the files to be compiled | ||||
| * @param dirName The new DestDir value | * @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) | /** type of target. Should be one of exe|library|module|winexe|(null) | ||||
| @@ -593,8 +593,8 @@ public class CSharp | |||||
| * Set the win32 icon | * Set the win32 icon | ||||
| * @param fileName path to the file. Can be relative, absolute, whatever. | * @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 | /** output file. If not supplied this is derived from the | ||||
| * source file | * source file | ||||
| */ | */ | ||||
| protected String _outputFile; | |||||
| protected File _outputFile; | |||||
| /** | /** | ||||
| * Set the definitions | * Set the definitions | ||||
| * @param list of definitions split by ; or , or even : | * @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 | /** get the argument or null for no argument needed | ||||
| * @return The OutputFile Parameter to CSC | * @return The OutputFile Parameter to CSC | ||||
| */ | */ | ||||
| protected String getOutputFileParameter() { | protected String getOutputFileParameter() { | ||||
| if (notEmpty(_outputFile)) { | |||||
| File f=project.resolveFile(_outputFile); | |||||
| if (_outputFile != null) { | |||||
| File f = _outputFile; | |||||
| return "/out:"+f.toString(); | return "/out:"+f.toString(); | ||||
| } | } | ||||
| else | else | ||||
| @@ -160,8 +160,8 @@ public class Ilasm | |||||
| * Set the source dir to find the files to be compiled | * Set the source dir to find the files to be compiled | ||||
| * @param srcDirName The new SrcDir value | * @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 | * output file. If not supplied this is derived from the | ||||
| * source file | * source file | ||||
| */ | */ | ||||
| protected String _outputFile; | |||||
| protected File _outputFile; | |||||
| /** | /** | ||||
| * Set the definitions | * Set the definitions | ||||
| * @param list of definitions split by ; or , or even : | * @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() { | protected String getOutputFileParameter() { | ||||
| if (_outputFile==null || _outputFile.length()==0) | if (_outputFile==null || _outputFile.length()==0) | ||||
| return null; | return null; | ||||
| File f=project.resolveFile(_outputFile); | |||||
| File f = _outputFile; | |||||
| return "/output="+f.toString(); | return "/output="+f.toString(); | ||||
| } | } | ||||
| @@ -322,8 +321,8 @@ public class Ilasm | |||||
| /** | /** | ||||
| * Set the resource file | * Set the resource file | ||||
| * @param fileName path to the file. Can be relative, absolute, whatever. | * @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() { | protected String getResourceFileParameter() { | ||||