git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270248 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -8,8 +8,6 @@ | |||
| package org.apache.antlib.xml; | |||
| import java.io.File; | |||
| import java.util.Enumeration; | |||
| import java.util.Vector; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| @@ -19,7 +17,6 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Reference; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * A Task to process via XSLT a set of XML documents. This is useful for | |||
| @@ -56,18 +53,9 @@ public class XSLTProcess | |||
| private boolean m_stylesheetLoaded; | |||
| private boolean m_force; | |||
| private String m_outputtype; | |||
| private FileUtils m_fileUtils; | |||
| private XSLTLiaison m_liaison; | |||
| private String m_processor; | |||
| /** | |||
| * Creates a new XSLTProcess Task. | |||
| */ | |||
| public XSLTProcess() | |||
| { | |||
| m_fileUtils = FileUtils.newFileUtils(); | |||
| }//-- setForce | |||
| /** | |||
| * Set the base directory. | |||
| * | |||
| @@ -21,9 +21,9 @@ import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import java.util.zip.ZipEntry; | |||
| import java.util.zip.ZipFile; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Used to load classes within ant with a different claspath from that used to | |||
| @@ -421,7 +421,7 @@ public class AntClassLoader | |||
| throws TaskException | |||
| { | |||
| File pathComponent | |||
| = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) | |||
| = project != null ? FileUtil.resolveFile( project.getBaseDir(), pathElement ) | |||
| : new File( pathElement ); | |||
| pathComponents.addElement( pathComponent ); | |||
| } | |||
| @@ -8,15 +8,12 @@ | |||
| package org.apache.tools.ant; | |||
| import java.io.File; | |||
| import java.lang.reflect.Modifier; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Central representation of an Ant project. This class defines a Ant project | |||
| @@ -7,10 +7,8 @@ | |||
| */ | |||
| package org.apache.tools.ant; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Base class for components of a project, including tasks and data types. | |||
| @@ -16,7 +16,6 @@ import org.apache.tools.ant.taskdefs.condition.Condition; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Reference; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Will set the given property if the requested resource is available at | |||
| @@ -274,7 +273,6 @@ public class Available | |||
| return false; | |||
| } | |||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| File parent = path.getParentFile(); | |||
| // ** full-pathname specified == parent dir of path in list | |||
| if( parent != null && parent.exists() | |||
| @@ -12,6 +12,7 @@ import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -61,12 +62,6 @@ public class Copy extends Task | |||
| protected Mapper mapperElement = null; | |||
| private Vector filterSets = new Vector(); | |||
| private FileUtils fileUtils; | |||
| public Copy() | |||
| { | |||
| fileUtils = FileUtils.newFileUtils(); | |||
| } | |||
| /** | |||
| * Sets a single source file to copy. | |||
| @@ -277,11 +272,6 @@ public class Copy extends Task | |||
| } | |||
| } | |||
| protected FileUtils getFileUtils() | |||
| { | |||
| return fileUtils; | |||
| } | |||
| /** | |||
| * Get the filtersets being applied to this operation. | |||
| * | |||
| @@ -335,8 +325,8 @@ public class Copy extends Task | |||
| if( fileCopyMap.size() > 0 ) | |||
| { | |||
| getLogger().info( "Copying " + fileCopyMap.size() + | |||
| " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| Enumeration e = fileCopyMap.keys(); | |||
| while( e.hasMoreElements() ) | |||
| @@ -363,8 +353,17 @@ public class Copy extends Task | |||
| { | |||
| executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() ); | |||
| } | |||
| fileUtils.copyFile( fromFile, toFile, executionFilters, | |||
| forceOverwrite, preserveLastModified ); | |||
| final File src = new File( fromFile ); | |||
| final File dest = new File( toFile ); | |||
| if( forceOverwrite ) | |||
| { | |||
| FileUtil.forceDelete( dest ); | |||
| } | |||
| FileUtils.newFileUtils().copyFile( src, dest, executionFilters ); | |||
| if( preserveLastModified ) | |||
| { | |||
| dest.setLastModified( src.lastModified() ); | |||
| } | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| @@ -398,9 +397,9 @@ public class Copy extends Task | |||
| if( count > 0 ) | |||
| { | |||
| getLogger().info( "Copied " + count + | |||
| " empty director" + | |||
| ( count == 1 ? "y" : "ies" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| " empty director" + | |||
| ( count == 1 ? "y" : "ies" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| } | |||
| } | |||
| } | |||
| @@ -17,12 +17,12 @@ import java.util.Date; | |||
| import java.util.Vector; | |||
| import java.util.zip.ZipEntry; | |||
| import java.util.zip.ZipInputStream; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Unzip a file. | |||
| @@ -115,8 +115,6 @@ public class Expand extends MatchingTask | |||
| throw new TaskException( "Dest must be a directory." ); | |||
| } | |||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| if( source != null ) | |||
| { | |||
| if( source.isDirectory() ) | |||
| @@ -126,7 +124,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| else | |||
| { | |||
| expandFile( fileUtils, source, dest ); | |||
| expandFile( source, dest ); | |||
| } | |||
| } | |||
| if( filesets.size() > 0 ) | |||
| @@ -141,7 +139,7 @@ public class Expand extends MatchingTask | |||
| for( int i = 0; i < files.length; ++i ) | |||
| { | |||
| File file = new File( fromDir, files[ i ] ); | |||
| expandFile( fileUtils, file, dest ); | |||
| expandFile( file, dest ); | |||
| } | |||
| } | |||
| } | |||
| @@ -150,7 +148,7 @@ public class Expand extends MatchingTask | |||
| /* | |||
| * This method is to be overridden by extending unarchival tasks. | |||
| */ | |||
| protected void expandFile( FileUtils fileUtils, File srcF, File dir ) | |||
| protected void expandFile( File srcF, File dir ) | |||
| throws TaskException | |||
| { | |||
| ZipInputStream zis = null; | |||
| @@ -162,7 +160,7 @@ public class Expand extends MatchingTask | |||
| while( ( ze = zis.getNextEntry() ) != null ) | |||
| { | |||
| extractFile( fileUtils, srcF, dir, zis, | |||
| extractFile( srcF, dir, zis, | |||
| ze.getName(), | |||
| new Date( ze.getTime() ), | |||
| ze.isDirectory() ); | |||
| @@ -189,7 +187,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| } | |||
| protected void extractFile( FileUtils fileUtils, File srcF, File dir, | |||
| protected void extractFile( File srcF, File dir, | |||
| InputStream compressedInputStream, | |||
| String entryName, | |||
| Date entryDate, boolean isDirectory ) | |||
| @@ -237,7 +235,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| } | |||
| File f = fileUtils.resolveFile( dir, entryName ); | |||
| File f = FileUtil.resolveFile( dir, entryName ); | |||
| try | |||
| { | |||
| if( !overwrite && f.exists() | |||
| @@ -101,8 +101,6 @@ public class FixCRLF extends MatchingTask | |||
| private boolean javafiles = false; | |||
| private File destDir = null; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| /** | |||
| * Encoding to assume for the files | |||
| */ | |||
| @@ -578,7 +576,7 @@ public class FixCRLF extends MatchingTask | |||
| // Set up the output Writer | |||
| try | |||
| { | |||
| tmpFile = fileUtils.createTempFile( "fixcrlf", "", destD ); | |||
| tmpFile = File.createTempFile( "fixcrlf", "", destD ); | |||
| Writer writer = ( encoding == null ) ? new FileWriter( tmpFile ) | |||
| : new OutputStreamWriter( new FileOutputStream( tmpFile ), encoding ); | |||
| outWriter = new BufferedWriter( writer ); | |||
| @@ -761,7 +759,7 @@ public class FixCRLF extends MatchingTask | |||
| { | |||
| // Compare the destination with the temp file | |||
| log( "destFile exists", Project.MSG_DEBUG ); | |||
| if( !fileUtils.contentEquals( destFile, tmpFile ) ) | |||
| if( !FileUtils.newFileUtils().contentEquals( destFile, tmpFile ) ) | |||
| { | |||
| log( destFile + " is being written", Project.MSG_DEBUG ); | |||
| if( !destFile.delete() ) | |||
| @@ -21,8 +21,8 @@ import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.PumpStreamHandler; | |||
| import org.apache.tools.ant.taskdefs.exec.LogOutputStream; | |||
| import org.apache.tools.ant.taskdefs.exec.PumpStreamHandler; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| @@ -95,8 +95,6 @@ public class Javadoc extends Task | |||
| private boolean useExternalFile = false; | |||
| private File tmpList = null; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| public void setAccess( AccessType at ) | |||
| { | |||
| cmd.createArgument().setValue( "-" + at.getValue() ); | |||
| @@ -873,7 +871,7 @@ public class Javadoc extends Task | |||
| { | |||
| if( tmpList == null ) | |||
| { | |||
| tmpList = fileUtils.createTempFile( "javadoc", "", null ); | |||
| tmpList = File.createTempFile( "javadoc", "", getBaseDirectory() ); | |||
| toExecute.createArgument().setValue( "@" + tmpList.getAbsolutePath() ); | |||
| } | |||
| srcListWriter = new PrintWriter( new FileWriter( tmpList.getAbsolutePath(), | |||
| @@ -1122,7 +1120,7 @@ public class Javadoc extends Task | |||
| { | |||
| if( useExternalFile ) | |||
| { | |||
| tmpList = fileUtils.createTempFile( "javadoc", "", null ); | |||
| tmpList = File.createTempFile( "javadoc", "", getBaseDirectory() ); | |||
| toExecute.createArgument().setValue( "@" + tmpList.getAbsolutePath() ); | |||
| packageListWriter = new PrintWriter( new FileWriter( tmpList ) ); | |||
| } | |||
| @@ -10,8 +10,10 @@ package org.apache.tools.ant.taskdefs; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| @@ -106,7 +108,7 @@ public class Move extends Copy | |||
| if( fileCopyMap.size() > 0 ) | |||
| {// files to move | |||
| getLogger().info( "Moving " + fileCopyMap.size() + " files to " + | |||
| destDir.getAbsolutePath() ); | |||
| destDir.getAbsolutePath() ); | |||
| Enumeration e = fileCopyMap.keys(); | |||
| while( e.hasMoreElements() ) | |||
| @@ -156,8 +158,12 @@ public class Move extends Copy | |||
| { | |||
| executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() ); | |||
| } | |||
| getFileUtils().copyFile( f, d, executionFilters, | |||
| forceOverwrite ); | |||
| if( forceOverwrite ) | |||
| { | |||
| FileUtil.forceDelete( d ); | |||
| } | |||
| FileUtils.newFileUtils().copyFile( f, d, executionFilters ); | |||
| f = new File( fromFile ); | |||
| if( !f.delete() ) | |||
| @@ -55,8 +55,6 @@ public class Replace extends MatchingTask | |||
| */ | |||
| private String encoding = null; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| private int fileCount; | |||
| private int replaceCount; | |||
| @@ -295,8 +293,15 @@ public class Replace extends MatchingTask | |||
| throw new TaskException( "Replace: source file " + src.getPath() + " doesn't exist" ); | |||
| } | |||
| File temp = fileUtils.createTempFile( "rep", ".tmp", | |||
| src.getParentFile() ); | |||
| File temp = null; | |||
| try | |||
| { | |||
| temp = File.createTempFile( "rep", ".tmp", src.getParentFile() ); | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| throw new TaskException( ioe.toString(), ioe ); | |||
| } | |||
| Reader reader = null; | |||
| Writer writer = null; | |||
| @@ -11,6 +11,7 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import java.rmi.Remote; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.AntClassLoader; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| @@ -688,7 +689,7 @@ public class Rmic extends MatchingTask | |||
| } | |||
| else | |||
| { | |||
| FileUtils.newFileUtils().copyFile( oldFile, newFile ); | |||
| FileUtil.copyFile( oldFile, newFile ); | |||
| } | |||
| oldFile.delete(); | |||
| } | |||
| @@ -19,7 +19,6 @@ import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Touch a file and/or fileset(s) -- corresponds to the Unix touch command. <p> | |||
| @@ -39,12 +38,6 @@ public class Touch extends Task | |||
| private String dateTime; | |||
| private File file; | |||
| private FileUtils fileUtils; | |||
| public Touch() | |||
| { | |||
| fileUtils = FileUtils.newFileUtils(); | |||
| } | |||
| /** | |||
| * Date in the format MM/DD/YYYY HH:MM AM_PM. | |||
| @@ -12,7 +12,6 @@ import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.tar.TarEntry; | |||
| import org.apache.tools.tar.TarInputStream; | |||
| @@ -25,7 +24,7 @@ import org.apache.tools.tar.TarInputStream; | |||
| public class Untar extends Expand | |||
| { | |||
| protected void expandFile( FileUtils fileUtils, File srcF, File dir ) | |||
| protected void expandFile( File srcF, File dir ) | |||
| throws TaskException | |||
| { | |||
| TarInputStream tis = null; | |||
| @@ -38,7 +37,7 @@ public class Untar extends Expand | |||
| while( ( te = tis.getNextEntry() ) != null ) | |||
| { | |||
| extractFile( fileUtils, srcF, dir, tis, | |||
| extractFile( srcF, dir, tis, | |||
| te.getName(), | |||
| te.getModTime(), te.isDirectory() ); | |||
| } | |||
| @@ -28,7 +28,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.ZipFileSet; | |||
| import org.apache.tools.ant.types.ZipScanner; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.MergingMapper; | |||
| import org.apache.tools.ant.util.SourceFileScanner; | |||
| import org.apache.tools.zip.ZipEntry; | |||
| @@ -235,9 +234,15 @@ public class Zip extends MatchingTask | |||
| doUpdate = doUpdate && zipFile.exists(); | |||
| if( doUpdate ) | |||
| { | |||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| renamedFile = fileUtils.createTempFile( "zip", ".tmp", | |||
| zipFile.getParentFile() ); | |||
| try | |||
| { | |||
| renamedFile = File.createTempFile( "zip", ".tmp", | |||
| zipFile.getParentFile() ); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| throw new TaskException( ioe.toString(), ioe ); | |||
| } | |||
| try | |||
| { | |||
| @@ -13,12 +13,11 @@ import java.io.IOException; | |||
| import java.io.PrintWriter; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.Javac; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * This is the default implementation for the CompilerAdapter interface. | |||
| @@ -39,7 +38,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||
| protected boolean depend = false; | |||
| protected boolean verbose = false; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| protected Javac attributes; | |||
| protected Path bootclasspath; | |||
| protected Path compileClasspath; | |||
| @@ -400,7 +398,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||
| PrintWriter out = null; | |||
| try | |||
| { | |||
| tmpFile = fileUtils.createTempFile( "jikes", "", null ); | |||
| tmpFile = File.createTempFile( "jikes", "", new File( "." ) ); | |||
| out = new PrintWriter( new FileWriter( tmpFile ) ); | |||
| for( int i = firstFileName; i < args.length; i++ ) | |||
| { | |||
| @@ -16,12 +16,12 @@ import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| import java.util.Locale; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Runs an external program. | |||
| @@ -817,7 +817,7 @@ public class Execute | |||
| { | |||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | |||
| } | |||
| String antRun = FileUtils.newFileUtils(). | |||
| String antRun = FileUtil. | |||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||
| // Build the command | |||
| @@ -883,7 +883,7 @@ public class Execute | |||
| { | |||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | |||
| } | |||
| String antRun = FileUtils.newFileUtils(). | |||
| String antRun = FileUtil. | |||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||
| // Build the command | |||
| @@ -18,11 +18,9 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecTask; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecTask; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Create a CAB archive. | |||
| @@ -39,7 +37,6 @@ public class Cab extends MatchingTask | |||
| protected String archiveType = "cab"; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| private File baseDir; | |||
| private File cabFile; | |||
| @@ -161,7 +158,7 @@ public class Cab extends MatchingTask | |||
| if( !doVerbose ) | |||
| { | |||
| outFile = fileUtils.createTempFile( "ant", "", null ); | |||
| outFile = File.createTempFile( "ant", "", getBaseDirectory() ); | |||
| exec.setOutput( outFile ); | |||
| } | |||
| @@ -327,7 +324,7 @@ public class Cab extends MatchingTask | |||
| protected File createListFile( Vector files ) | |||
| throws IOException | |||
| { | |||
| File listFile = fileUtils.createTempFile( "ant", "", null ); | |||
| File listFile = File.createTempFile( "ant", "", getBaseDirectory() ); | |||
| PrintWriter writer = new PrintWriter( new FileOutputStream( listFile ) ); | |||
| @@ -17,11 +17,11 @@ import java.util.Properties; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| import netrexx.lang.Rexx; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Task to compile NetRexx source files. This task can take the following | |||
| @@ -501,8 +501,8 @@ public class NetRexxC extends MatchingTask | |||
| if( compileList.size() > 0 ) | |||
| { | |||
| getLogger().info( "Compiling " + compileList.size() + " source file" | |||
| + ( compileList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir ); | |||
| + ( compileList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir ); | |||
| doNetRexxCompile(); | |||
| } | |||
| } | |||
| @@ -611,8 +611,8 @@ public class NetRexxC extends MatchingTask | |||
| if( filecopyList.size() > 0 ) | |||
| { | |||
| getLogger().info( "Copying " + filecopyList.size() + " file" | |||
| + ( filecopyList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir.getAbsolutePath() ); | |||
| + ( filecopyList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir.getAbsolutePath() ); | |||
| Enumeration enum = filecopyList.keys(); | |||
| while( enum.hasMoreElements() ) | |||
| { | |||
| @@ -620,7 +620,7 @@ public class NetRexxC extends MatchingTask | |||
| String toFile = (String)filecopyList.get( fromFile ); | |||
| try | |||
| { | |||
| FileUtils.newFileUtils().copyFile( fromFile, toFile ); | |||
| FileUtil.copyFile( new File( fromFile ), new File( toFile ) ); | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| @@ -23,7 +23,6 @@ import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.RegularExpression; | |||
| import org.apache.tools.ant.types.Substitution; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.regexp.Regexp; | |||
| /** | |||
| @@ -73,8 +72,6 @@ import org.apache.tools.ant.util.regexp.Regexp; | |||
| */ | |||
| public class ReplaceRegExp extends Task | |||
| { | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| private boolean byline; | |||
| private File file; | |||
| @@ -263,7 +260,7 @@ public class ReplaceRegExp extends Task | |||
| throws IOException, TaskException | |||
| { | |||
| File parentDir = new File( new File( f.getAbsolutePath() ).getParent() ); | |||
| File temp = fileUtils.createTempFile( "replace", ".txt", parentDir ); | |||
| File temp = File.createTempFile( "replace", ".txt", parentDir ); | |||
| FileReader r = null; | |||
| FileWriter w = null; | |||
| @@ -20,12 +20,12 @@ import java.util.jar.JarFile; | |||
| import java.util.jar.JarOutputStream; | |||
| import javax.xml.parsers.SAXParser; | |||
| import javax.xml.parsers.SAXParserFactory; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.AntClassLoader; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.xml.sax.InputSource; | |||
| public class WeblogicDeploymentTool extends GenericDeploymentTool | |||
| @@ -755,7 +755,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||
| { | |||
| try | |||
| { | |||
| FileUtils.newFileUtils().copyFile( sourceJar, destJar ); | |||
| FileUtil.copyFile( sourceJar, destJar ); | |||
| if( !keepgenerated ) | |||
| { | |||
| sourceJar.delete(); | |||
| @@ -18,12 +18,12 @@ import java.io.OutputStreamWriter; | |||
| import java.util.Hashtable; | |||
| import java.util.Locale; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Translates text embedded in files using Resource Bundle files. | |||
| @@ -40,10 +40,6 @@ public class Translate extends MatchingTask | |||
| * Holds key value pairs loaded from resource bundle file | |||
| */ | |||
| private Hashtable resourceMap = new Hashtable(); | |||
| /** | |||
| * Used to resolve file names. | |||
| */ | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| /** | |||
| * Last Modified Timestamp of resource bundle file being used. | |||
| */ | |||
| @@ -528,7 +524,7 @@ public class Translate extends MatchingTask | |||
| { | |||
| try | |||
| { | |||
| File dest = fileUtils.resolveFile( toDir, srcFiles[ j ] ); | |||
| File dest = FileUtil.resolveFile( toDir, srcFiles[ j ] ); | |||
| //Make sure parent dirs exist, else, create them. | |||
| try | |||
| { | |||
| @@ -15,11 +15,11 @@ import java.io.InputStream; | |||
| import java.net.URL; | |||
| import javax.xml.parsers.DocumentBuilder; | |||
| import javax.xml.parsers.DocumentBuilderFactory; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.w3c.dom.Document; | |||
| import org.w3c.dom.Element; | |||
| @@ -215,12 +215,11 @@ public class AggregateTransformer | |||
| // set the destination directory relative from the project if needed. | |||
| if( toDir == null ) | |||
| { | |||
| toDir = FileUtils.newFileUtils().resolveFile( task.getBaseDirectory(), "." ); | |||
| toDir = FileUtil.resolveFile( task.getBaseDirectory(), "." ); | |||
| } | |||
| else if( !toDir.isAbsolute() ) | |||
| { | |||
| toDir = FileUtils.newFileUtils(). | |||
| resolveFile( task.getBaseDirectory(), toDir.getPath() ); | |||
| toDir = FileUtil.resolveFile( task.getBaseDirectory(), toDir.getPath() ); | |||
| } | |||
| } | |||
| @@ -17,13 +17,13 @@ import java.util.Enumeration; | |||
| import java.util.Vector; | |||
| import javax.xml.parsers.DocumentBuilder; | |||
| import javax.xml.parsers.DocumentBuilderFactory; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.DOMElementWriter; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.StringUtils; | |||
| import org.w3c.dom.Document; | |||
| import org.w3c.dom.Element; | |||
| @@ -184,7 +184,7 @@ public class XMLResultAggregator extends Task implements XMLConstants | |||
| } | |||
| if( toDir == null ) | |||
| { | |||
| toDir = FileUtils.newFileUtils().resolveFile( project.getBaseDir(), DEFAULT_DIR ); | |||
| toDir = FileUtil.resolveFile( project.getBaseDir(), DEFAULT_DIR ); | |||
| } | |||
| return new File( toDir, toFile ); | |||
| } | |||
| @@ -210,7 +210,7 @@ public class XMLResultAggregator extends Task implements XMLConstants | |||
| if( pathname.endsWith( ".xml" ) ) | |||
| { | |||
| File file = new File( ds.getBasedir(), pathname ); | |||
| file = FileUtils.newFileUtils(). | |||
| file = FileUtil. | |||
| resolveFile( project.getBaseDir(), file.getPath() ); | |||
| v.addElement( file ); | |||
| } | |||
| @@ -12,11 +12,11 @@ import java.util.Enumeration; | |||
| import java.util.Locale; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| 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; | |||
| /** | |||
| * This object represents a path as used by CLASSPATH or PATH environment | |||
| @@ -196,8 +196,7 @@ public class Path | |||
| { | |||
| if( project != null ) | |||
| { | |||
| File f = FileUtils.newFileUtils(). | |||
| resolveFile( project.getBaseDir(), relativeName ); | |||
| File f = FileUtil.resolveFile( project.getBaseDir(), relativeName ); | |||
| return f.getAbsolutePath(); | |||
| } | |||
| return relativeName; | |||
| @@ -17,8 +17,6 @@ import java.io.FileReader; | |||
| import java.io.FileWriter; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.text.DecimalFormat; | |||
| import java.util.Random; | |||
| import java.util.Stack; | |||
| import java.util.StringTokenizer; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| @@ -37,15 +35,6 @@ import org.apache.tools.ant.types.FilterSetCollection; | |||
| public class FileUtils | |||
| { | |||
| private static Random rand = new Random( System.currentTimeMillis() ); | |||
| /** | |||
| * Empty constructor. | |||
| */ | |||
| private FileUtils() | |||
| { | |||
| } | |||
| /** | |||
| * Factory method. | |||
| * | |||
| @@ -132,54 +121,6 @@ public class FileUtils | |||
| } | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination. No | |||
| * filtering is performed. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), null, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile, FilterSetCollection filters ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), filters, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used and if source files may | |||
| * overwrite newer destination files. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @param overwrite Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, | |||
| boolean overwrite ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), filters, | |||
| overwrite, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used, if source files may overwrite | |||
| @@ -194,84 +135,14 @@ public class FileUtils | |||
| * @param preserveLastModified Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, | |||
| boolean overwrite, boolean preserveLastModified ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), filters, | |||
| overwrite, preserveLastModified ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination. No | |||
| * filtering is performed. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( sourceFile, destFile, null, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile, FilterSetCollection filters ) | |||
| public void copyFile( File sourceFile, | |||
| File destFile, | |||
| FilterSetCollection filters ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( sourceFile, destFile, filters, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used and if source files may | |||
| * overwrite newer destination files. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @param overwrite Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, | |||
| boolean overwrite ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( sourceFile, destFile, filters, overwrite, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used, if source files may overwrite | |||
| * newer destination files and the last modified time of <code>destFile</code> | |||
| * file should be made equal to the last modified time of <code>sourceFile</code> | |||
| * . | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @param overwrite Description of Parameter | |||
| * @param preserveLastModified Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, | |||
| boolean overwrite, boolean preserveLastModified ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( overwrite || !destFile.exists() || | |||
| if( !destFile.exists() || | |||
| destFile.lastModified() < sourceFile.lastModified() ) | |||
| { | |||
| if( destFile.exists() && destFile.isFile() ) | |||
| { | |||
| destFile.delete(); | |||
| @@ -327,54 +198,9 @@ public class FileUtils | |||
| in.close(); | |||
| out.close(); | |||
| } | |||
| if( preserveLastModified ) | |||
| { | |||
| destFile.setLastModified( sourceFile.lastModified() ); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Create a temporary file in a given directory. <p> | |||
| * | |||
| * The file denoted by the returned abstract pathname did not exist before | |||
| * this method was invoked, any subsequent invocation of this method will | |||
| * yield a different file name.</p> <p> | |||
| * | |||
| * This method is different to File.createTempFile of JDK 1.2 as it doesn't | |||
| * create the file itself and doesn't use platform specific temporary | |||
| * directory when the parentDir attribute is null.</p> | |||
| * | |||
| * @param parentDir Directory to create the temporary file in - current | |||
| * working directory will be assumed if this parameter is null. | |||
| * @param prefix Description of Parameter | |||
| * @param suffix Description of Parameter | |||
| * @return Description of the Returned Value | |||
| * @since 1.8 | |||
| */ | |||
| public File createTempFile( String prefix, String suffix, File parentDir ) | |||
| { | |||
| File result = null; | |||
| String parent = null; | |||
| if( parentDir != null ) | |||
| { | |||
| parent = parentDir.getPath(); | |||
| } | |||
| DecimalFormat fmt = new DecimalFormat( "#####" ); | |||
| synchronized( rand ) | |||
| { | |||
| do | |||
| { | |||
| result = new File( parent, | |||
| prefix + fmt.format( rand.nextInt() ) | |||
| + suffix ); | |||
| } while( result.exists() ); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| * "normalize" the given absolute path. <p> | |||
| * | |||
| @@ -514,68 +340,5 @@ public class FileUtils | |||
| } | |||
| return new File( path ); | |||
| } | |||
| /** | |||
| * Interpret the filename as a file relative to the given file - unless the | |||
| * filename already represents an absolute filename. | |||
| * | |||
| * @param file the "reference" file for relative paths. This instance must | |||
| * be an absolute file and must not contain "./" or | |||
| * "../" sequences (same for \ instead of /). If it is null, | |||
| * this call is equivalent to <code>new java.io.File(filename)</code>. | |||
| * @param filename a file name | |||
| * @return an absolute file that doesn't contain "./" or | |||
| * "../" sequences and uses the correct separator for the | |||
| * current platform. | |||
| */ | |||
| public File resolveFile( File file, String filename ) | |||
| throws TaskException | |||
| { | |||
| filename = filename.replace( '/', File.separatorChar ) | |||
| .replace( '\\', File.separatorChar ); | |||
| // deal with absolute files | |||
| if( filename.startsWith( File.separator ) || | |||
| ( filename.length() >= 2 && | |||
| Character.isLetter( filename.charAt( 0 ) ) && | |||
| filename.charAt( 1 ) == ':' ) | |||
| ) | |||
| { | |||
| return normalize( filename ); | |||
| } | |||
| if( file == null ) | |||
| { | |||
| return new File( filename ); | |||
| } | |||
| File helpFile = new File( file.getAbsolutePath() ); | |||
| StringTokenizer tok = new StringTokenizer( filename, File.separator ); | |||
| while( tok.hasMoreTokens() ) | |||
| { | |||
| String part = tok.nextToken(); | |||
| if( part.equals( ".." ) ) | |||
| { | |||
| helpFile = helpFile.getParentFile(); | |||
| if( helpFile == null ) | |||
| { | |||
| String msg = "The file or path you specified (" | |||
| + filename + ") is invalid relative to " | |||
| + file.getPath(); | |||
| throw new TaskException( msg ); | |||
| } | |||
| } | |||
| else if( part.equals( "." ) ) | |||
| { | |||
| // Do nothing here | |||
| } | |||
| else | |||
| { | |||
| helpFile = new File( helpFile, part ); | |||
| } | |||
| } | |||
| return new File( helpFile.getAbsolutePath() ); | |||
| } | |||
| } | |||
| @@ -13,6 +13,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| /** | |||
| * Utility class that collects the functionality of the various scanDir methods | |||
| @@ -26,18 +27,14 @@ import org.apache.tools.ant.Task; | |||
| */ | |||
| public class SourceFileScanner | |||
| { | |||
| protected Task task; | |||
| private FileUtils fileUtils; | |||
| private Task m_task; | |||
| /** | |||
| * @param task The task we should log messages through | |||
| */ | |||
| public SourceFileScanner( Task task ) | |||
| { | |||
| this.task = task; | |||
| fileUtils = FileUtils.newFileUtils(); | |||
| this.m_task = task; | |||
| } | |||
| /** | |||
| @@ -80,16 +77,16 @@ public class SourceFileScanner | |||
| String[] targets = mapper.mapFileName( files[ i ] ); | |||
| if( targets == null || targets.length == 0 ) | |||
| { | |||
| task.log( files[ i ] + " skipped - don\'t know how to handle it", | |||
| m_task.log( files[ i ] + " skipped - don\'t know how to handle it", | |||
| Project.MSG_VERBOSE ); | |||
| continue; | |||
| } | |||
| File src = fileUtils.resolveFile( srcDir, files[ i ] ); | |||
| File src = FileUtil.resolveFile( srcDir, files[ i ] ); | |||
| if( src.lastModified() > now ) | |||
| { | |||
| task.log( "Warning: " + files[ i ] + " modified in the future.", | |||
| m_task.log( "Warning: " + files[ i ] + " modified in the future.", | |||
| Project.MSG_WARN ); | |||
| } | |||
| @@ -97,18 +94,18 @@ public class SourceFileScanner | |||
| targetList.setLength( 0 ); | |||
| for( int j = 0; !added && j < targets.length; j++ ) | |||
| { | |||
| File dest = fileUtils.resolveFile( destDir, targets[ j ] ); | |||
| File dest = FileUtil.resolveFile( destDir, targets[ j ] ); | |||
| if( !dest.exists() ) | |||
| { | |||
| task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", | |||
| Project.MSG_VERBOSE ); | |||
| v.addElement( files[ i ] ); | |||
| added = true; | |||
| } | |||
| else if( src.lastModified() > dest.lastModified() ) | |||
| { | |||
| task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", | |||
| Project.MSG_VERBOSE ); | |||
| v.addElement( files[ i ] ); | |||
| added = true; | |||
| @@ -125,7 +122,7 @@ public class SourceFileScanner | |||
| if( !added ) | |||
| { | |||
| task.log( files[ i ] + " omitted as " + targetList.toString() | |||
| m_task.log( files[ i ] + " omitted as " + targetList.toString() | |||
| + ( targets.length == 1 ? " is" : " are " ) | |||
| + " up to date.", Project.MSG_VERBOSE ); | |||
| } | |||
| @@ -21,9 +21,9 @@ import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import java.util.zip.ZipEntry; | |||
| import java.util.zip.ZipFile; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Used to load classes within ant with a different claspath from that used to | |||
| @@ -421,7 +421,7 @@ public class AntClassLoader | |||
| throws TaskException | |||
| { | |||
| File pathComponent | |||
| = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) | |||
| = project != null ? FileUtil.resolveFile( project.getBaseDir(), pathElement ) | |||
| : new File( pathElement ); | |||
| pathComponents.addElement( pathComponent ); | |||
| } | |||
| @@ -8,15 +8,12 @@ | |||
| package org.apache.tools.ant; | |||
| import java.io.File; | |||
| import java.lang.reflect.Modifier; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Central representation of an Ant project. This class defines a Ant project | |||
| @@ -7,10 +7,8 @@ | |||
| */ | |||
| package org.apache.tools.ant; | |||
| import java.io.File; | |||
| import org.apache.myrmidon.api.AbstractTask; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Base class for components of a project, including tasks and data types. | |||
| @@ -16,7 +16,6 @@ import org.apache.tools.ant.taskdefs.condition.Condition; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Reference; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Will set the given property if the requested resource is available at | |||
| @@ -274,7 +273,6 @@ public class Available | |||
| return false; | |||
| } | |||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| File parent = path.getParentFile(); | |||
| // ** full-pathname specified == parent dir of path in list | |||
| if( parent != null && parent.exists() | |||
| @@ -12,6 +12,7 @@ import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import java.util.Hashtable; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| @@ -61,12 +62,6 @@ public class Copy extends Task | |||
| protected Mapper mapperElement = null; | |||
| private Vector filterSets = new Vector(); | |||
| private FileUtils fileUtils; | |||
| public Copy() | |||
| { | |||
| fileUtils = FileUtils.newFileUtils(); | |||
| } | |||
| /** | |||
| * Sets a single source file to copy. | |||
| @@ -277,11 +272,6 @@ public class Copy extends Task | |||
| } | |||
| } | |||
| protected FileUtils getFileUtils() | |||
| { | |||
| return fileUtils; | |||
| } | |||
| /** | |||
| * Get the filtersets being applied to this operation. | |||
| * | |||
| @@ -335,8 +325,8 @@ public class Copy extends Task | |||
| if( fileCopyMap.size() > 0 ) | |||
| { | |||
| getLogger().info( "Copying " + fileCopyMap.size() + | |||
| " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| Enumeration e = fileCopyMap.keys(); | |||
| while( e.hasMoreElements() ) | |||
| @@ -363,8 +353,17 @@ public class Copy extends Task | |||
| { | |||
| executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() ); | |||
| } | |||
| fileUtils.copyFile( fromFile, toFile, executionFilters, | |||
| forceOverwrite, preserveLastModified ); | |||
| final File src = new File( fromFile ); | |||
| final File dest = new File( toFile ); | |||
| if( forceOverwrite ) | |||
| { | |||
| FileUtil.forceDelete( dest ); | |||
| } | |||
| FileUtils.newFileUtils().copyFile( src, dest, executionFilters ); | |||
| if( preserveLastModified ) | |||
| { | |||
| dest.setLastModified( src.lastModified() ); | |||
| } | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| @@ -398,9 +397,9 @@ public class Copy extends Task | |||
| if( count > 0 ) | |||
| { | |||
| getLogger().info( "Copied " + count + | |||
| " empty director" + | |||
| ( count == 1 ? "y" : "ies" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| " empty director" + | |||
| ( count == 1 ? "y" : "ies" ) + | |||
| " to " + destDir.getAbsolutePath() ); | |||
| } | |||
| } | |||
| } | |||
| @@ -17,12 +17,12 @@ import java.util.Date; | |||
| import java.util.Vector; | |||
| import java.util.zip.ZipEntry; | |||
| import java.util.zip.ZipInputStream; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Unzip a file. | |||
| @@ -115,8 +115,6 @@ public class Expand extends MatchingTask | |||
| throw new TaskException( "Dest must be a directory." ); | |||
| } | |||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| if( source != null ) | |||
| { | |||
| if( source.isDirectory() ) | |||
| @@ -126,7 +124,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| else | |||
| { | |||
| expandFile( fileUtils, source, dest ); | |||
| expandFile( source, dest ); | |||
| } | |||
| } | |||
| if( filesets.size() > 0 ) | |||
| @@ -141,7 +139,7 @@ public class Expand extends MatchingTask | |||
| for( int i = 0; i < files.length; ++i ) | |||
| { | |||
| File file = new File( fromDir, files[ i ] ); | |||
| expandFile( fileUtils, file, dest ); | |||
| expandFile( file, dest ); | |||
| } | |||
| } | |||
| } | |||
| @@ -150,7 +148,7 @@ public class Expand extends MatchingTask | |||
| /* | |||
| * This method is to be overridden by extending unarchival tasks. | |||
| */ | |||
| protected void expandFile( FileUtils fileUtils, File srcF, File dir ) | |||
| protected void expandFile( File srcF, File dir ) | |||
| throws TaskException | |||
| { | |||
| ZipInputStream zis = null; | |||
| @@ -162,7 +160,7 @@ public class Expand extends MatchingTask | |||
| while( ( ze = zis.getNextEntry() ) != null ) | |||
| { | |||
| extractFile( fileUtils, srcF, dir, zis, | |||
| extractFile( srcF, dir, zis, | |||
| ze.getName(), | |||
| new Date( ze.getTime() ), | |||
| ze.isDirectory() ); | |||
| @@ -189,7 +187,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| } | |||
| protected void extractFile( FileUtils fileUtils, File srcF, File dir, | |||
| protected void extractFile( File srcF, File dir, | |||
| InputStream compressedInputStream, | |||
| String entryName, | |||
| Date entryDate, boolean isDirectory ) | |||
| @@ -237,7 +235,7 @@ public class Expand extends MatchingTask | |||
| } | |||
| } | |||
| File f = fileUtils.resolveFile( dir, entryName ); | |||
| File f = FileUtil.resolveFile( dir, entryName ); | |||
| try | |||
| { | |||
| if( !overwrite && f.exists() | |||
| @@ -101,8 +101,6 @@ public class FixCRLF extends MatchingTask | |||
| private boolean javafiles = false; | |||
| private File destDir = null; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| /** | |||
| * Encoding to assume for the files | |||
| */ | |||
| @@ -578,7 +576,7 @@ public class FixCRLF extends MatchingTask | |||
| // Set up the output Writer | |||
| try | |||
| { | |||
| tmpFile = fileUtils.createTempFile( "fixcrlf", "", destD ); | |||
| tmpFile = File.createTempFile( "fixcrlf", "", destD ); | |||
| Writer writer = ( encoding == null ) ? new FileWriter( tmpFile ) | |||
| : new OutputStreamWriter( new FileOutputStream( tmpFile ), encoding ); | |||
| outWriter = new BufferedWriter( writer ); | |||
| @@ -761,7 +759,7 @@ public class FixCRLF extends MatchingTask | |||
| { | |||
| // Compare the destination with the temp file | |||
| log( "destFile exists", Project.MSG_DEBUG ); | |||
| if( !fileUtils.contentEquals( destFile, tmpFile ) ) | |||
| if( !FileUtils.newFileUtils().contentEquals( destFile, tmpFile ) ) | |||
| { | |||
| log( destFile + " is being written", Project.MSG_DEBUG ); | |||
| if( !destFile.delete() ) | |||
| @@ -21,8 +21,8 @@ import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.PumpStreamHandler; | |||
| import org.apache.tools.ant.taskdefs.exec.LogOutputStream; | |||
| import org.apache.tools.ant.taskdefs.exec.PumpStreamHandler; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| @@ -95,8 +95,6 @@ public class Javadoc extends Task | |||
| private boolean useExternalFile = false; | |||
| private File tmpList = null; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| public void setAccess( AccessType at ) | |||
| { | |||
| cmd.createArgument().setValue( "-" + at.getValue() ); | |||
| @@ -873,7 +871,7 @@ public class Javadoc extends Task | |||
| { | |||
| if( tmpList == null ) | |||
| { | |||
| tmpList = fileUtils.createTempFile( "javadoc", "", null ); | |||
| tmpList = File.createTempFile( "javadoc", "", getBaseDirectory() ); | |||
| toExecute.createArgument().setValue( "@" + tmpList.getAbsolutePath() ); | |||
| } | |||
| srcListWriter = new PrintWriter( new FileWriter( tmpList.getAbsolutePath(), | |||
| @@ -1122,7 +1120,7 @@ public class Javadoc extends Task | |||
| { | |||
| if( useExternalFile ) | |||
| { | |||
| tmpList = fileUtils.createTempFile( "javadoc", "", null ); | |||
| tmpList = File.createTempFile( "javadoc", "", getBaseDirectory() ); | |||
| toExecute.createArgument().setValue( "@" + tmpList.getAbsolutePath() ); | |||
| packageListWriter = new PrintWriter( new FileWriter( tmpList ) ); | |||
| } | |||
| @@ -10,8 +10,10 @@ package org.apache.tools.ant.taskdefs; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Enumeration; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.FilterSet; | |||
| import org.apache.tools.ant.types.FilterSetCollection; | |||
| @@ -106,7 +108,7 @@ public class Move extends Copy | |||
| if( fileCopyMap.size() > 0 ) | |||
| {// files to move | |||
| getLogger().info( "Moving " + fileCopyMap.size() + " files to " + | |||
| destDir.getAbsolutePath() ); | |||
| destDir.getAbsolutePath() ); | |||
| Enumeration e = fileCopyMap.keys(); | |||
| while( e.hasMoreElements() ) | |||
| @@ -156,8 +158,12 @@ public class Move extends Copy | |||
| { | |||
| executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() ); | |||
| } | |||
| getFileUtils().copyFile( f, d, executionFilters, | |||
| forceOverwrite ); | |||
| if( forceOverwrite ) | |||
| { | |||
| FileUtil.forceDelete( d ); | |||
| } | |||
| FileUtils.newFileUtils().copyFile( f, d, executionFilters ); | |||
| f = new File( fromFile ); | |||
| if( !f.delete() ) | |||
| @@ -55,8 +55,6 @@ public class Replace extends MatchingTask | |||
| */ | |||
| private String encoding = null; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| private int fileCount; | |||
| private int replaceCount; | |||
| @@ -295,8 +293,15 @@ public class Replace extends MatchingTask | |||
| throw new TaskException( "Replace: source file " + src.getPath() + " doesn't exist" ); | |||
| } | |||
| File temp = fileUtils.createTempFile( "rep", ".tmp", | |||
| src.getParentFile() ); | |||
| File temp = null; | |||
| try | |||
| { | |||
| temp = File.createTempFile( "rep", ".tmp", src.getParentFile() ); | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| throw new TaskException( ioe.toString(), ioe ); | |||
| } | |||
| Reader reader = null; | |||
| Writer writer = null; | |||
| @@ -11,6 +11,7 @@ import java.io.File; | |||
| import java.io.IOException; | |||
| import java.rmi.Remote; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.AntClassLoader; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| @@ -688,7 +689,7 @@ public class Rmic extends MatchingTask | |||
| } | |||
| else | |||
| { | |||
| FileUtils.newFileUtils().copyFile( oldFile, newFile ); | |||
| FileUtil.copyFile( oldFile, newFile ); | |||
| } | |||
| oldFile.delete(); | |||
| } | |||
| @@ -19,7 +19,6 @@ import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Touch a file and/or fileset(s) -- corresponds to the Unix touch command. <p> | |||
| @@ -39,12 +38,6 @@ public class Touch extends Task | |||
| private String dateTime; | |||
| private File file; | |||
| private FileUtils fileUtils; | |||
| public Touch() | |||
| { | |||
| fileUtils = FileUtils.newFileUtils(); | |||
| } | |||
| /** | |||
| * Date in the format MM/DD/YYYY HH:MM AM_PM. | |||
| @@ -12,7 +12,6 @@ import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.tar.TarEntry; | |||
| import org.apache.tools.tar.TarInputStream; | |||
| @@ -25,7 +24,7 @@ import org.apache.tools.tar.TarInputStream; | |||
| public class Untar extends Expand | |||
| { | |||
| protected void expandFile( FileUtils fileUtils, File srcF, File dir ) | |||
| protected void expandFile( File srcF, File dir ) | |||
| throws TaskException | |||
| { | |||
| TarInputStream tis = null; | |||
| @@ -38,7 +37,7 @@ public class Untar extends Expand | |||
| while( ( te = tis.getNextEntry() ) != null ) | |||
| { | |||
| extractFile( fileUtils, srcF, dir, tis, | |||
| extractFile( srcF, dir, tis, | |||
| te.getName(), | |||
| te.getModTime(), te.isDirectory() ); | |||
| } | |||
| @@ -28,7 +28,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.ZipFileSet; | |||
| import org.apache.tools.ant.types.ZipScanner; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.MergingMapper; | |||
| import org.apache.tools.ant.util.SourceFileScanner; | |||
| import org.apache.tools.zip.ZipEntry; | |||
| @@ -235,9 +234,15 @@ public class Zip extends MatchingTask | |||
| doUpdate = doUpdate && zipFile.exists(); | |||
| if( doUpdate ) | |||
| { | |||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| renamedFile = fileUtils.createTempFile( "zip", ".tmp", | |||
| zipFile.getParentFile() ); | |||
| try | |||
| { | |||
| renamedFile = File.createTempFile( "zip", ".tmp", | |||
| zipFile.getParentFile() ); | |||
| } | |||
| catch( final IOException ioe ) | |||
| { | |||
| throw new TaskException( ioe.toString(), ioe ); | |||
| } | |||
| try | |||
| { | |||
| @@ -13,12 +13,11 @@ import java.io.IOException; | |||
| import java.io.PrintWriter; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.Javac; | |||
| import org.apache.tools.ant.taskdefs.exec.Execute; | |||
| import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * This is the default implementation for the CompilerAdapter interface. | |||
| @@ -39,7 +38,6 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||
| protected boolean depend = false; | |||
| protected boolean verbose = false; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| protected Javac attributes; | |||
| protected Path bootclasspath; | |||
| protected Path compileClasspath; | |||
| @@ -400,7 +398,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||
| PrintWriter out = null; | |||
| try | |||
| { | |||
| tmpFile = fileUtils.createTempFile( "jikes", "", null ); | |||
| tmpFile = File.createTempFile( "jikes", "", new File( "." ) ); | |||
| out = new PrintWriter( new FileWriter( tmpFile ) ); | |||
| for( int i = firstFileName; i < args.length; i++ ) | |||
| { | |||
| @@ -16,12 +16,12 @@ import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| import java.util.Locale; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Runs an external program. | |||
| @@ -817,7 +817,7 @@ public class Execute | |||
| { | |||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | |||
| } | |||
| String antRun = FileUtils.newFileUtils(). | |||
| String antRun = FileUtil. | |||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||
| // Build the command | |||
| @@ -883,7 +883,7 @@ public class Execute | |||
| { | |||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | |||
| } | |||
| String antRun = FileUtils.newFileUtils(). | |||
| String antRun = FileUtil. | |||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||
| // Build the command | |||
| @@ -18,11 +18,9 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecTask; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.taskdefs.exec.ExecTask; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Create a CAB archive. | |||
| @@ -39,7 +37,6 @@ public class Cab extends MatchingTask | |||
| protected String archiveType = "cab"; | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| private File baseDir; | |||
| private File cabFile; | |||
| @@ -161,7 +158,7 @@ public class Cab extends MatchingTask | |||
| if( !doVerbose ) | |||
| { | |||
| outFile = fileUtils.createTempFile( "ant", "", null ); | |||
| outFile = File.createTempFile( "ant", "", getBaseDirectory() ); | |||
| exec.setOutput( outFile ); | |||
| } | |||
| @@ -327,7 +324,7 @@ public class Cab extends MatchingTask | |||
| protected File createListFile( Vector files ) | |||
| throws IOException | |||
| { | |||
| File listFile = fileUtils.createTempFile( "ant", "", null ); | |||
| File listFile = File.createTempFile( "ant", "", getBaseDirectory() ); | |||
| PrintWriter writer = new PrintWriter( new FileOutputStream( listFile ) ); | |||
| @@ -17,11 +17,11 @@ import java.util.Properties; | |||
| import java.util.StringTokenizer; | |||
| import java.util.Vector; | |||
| import netrexx.lang.Rexx; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Task to compile NetRexx source files. This task can take the following | |||
| @@ -501,8 +501,8 @@ public class NetRexxC extends MatchingTask | |||
| if( compileList.size() > 0 ) | |||
| { | |||
| getLogger().info( "Compiling " + compileList.size() + " source file" | |||
| + ( compileList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir ); | |||
| + ( compileList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir ); | |||
| doNetRexxCompile(); | |||
| } | |||
| } | |||
| @@ -611,8 +611,8 @@ public class NetRexxC extends MatchingTask | |||
| if( filecopyList.size() > 0 ) | |||
| { | |||
| getLogger().info( "Copying " + filecopyList.size() + " file" | |||
| + ( filecopyList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir.getAbsolutePath() ); | |||
| + ( filecopyList.size() == 1 ? "" : "s" ) | |||
| + " to " + destDir.getAbsolutePath() ); | |||
| Enumeration enum = filecopyList.keys(); | |||
| while( enum.hasMoreElements() ) | |||
| { | |||
| @@ -620,7 +620,7 @@ public class NetRexxC extends MatchingTask | |||
| String toFile = (String)filecopyList.get( fromFile ); | |||
| try | |||
| { | |||
| FileUtils.newFileUtils().copyFile( fromFile, toFile ); | |||
| FileUtil.copyFile( new File( fromFile ), new File( toFile ) ); | |||
| } | |||
| catch( IOException ioe ) | |||
| { | |||
| @@ -23,7 +23,6 @@ import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.RegularExpression; | |||
| import org.apache.tools.ant.types.Substitution; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.regexp.Regexp; | |||
| /** | |||
| @@ -73,8 +72,6 @@ import org.apache.tools.ant.util.regexp.Regexp; | |||
| */ | |||
| public class ReplaceRegExp extends Task | |||
| { | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| private boolean byline; | |||
| private File file; | |||
| @@ -263,7 +260,7 @@ public class ReplaceRegExp extends Task | |||
| throws IOException, TaskException | |||
| { | |||
| File parentDir = new File( new File( f.getAbsolutePath() ).getParent() ); | |||
| File temp = fileUtils.createTempFile( "replace", ".txt", parentDir ); | |||
| File temp = File.createTempFile( "replace", ".txt", parentDir ); | |||
| FileReader r = null; | |||
| FileWriter w = null; | |||
| @@ -20,12 +20,12 @@ import java.util.jar.JarFile; | |||
| import java.util.jar.JarOutputStream; | |||
| import javax.xml.parsers.SAXParser; | |||
| import javax.xml.parsers.SAXParserFactory; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.AntClassLoader; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.Java; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.xml.sax.InputSource; | |||
| public class WeblogicDeploymentTool extends GenericDeploymentTool | |||
| @@ -755,7 +755,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||
| { | |||
| try | |||
| { | |||
| FileUtils.newFileUtils().copyFile( sourceJar, destJar ); | |||
| FileUtil.copyFile( sourceJar, destJar ); | |||
| if( !keepgenerated ) | |||
| { | |||
| sourceJar.delete(); | |||
| @@ -18,12 +18,12 @@ import java.io.OutputStreamWriter; | |||
| import java.util.Hashtable; | |||
| import java.util.Locale; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| * Translates text embedded in files using Resource Bundle files. | |||
| @@ -40,10 +40,6 @@ public class Translate extends MatchingTask | |||
| * Holds key value pairs loaded from resource bundle file | |||
| */ | |||
| private Hashtable resourceMap = new Hashtable(); | |||
| /** | |||
| * Used to resolve file names. | |||
| */ | |||
| private FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| /** | |||
| * Last Modified Timestamp of resource bundle file being used. | |||
| */ | |||
| @@ -528,7 +524,7 @@ public class Translate extends MatchingTask | |||
| { | |||
| try | |||
| { | |||
| File dest = fileUtils.resolveFile( toDir, srcFiles[ j ] ); | |||
| File dest = FileUtil.resolveFile( toDir, srcFiles[ j ] ); | |||
| //Make sure parent dirs exist, else, create them. | |||
| try | |||
| { | |||
| @@ -15,11 +15,11 @@ import java.io.InputStream; | |||
| import java.net.URL; | |||
| import javax.xml.parsers.DocumentBuilder; | |||
| import javax.xml.parsers.DocumentBuilderFactory; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.w3c.dom.Document; | |||
| import org.w3c.dom.Element; | |||
| @@ -215,12 +215,11 @@ public class AggregateTransformer | |||
| // set the destination directory relative from the project if needed. | |||
| if( toDir == null ) | |||
| { | |||
| toDir = FileUtils.newFileUtils().resolveFile( task.getBaseDirectory(), "." ); | |||
| toDir = FileUtil.resolveFile( task.getBaseDirectory(), "." ); | |||
| } | |||
| else if( !toDir.isAbsolute() ) | |||
| { | |||
| toDir = FileUtils.newFileUtils(). | |||
| resolveFile( task.getBaseDirectory(), toDir.getPath() ); | |||
| toDir = FileUtil.resolveFile( task.getBaseDirectory(), toDir.getPath() ); | |||
| } | |||
| } | |||
| @@ -17,13 +17,13 @@ import java.util.Enumeration; | |||
| import java.util.Vector; | |||
| import javax.xml.parsers.DocumentBuilder; | |||
| import javax.xml.parsers.DocumentBuilderFactory; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.tools.ant.DirectoryScanner; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.util.DOMElementWriter; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.StringUtils; | |||
| import org.w3c.dom.Document; | |||
| import org.w3c.dom.Element; | |||
| @@ -184,7 +184,7 @@ public class XMLResultAggregator extends Task implements XMLConstants | |||
| } | |||
| if( toDir == null ) | |||
| { | |||
| toDir = FileUtils.newFileUtils().resolveFile( project.getBaseDir(), DEFAULT_DIR ); | |||
| toDir = FileUtil.resolveFile( project.getBaseDir(), DEFAULT_DIR ); | |||
| } | |||
| return new File( toDir, toFile ); | |||
| } | |||
| @@ -210,7 +210,7 @@ public class XMLResultAggregator extends Task implements XMLConstants | |||
| if( pathname.endsWith( ".xml" ) ) | |||
| { | |||
| File file = new File( ds.getBasedir(), pathname ); | |||
| file = FileUtils.newFileUtils(). | |||
| file = FileUtil. | |||
| resolveFile( project.getBaseDir(), file.getPath() ); | |||
| v.addElement( file ); | |||
| } | |||
| @@ -12,11 +12,11 @@ import java.util.Enumeration; | |||
| import java.util.Locale; | |||
| import java.util.Stack; | |||
| import java.util.Vector; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| 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; | |||
| /** | |||
| * This object represents a path as used by CLASSPATH or PATH environment | |||
| @@ -196,8 +196,7 @@ public class Path | |||
| { | |||
| if( project != null ) | |||
| { | |||
| File f = FileUtils.newFileUtils(). | |||
| resolveFile( project.getBaseDir(), relativeName ); | |||
| File f = FileUtil.resolveFile( project.getBaseDir(), relativeName ); | |||
| return f.getAbsolutePath(); | |||
| } | |||
| return relativeName; | |||
| @@ -17,8 +17,6 @@ import java.io.FileReader; | |||
| import java.io.FileWriter; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.text.DecimalFormat; | |||
| import java.util.Random; | |||
| import java.util.Stack; | |||
| import java.util.StringTokenizer; | |||
| import org.apache.myrmidon.api.TaskException; | |||
| @@ -37,15 +35,6 @@ import org.apache.tools.ant.types.FilterSetCollection; | |||
| public class FileUtils | |||
| { | |||
| private static Random rand = new Random( System.currentTimeMillis() ); | |||
| /** | |||
| * Empty constructor. | |||
| */ | |||
| private FileUtils() | |||
| { | |||
| } | |||
| /** | |||
| * Factory method. | |||
| * | |||
| @@ -132,54 +121,6 @@ public class FileUtils | |||
| } | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination. No | |||
| * filtering is performed. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), null, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile, FilterSetCollection filters ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), filters, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used and if source files may | |||
| * overwrite newer destination files. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @param overwrite Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, | |||
| boolean overwrite ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), filters, | |||
| overwrite, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used, if source files may overwrite | |||
| @@ -194,84 +135,14 @@ public class FileUtils | |||
| * @param preserveLastModified Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, | |||
| boolean overwrite, boolean preserveLastModified ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( new File( sourceFile ), new File( destFile ), filters, | |||
| overwrite, preserveLastModified ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination. No | |||
| * filtering is performed. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( sourceFile, destFile, null, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile, FilterSetCollection filters ) | |||
| public void copyFile( File sourceFile, | |||
| File destFile, | |||
| FilterSetCollection filters ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( sourceFile, destFile, filters, false, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used and if source files may | |||
| * overwrite newer destination files. | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @param overwrite Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, | |||
| boolean overwrite ) | |||
| throws IOException, TaskException | |||
| { | |||
| copyFile( sourceFile, destFile, filters, overwrite, false ); | |||
| } | |||
| /** | |||
| * Convienence method to copy a file from a source to a destination | |||
| * specifying if token filtering must be used, if source files may overwrite | |||
| * newer destination files and the last modified time of <code>destFile</code> | |||
| * file should be made equal to the last modified time of <code>sourceFile</code> | |||
| * . | |||
| * | |||
| * @param sourceFile Description of Parameter | |||
| * @param destFile Description of Parameter | |||
| * @param filters Description of Parameter | |||
| * @param overwrite Description of Parameter | |||
| * @param preserveLastModified Description of Parameter | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, | |||
| boolean overwrite, boolean preserveLastModified ) | |||
| throws IOException, TaskException | |||
| { | |||
| if( overwrite || !destFile.exists() || | |||
| if( !destFile.exists() || | |||
| destFile.lastModified() < sourceFile.lastModified() ) | |||
| { | |||
| if( destFile.exists() && destFile.isFile() ) | |||
| { | |||
| destFile.delete(); | |||
| @@ -327,54 +198,9 @@ public class FileUtils | |||
| in.close(); | |||
| out.close(); | |||
| } | |||
| if( preserveLastModified ) | |||
| { | |||
| destFile.setLastModified( sourceFile.lastModified() ); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Create a temporary file in a given directory. <p> | |||
| * | |||
| * The file denoted by the returned abstract pathname did not exist before | |||
| * this method was invoked, any subsequent invocation of this method will | |||
| * yield a different file name.</p> <p> | |||
| * | |||
| * This method is different to File.createTempFile of JDK 1.2 as it doesn't | |||
| * create the file itself and doesn't use platform specific temporary | |||
| * directory when the parentDir attribute is null.</p> | |||
| * | |||
| * @param parentDir Directory to create the temporary file in - current | |||
| * working directory will be assumed if this parameter is null. | |||
| * @param prefix Description of Parameter | |||
| * @param suffix Description of Parameter | |||
| * @return Description of the Returned Value | |||
| * @since 1.8 | |||
| */ | |||
| public File createTempFile( String prefix, String suffix, File parentDir ) | |||
| { | |||
| File result = null; | |||
| String parent = null; | |||
| if( parentDir != null ) | |||
| { | |||
| parent = parentDir.getPath(); | |||
| } | |||
| DecimalFormat fmt = new DecimalFormat( "#####" ); | |||
| synchronized( rand ) | |||
| { | |||
| do | |||
| { | |||
| result = new File( parent, | |||
| prefix + fmt.format( rand.nextInt() ) | |||
| + suffix ); | |||
| } while( result.exists() ); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| * "normalize" the given absolute path. <p> | |||
| * | |||
| @@ -514,68 +340,5 @@ public class FileUtils | |||
| } | |||
| return new File( path ); | |||
| } | |||
| /** | |||
| * Interpret the filename as a file relative to the given file - unless the | |||
| * filename already represents an absolute filename. | |||
| * | |||
| * @param file the "reference" file for relative paths. This instance must | |||
| * be an absolute file and must not contain "./" or | |||
| * "../" sequences (same for \ instead of /). If it is null, | |||
| * this call is equivalent to <code>new java.io.File(filename)</code>. | |||
| * @param filename a file name | |||
| * @return an absolute file that doesn't contain "./" or | |||
| * "../" sequences and uses the correct separator for the | |||
| * current platform. | |||
| */ | |||
| public File resolveFile( File file, String filename ) | |||
| throws TaskException | |||
| { | |||
| filename = filename.replace( '/', File.separatorChar ) | |||
| .replace( '\\', File.separatorChar ); | |||
| // deal with absolute files | |||
| if( filename.startsWith( File.separator ) || | |||
| ( filename.length() >= 2 && | |||
| Character.isLetter( filename.charAt( 0 ) ) && | |||
| filename.charAt( 1 ) == ':' ) | |||
| ) | |||
| { | |||
| return normalize( filename ); | |||
| } | |||
| if( file == null ) | |||
| { | |||
| return new File( filename ); | |||
| } | |||
| File helpFile = new File( file.getAbsolutePath() ); | |||
| StringTokenizer tok = new StringTokenizer( filename, File.separator ); | |||
| while( tok.hasMoreTokens() ) | |||
| { | |||
| String part = tok.nextToken(); | |||
| if( part.equals( ".." ) ) | |||
| { | |||
| helpFile = helpFile.getParentFile(); | |||
| if( helpFile == null ) | |||
| { | |||
| String msg = "The file or path you specified (" | |||
| + filename + ") is invalid relative to " | |||
| + file.getPath(); | |||
| throw new TaskException( msg ); | |||
| } | |||
| } | |||
| else if( part.equals( "." ) ) | |||
| { | |||
| // Do nothing here | |||
| } | |||
| else | |||
| { | |||
| helpFile = new File( helpFile, part ); | |||
| } | |||
| } | |||
| return new File( helpFile.getAbsolutePath() ); | |||
| } | |||
| } | |||
| @@ -13,6 +13,7 @@ import org.apache.myrmidon.api.TaskException; | |||
| import org.apache.myrmidon.framework.Os; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.avalon.excalibur.io.FileUtil; | |||
| /** | |||
| * Utility class that collects the functionality of the various scanDir methods | |||
| @@ -26,18 +27,14 @@ import org.apache.tools.ant.Task; | |||
| */ | |||
| public class SourceFileScanner | |||
| { | |||
| protected Task task; | |||
| private FileUtils fileUtils; | |||
| private Task m_task; | |||
| /** | |||
| * @param task The task we should log messages through | |||
| */ | |||
| public SourceFileScanner( Task task ) | |||
| { | |||
| this.task = task; | |||
| fileUtils = FileUtils.newFileUtils(); | |||
| this.m_task = task; | |||
| } | |||
| /** | |||
| @@ -80,16 +77,16 @@ public class SourceFileScanner | |||
| String[] targets = mapper.mapFileName( files[ i ] ); | |||
| if( targets == null || targets.length == 0 ) | |||
| { | |||
| task.log( files[ i ] + " skipped - don\'t know how to handle it", | |||
| m_task.log( files[ i ] + " skipped - don\'t know how to handle it", | |||
| Project.MSG_VERBOSE ); | |||
| continue; | |||
| } | |||
| File src = fileUtils.resolveFile( srcDir, files[ i ] ); | |||
| File src = FileUtil.resolveFile( srcDir, files[ i ] ); | |||
| if( src.lastModified() > now ) | |||
| { | |||
| task.log( "Warning: " + files[ i ] + " modified in the future.", | |||
| m_task.log( "Warning: " + files[ i ] + " modified in the future.", | |||
| Project.MSG_WARN ); | |||
| } | |||
| @@ -97,18 +94,18 @@ public class SourceFileScanner | |||
| targetList.setLength( 0 ); | |||
| for( int j = 0; !added && j < targets.length; j++ ) | |||
| { | |||
| File dest = fileUtils.resolveFile( destDir, targets[ j ] ); | |||
| File dest = FileUtil.resolveFile( destDir, targets[ j ] ); | |||
| if( !dest.exists() ) | |||
| { | |||
| task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " doesn\'t exist.", | |||
| Project.MSG_VERBOSE ); | |||
| v.addElement( files[ i ] ); | |||
| added = true; | |||
| } | |||
| else if( src.lastModified() > dest.lastModified() ) | |||
| { | |||
| task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", | |||
| m_task.log( files[ i ] + " added as " + dest.getAbsolutePath() + " is outdated.", | |||
| Project.MSG_VERBOSE ); | |||
| v.addElement( files[ i ] ); | |||
| added = true; | |||
| @@ -125,7 +122,7 @@ public class SourceFileScanner | |||
| if( !added ) | |||
| { | |||
| task.log( files[ i ] + " omitted as " + targetList.toString() | |||
| m_task.log( files[ i ] + " omitted as " + targetList.toString() | |||
| + ( targets.length == 1 ? " is" : " are " ) | |||
| + " up to date.", Project.MSG_VERBOSE ); | |||
| } | |||