git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@668724 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -42,10 +42,11 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.condition.Condition; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.Union; | |||
| import org.apache.tools.ant.types.resources.Restrict; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.selectors.Type; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.StringUtils; | |||
| @@ -392,13 +393,13 @@ public class Checksum extends MatchingTask implements Condition { | |||
| try { | |||
| if (resources != null) { | |||
| for (Iterator i = resources.iterator(); i.hasNext();) { | |||
| FileResource fr = (FileResource) i.next(); | |||
| File src = fr.getFile(); | |||
| Resource r = (Resource) i.next(); | |||
| File src = ((FileProvider) r).getFile(); | |||
| if (totalproperty != null || todir != null) { | |||
| // Use '/' to calculate digest based on file name. | |||
| // This is required in order to get the same result | |||
| // on different platforms. | |||
| relativeFilePaths.put(src, fr.getName().replace(File.separatorChar, '/')); | |||
| relativeFilePaths.put(src, r.getName().replace(File.separatorChar, '/')); | |||
| } | |||
| addToIncludeFileMap(src); | |||
| } | |||
| @@ -45,9 +45,9 @@ import org.apache.tools.ant.types.FileList; | |||
| import org.apache.tools.ant.types.FilterChain; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.Restrict; | |||
| import org.apache.tools.ant.types.resources.Resources; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.StringResource; | |||
| import org.apache.tools.ant.types.resources.selectors.Not; | |||
| import org.apache.tools.ant.types.resources.selectors.Exists; | |||
| @@ -854,8 +854,8 @@ public class Concat extends Task implements ResourceCollection { | |||
| if (destinationFile != null) { | |||
| for (Iterator i = rc.iterator(); i.hasNext();) { | |||
| Object o = i.next(); | |||
| if (o instanceof FileResource) { | |||
| File f = ((FileResource) o).getFile(); | |||
| if (o instanceof FileProvider) { | |||
| File f = ((FileProvider) o).getFile(); | |||
| if (FILE_UTILS.fileNameEquals(f, destinationFile)) { | |||
| throw new BuildException("Input file \"" | |||
| + f + "\" is the same as the output file."); | |||
| @@ -41,6 +41,7 @@ import org.apache.tools.ant.types.FilterSetCollection; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.ResourceFactory; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.FileNameMapper; | |||
| @@ -465,8 +466,8 @@ public class Copy extends Task { | |||
| File baseDir = NULL_FILE_PLACEHOLDER; | |||
| String name = r.getName(); | |||
| if (r instanceof FileResource) { | |||
| FileResource fr = (FileResource) r; | |||
| if (r instanceof FileProvider) { | |||
| FileResource fr = ResourceUtils.asFileResource((FileProvider) r); | |||
| baseDir = getKeyFile(fr.getBaseDir()); | |||
| if (fr.getBaseDir() == null) { | |||
| name = fr.getFile().getAbsolutePath(); | |||
| @@ -476,7 +477,7 @@ public class Copy extends Task { | |||
| // copying of dirs is trivial and can be done | |||
| // for non-file resources as well as for real | |||
| // files. | |||
| if (r.isDirectory() || r instanceof FileResource) { | |||
| if (r.isDirectory() || r instanceof FileProvider) { | |||
| add(baseDir, name, | |||
| r.isDirectory() ? dirsByBasedir | |||
| : filesByBasedir); | |||
| @@ -620,7 +621,7 @@ public class Copy extends Task { | |||
| throw new BuildException( | |||
| "Cannot perform operation from directory to file."); | |||
| } else if (rc.size() == 1) { | |||
| FileResource r = (FileResource) rc.iterator().next(); | |||
| FileProvider r = (FileProvider) rc.iterator().next(); | |||
| if (file == null) { | |||
| file = r.getFile(); | |||
| rcs.removeElementAt(0); | |||
| @@ -30,10 +30,10 @@ import org.apache.tools.ant.taskdefs.condition.Os; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.Sort; | |||
| import org.apache.tools.ant.types.resources.Restrict; | |||
| import org.apache.tools.ant.types.resources.Resources; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.FileResourceIterator; | |||
| import org.apache.tools.ant.types.resources.comparators.Reverse; | |||
| import org.apache.tools.ant.types.resources.comparators.FileSystem; | |||
| @@ -590,17 +590,17 @@ public class Delete extends MatchingTask { | |||
| try { | |||
| if (resourcesToDelete.isFilesystemOnly()) { | |||
| for (Iterator iter = resourcesToDelete.iterator(); iter.hasNext();) { | |||
| FileResource r = (FileResource) iter.next(); | |||
| // nonexistent resources could only occur if we already | |||
| // deleted something from a fileset: | |||
| if (!r.isExists()) { | |||
| File f = ((FileProvider) iter.next()).getFile(); | |||
| if (!f.exists()) { | |||
| continue; | |||
| } | |||
| if (!(r.isDirectory()) || r.getFile().list().length == 0) { | |||
| log("Deleting " + r, verbosity); | |||
| if (!delete(r.getFile()) && failonerror) { | |||
| if (!(f.isDirectory()) || f.list().length == 0) { | |||
| log("Deleting " + f, verbosity); | |||
| if (!delete(f) && failonerror) { | |||
| handle("Unable to delete " | |||
| + (r.isDirectory() ? "directory " : "file ") + r); | |||
| + (f.isDirectory() ? "directory " : "file ") + f); | |||
| } | |||
| } | |||
| } | |||
| @@ -31,7 +31,6 @@ import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.Union; | |||
| import org.apache.tools.ant.types.resources.Restrict; | |||
| import org.apache.tools.ant.types.resources.Resources; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.selectors.Not; | |||
| import org.apache.tools.ant.types.resources.selectors.Exists; | |||
| import org.apache.tools.ant.types.resources.selectors.ResourceSelector; | |||
| @@ -205,7 +204,7 @@ public class DependSet extends MatchingTask { | |||
| log(neTargets + " nonexistent targets", Project.MSG_VERBOSE); | |||
| return false; | |||
| } | |||
| FileResource oldestTarget = (FileResource) getOldest(targets); | |||
| Resource oldestTarget = getOldest(targets); | |||
| log(oldestTarget + " is oldest target file", Project.MSG_VERBOSE); | |||
| logFuture(sources, datesel); | |||
| @@ -35,9 +35,11 @@ import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.Mapper; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.Union; | |||
| import org.apache.tools.ant.util.FileNameMapper; | |||
| import org.apache.tools.ant.util.ResourceUtils; | |||
| import org.apache.tools.ant.util.SourceFileScanner; | |||
| /** | |||
| @@ -424,8 +426,8 @@ public class ExecuteOn extends ExecTask { | |||
| File base = null; | |||
| String name = res.getName(); | |||
| if (res instanceof FileResource) { | |||
| FileResource fr = (FileResource) res; | |||
| if (res instanceof FileProvider) { | |||
| FileResource fr = ResourceUtils.asFileResource((FileProvider) res); | |||
| base = fr.getBaseDir(); | |||
| if (base == null) { | |||
| name = fr.getFile().getAbsolutePath(); | |||
| @@ -38,7 +38,7 @@ import org.apache.tools.ant.types.Mapper; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.Union; | |||
| import org.apache.tools.ant.types.selectors.SelectorUtils; | |||
| import org.apache.tools.ant.util.FileNameMapper; | |||
| @@ -114,8 +114,8 @@ public class Expand extends Task { | |||
| continue; | |||
| } | |||
| if (r instanceof FileResource) { | |||
| expandFile(FILE_UTILS, ((FileResource) r).getFile(), dest); | |||
| if (r instanceof FileProvider) { | |||
| expandFile(FILE_UTILS, ((FileProvider) r).getFile(), dest); | |||
| } else { | |||
| expandResource(r, dest); | |||
| } | |||
| @@ -46,7 +46,7 @@ import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.PatternSet; | |||
| import org.apache.tools.ant.types.Reference; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||
| @@ -1910,7 +1910,7 @@ public class Javadoc extends Task { | |||
| "Error creating or writing temporary file for javadoc options", | |||
| ex, getLocation()); | |||
| } finally { | |||
| FILE_UTILS.close(optionsListWriter); | |||
| FileUtils.close(optionsListWriter); | |||
| } | |||
| } | |||
| @@ -2267,7 +2267,7 @@ public class Javadoc extends Task { | |||
| } | |||
| Iterator iter = rc.iterator(); | |||
| while (iter.hasNext()) { | |||
| sf.addElement(new SourceFile(((FileResource) iter.next()) | |||
| sf.addElement(new SourceFile(((FileProvider) iter.next()) | |||
| .getFile())); | |||
| } | |||
| } | |||
| @@ -26,6 +26,7 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| /** | |||
| @@ -74,11 +75,10 @@ public abstract class Pack extends Task { | |||
| if (src.isDirectory()) { | |||
| throw new BuildException("the source can't be a directory"); | |||
| } | |||
| if (src instanceof FileResource) { | |||
| source = ((FileResource) src).getFile(); | |||
| if (src instanceof FileProvider) { | |||
| source = ((FileProvider) src).getFile(); | |||
| } else if (!supportsNonFileResources()) { | |||
| throw new BuildException("Only FileSystem resources are" | |||
| + " supported."); | |||
| throw new BuildException("Only FileSystem resources are supported."); | |||
| } | |||
| this.src = src; | |||
| } | |||
| @@ -26,10 +26,12 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.taskdefs.condition.IsSigned; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.IdentityMapper; | |||
| import org.apache.tools.ant.util.FileNameMapper; | |||
| import org.apache.tools.ant.util.ResourceUtils; | |||
| /** | |||
| * Signs JAR or ZIP files with the javasign command line tool. The tool detailed | |||
| @@ -320,7 +322,7 @@ public class SignJar extends AbstractJarSignerTask { | |||
| // deal with the paths | |||
| Iterator iter = sources.iterator(); | |||
| while (iter.hasNext()) { | |||
| FileResource fr = (FileResource) iter.next(); | |||
| FileResource fr = ResourceUtils.asFileResource((FileProvider) iter.next()); | |||
| //calculate our destination directory; it is either the destDir | |||
| //attribute, or the base dir of the fileset (for in situ updates) | |||
| @@ -39,11 +39,13 @@ import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.ArchiveResource; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.selectors.SelectorUtils; | |||
| import org.apache.tools.ant.types.resources.TarResource; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.MergingMapper; | |||
| import org.apache.tools.ant.util.ResourceUtils; | |||
| import org.apache.tools.ant.util.SourceFileScanner; | |||
| import org.apache.tools.bzip2.CBZip2OutputStream; | |||
| import org.apache.tools.tar.TarConstants; | |||
| @@ -559,7 +561,7 @@ public class Tar extends MatchingTask { | |||
| HashMap basedirToFilesMap = new HashMap(); | |||
| Iterator iter = rc.iterator(); | |||
| while (iter.hasNext()) { | |||
| FileResource r = (FileResource) iter.next(); | |||
| FileResource r = ResourceUtils.asFileResource((FileProvider) iter.next()); | |||
| File base = r.getBaseDir(); | |||
| if (base == null) { | |||
| base = Copy.NULL_FILE_PLACEHOLDER; | |||
| @@ -652,7 +654,7 @@ public class Tar extends MatchingTask { | |||
| } else if (rc.isFilesystemOnly()) { | |||
| Iterator iter = rc.iterator(); | |||
| while (iter.hasNext()) { | |||
| FileResource r = (FileResource) iter.next(); | |||
| FileResource r = ResourceUtils.asFileResource((FileProvider) iter.next()); | |||
| File f = r.getFile(); | |||
| if (f == null) { | |||
| f = new File(r.getBaseDir(), r.getName()); | |||
| @@ -35,6 +35,7 @@ import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.FileList; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.Touchable; | |||
| import org.apache.tools.ant.types.resources.Union; | |||
| @@ -338,9 +339,9 @@ public class Touch extends Task { | |||
| private void touch(Resource r, long defaultTimestamp) { | |||
| if (fileNameMapper == null) { | |||
| if (r instanceof FileResource) { | |||
| if (r instanceof FileProvider) { | |||
| // use this to create file and deal with non-writable files | |||
| touch(((FileResource) r).getFile(), defaultTimestamp); | |||
| touch(((FileProvider) r).getFile(), defaultTimestamp); | |||
| } else { | |||
| ((Touchable) r).touch(defaultTimestamp); | |||
| } | |||
| @@ -27,6 +27,7 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -125,7 +126,7 @@ public class Truncate extends Task { | |||
| throw new BuildException(NO_CHILD); | |||
| } | |||
| for (Iterator it = path.iterator(); it.hasNext();) { | |||
| File f = ((FileResource) it.next()).getFile(); | |||
| File f = ((FileProvider) it.next()).getFile(); | |||
| if (shouldProcess(f)) { | |||
| process(f); | |||
| } | |||
| @@ -24,6 +24,7 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| /** | |||
| @@ -90,8 +91,8 @@ public abstract class Unpack extends Task { | |||
| throw new BuildException( | |||
| "the archive " + src.getName() + " can't be a directory"); | |||
| } | |||
| if (src instanceof FileResource) { | |||
| source = ((FileResource) src).getFile(); | |||
| if (src instanceof FileProvider) { | |||
| source = ((FileProvider) src).getFile(); | |||
| } else if (!supportsNonFileResources()) { | |||
| throw new BuildException( | |||
| "The source " + src.getName() | |||
| @@ -24,6 +24,7 @@ import org.apache.tools.ant.filters.ChainableReader; | |||
| import org.apache.tools.ant.types.RedirectorElement; | |||
| import org.apache.tools.ant.types.FilterChain; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import java.util.Iterator; | |||
| @@ -90,7 +91,7 @@ public class VerifyJar extends AbstractJarSignerTask { | |||
| Path sources = createUnifiedSourcePath(); | |||
| Iterator iter = sources.iterator(); | |||
| while (iter.hasNext()) { | |||
| FileResource fr = (FileResource) iter.next(); | |||
| FileProvider fr = (FileProvider) iter.next(); | |||
| verifyOneJar(fr.getFile()); | |||
| } | |||
| @@ -38,6 +38,7 @@ import org.apache.tools.ant.types.resources.Union; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.util.FileNameMapper; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.ResourceUtils; | |||
| /** | |||
| * Processes a set of XML documents via XSLT. This is | |||
| @@ -591,8 +592,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
| } | |||
| File base = baseDir; | |||
| String name = r.getName(); | |||
| if (r instanceof FileResource) { | |||
| FileResource f = (FileResource) r; | |||
| if (r instanceof FileProvider) { | |||
| FileResource f = ResourceUtils.asFileResource((FileProvider) r); | |||
| base = f.getBaseDir(); | |||
| if (base == null) { | |||
| name = f.getFile().getAbsolutePath(); | |||
| @@ -29,6 +29,7 @@ import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.XMLCatalog; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.w3c.dom.Document; | |||
| @@ -243,8 +244,8 @@ public class XmlProperty extends org.apache.tools.ant.Task { | |||
| DocumentBuilder builder = factory.newDocumentBuilder(); | |||
| builder.setEntityResolver(getEntityResolver()); | |||
| Document document = null; | |||
| if (src instanceof FileResource) { | |||
| document = builder.parse(((FileResource) src).getFile()); | |||
| if (src instanceof FileProvider) { | |||
| document = builder.parse(((FileProvider) src).getFile()); | |||
| } else { | |||
| document = builder.parse(src.getInputStream()); | |||
| } | |||
| @@ -573,10 +574,11 @@ public class XmlProperty extends org.apache.tools.ant.Task { | |||
| if (src.isDirectory()) { | |||
| throw new BuildException("the source can't be a directory"); | |||
| } | |||
| if (src instanceof FileResource && !supportsNonFileResources()) { | |||
| if (src instanceof FileProvider || supportsNonFileResources()) { | |||
| this.src = src; | |||
| } else { | |||
| throw new BuildException("Only FileSystem resources are supported."); | |||
| } | |||
| this.src = src; | |||
| } | |||
| /** | |||
| @@ -667,7 +669,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { | |||
| * @return the file attribute. | |||
| */ | |||
| protected File getFile () { | |||
| return src instanceof FileResource ? ((FileResource) src).getFile() : null; | |||
| return src instanceof FileProvider ? ((FileProvider) src).getFile() : null; | |||
| } | |||
| /** | |||
| @@ -677,8 +679,8 @@ public class XmlProperty extends org.apache.tools.ant.Task { | |||
| // delegate this way around to support subclasses that | |||
| // overwrite getFile | |||
| File f = getFile(); | |||
| return f == null ? src : src instanceof FileResource | |||
| && ((FileResource) src).getFile().equals(f) ? src : new FileResource(f); | |||
| return f == null ? src : src instanceof FileProvider | |||
| && ((FileProvider) src).getFile().equals(f) ? src : new FileResource(f); | |||
| } | |||
| /** | |||
| @@ -46,7 +46,7 @@ import org.apache.tools.ant.types.ResourceCollection; | |||
| import org.apache.tools.ant.types.ZipFileSet; | |||
| import org.apache.tools.ant.types.ZipScanner; | |||
| import org.apache.tools.ant.types.resources.ArchiveResource; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.util.FileNameMapper; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.util.GlobPatternMapper; | |||
| @@ -863,8 +863,8 @@ public class Zip extends MatchingTask { | |||
| continue; | |||
| } | |||
| File base = null; | |||
| if (resources[i] instanceof FileResource) { | |||
| base = ((FileResource) resources[i]).getBaseDir(); | |||
| if (resources[i] instanceof FileProvider) { | |||
| base = ResourceUtils.asFileResource((FileProvider) resources[i]).getBaseDir(); | |||
| } | |||
| if (resources[i].isDirectory()) { | |||
| if (!name.endsWith("/")) { | |||
| @@ -876,8 +876,8 @@ public class Zip extends MatchingTask { | |||
| ArchiveFileSet.DEFAULT_DIR_MODE); | |||
| if (!resources[i].isDirectory()) { | |||
| if (resources[i] instanceof FileResource) { | |||
| File f = ((FileResource) resources[i]).getFile(); | |||
| if (resources[i] instanceof FileProvider) { | |||
| File f = ((FileProvider) resources[i]).getFile(); | |||
| zipFile(f, zOut, name, ArchiveFileSet.DEFAULT_FILE_MODE); | |||
| } else { | |||
| InputStream is = null; | |||
| @@ -1254,8 +1254,8 @@ public class Zip extends MatchingTask { | |||
| } | |||
| for (int j = 0; j < initialResources[i].length; j++) { | |||
| if (initialResources[i][j] instanceof FileResource | |||
| && zipFile.equals(((FileResource) | |||
| if (initialResources[i][j] instanceof FileProvider | |||
| && zipFile.equals(((FileProvider) | |||
| initialResources[i][j]).getFile())) { | |||
| throw new BuildException("A zip file cannot include " | |||
| + "itself", getLocation()); | |||
| @@ -28,6 +28,7 @@ import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.EnumeratedAttribute; | |||
| import org.apache.tools.ant.types.FileSet; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.util.ClasspathUtils; | |||
| @@ -499,8 +500,7 @@ public class EmailTask extends Task { | |||
| Iterator iter = attachments.iterator(); | |||
| while (iter.hasNext()) { | |||
| FileResource fr = (FileResource) iter.next(); | |||
| files.addElement(fr.getFile()); | |||
| files.addElement(((FileProvider) iter.next()).getFile()); | |||
| } | |||
| } | |||
| // let the user know what's going to happen | |||
| @@ -52,6 +52,7 @@ import org.apache.tools.ant.taskdefs.XSLTLoggerAware; | |||
| import org.apache.tools.ant.taskdefs.XSLTProcess; | |||
| import org.apache.tools.ant.types.XMLCatalog; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.URLResource; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| @@ -271,8 +272,8 @@ public class TraXLiaison implements XSLTLiaison3, ErrorListener, XSLTLoggerAware | |||
| } | |||
| private String resourceToURI(Resource resource) { | |||
| if (resource instanceof FileResource) { | |||
| File f = ((FileResource) resource).getFile(); | |||
| if (resource instanceof FileProvider) { | |||
| File f = ((FileProvider) resource).getFile(); | |||
| return FILE_UTILS.toURI(f.getAbsolutePath()); | |||
| } | |||
| if (resource instanceof URLResource) { | |||
| @@ -158,7 +158,7 @@ public abstract class BaseResourceCollectionContainer | |||
| /* now check each Resource in case the child only | |||
| lets through files from any children IT may have: */ | |||
| for (Iterator i = cacheCollection().iterator(); i.hasNext();) { | |||
| if (!(i.next() instanceof FileResource)) { | |||
| if (!(i.next() instanceof FileProvider)) { | |||
| return false; | |||
| } | |||
| } | |||
| @@ -122,7 +122,7 @@ public abstract class BaseResourceCollectionWrapper | |||
| /* now check each Resource in case the child only | |||
| lets through files from any children IT may have: */ | |||
| for (Iterator i = cacheCollection().iterator(); i.hasNext();) { | |||
| if (!(i.next() instanceof FileResource)) { | |||
| if (!(i.next() instanceof FileProvider)) { | |||
| return false; | |||
| } | |||
| } | |||
| @@ -228,13 +228,12 @@ public class FileResource extends Resource implements Touchable, FileProvider, | |||
| if (this.equals(another)) { | |||
| return 0; | |||
| } | |||
| if (another.getClass().equals(getClass())) { | |||
| FileResource otherfr = (FileResource) another; | |||
| if (another instanceof FileProvider) { | |||
| File f = getFile(); | |||
| if (f == null) { | |||
| return -1; | |||
| } | |||
| File of = otherfr.getFile(); | |||
| File of = ((FileProvider) another).getFile(); | |||
| if (of == null) { | |||
| return 1; | |||
| } | |||
| @@ -19,7 +19,7 @@ package org.apache.tools.ant.types.resources.comparators; | |||
| import java.io.File; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.resources.FileResource; | |||
| import org.apache.tools.ant.types.resources.FileProvider; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| /** | |||
| @@ -38,8 +38,8 @@ public class FileSystem extends ResourceComparator { | |||
| * @throws ClassCastException if either resource is not an instance of FileResource. | |||
| */ | |||
| protected int resourceCompare(Resource foo, Resource bar) { | |||
| File foofile = ((FileResource) foo).getFile(); | |||
| File barfile = ((FileResource) bar).getFile(); | |||
| File foofile = ((FileProvider) foo).getFile(); | |||
| File barfile = ((FileProvider) bar).getFile(); | |||
| return foofile.equals(barfile) ? 0 | |||
| : FILE_UTILS.isLeadingPath(foofile, barfile) ? -1 | |||
| : FILE_UTILS.normalize(foofile.getAbsolutePath()).compareTo( | |||