From 5d1a7711e3d5cf1aa1704bb1df97710ae47aa47b Mon Sep 17 00:00:00 2001 From: Antoine Levy-Lambert Date: Thu, 20 Oct 2005 21:24:45 +0000 Subject: [PATCH] instantiate a FileResource when setSrc(Resource) is called. Otherwise a number of tests break. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@327004 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/types/ArchiveFileSet.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java index 7ecfd2919..8b6a3fb74 100755 --- a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java +++ b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java @@ -21,6 +21,7 @@ import java.util.Iterator; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; +import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.zip.UnixStat; @@ -61,6 +62,7 @@ public abstract class ArchiveFileSet extends FileSet { private boolean fileModeHasBeenSet = false; private boolean dirModeHasBeenSet = false; + private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); /** Constructor for ArchiveFileSet */ public ArchiveFileSet() { @@ -134,14 +136,18 @@ public abstract class ArchiveFileSet extends FileSet { * Set the source Archive file for the archivefileset. Prevents both * "dir" and "src" from being specified. * - * @param srcFile The archive from which to extract entries. + * @param src The archive from which to extract entries. */ public void setSrcResource(Resource src) { checkAttributesAllowed(); if (hasDir) { throw new BuildException("Cannot set both dir and src attributes"); } - this.src = src; + if (getProject()!=null) { + this.src = new FileResource(FILE_UTILS.resolveFile(getProject().getBaseDir(),src.toString())); + } else { + this.src = new FileResource(new File(src.toString())); + } } /** @@ -417,8 +423,7 @@ public abstract class ArchiveFileSet extends FileSet { /** * A ArchiveFileset accepts another ArchiveFileSet or a FileSet as reference * FileSets are often used by the war task for the lib attribute - * @param p the project to use - * @return the abstract fileset instance + * @param zfs the project to use */ protected void configureFileSet(ArchiveFileSet zfs) { zfs.setPrefix(prefix); @@ -442,4 +447,20 @@ public abstract class ArchiveFileSet extends FileSet { return super.clone(); } } + + /** + * for file based zipfilesets, return the same as for normal filesets + * else just return the path of the zip + * @return for file based archivefilesets, included files as a list + * of semicolon-separated filenames. else just the name of the zip. + */ + public String toString() { + if (hasDir && getProject() != null) { + return super.toString(); + } else if (src != null) { + return src.getName(); + } else { + return null; + } + } }