Browse Source

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
master
Antoine Levy-Lambert 19 years ago
parent
commit
5d1a7711e3
1 changed files with 25 additions and 4 deletions
  1. +25
    -4
      src/main/org/apache/tools/ant/types/ArchiveFileSet.java

+ 25
- 4
src/main/org/apache/tools/ant/types/ArchiveFileSet.java View File

@@ -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;
}
}
}

Loading…
Cancel
Save