Browse Source

Bug 43348: add awareness of FileProvider to ArchiveFileSet

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@709764 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 16 years ago
parent
commit
2d183a571f
1 changed files with 11 additions and 8 deletions
  1. +11
    -8
      src/main/org/apache/tools/ant/types/ArchiveFileSet.java

+ 11
- 8
src/main/org/apache/tools/ant/types/ArchiveFileSet.java View File

@@ -23,6 +23,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.zip.UnixStat; import org.apache.tools.zip.UnixStat;


/** /**
@@ -64,6 +65,8 @@ public abstract class ArchiveFileSet extends FileSet {


private boolean fileModeHasBeenSet = false; private boolean fileModeHasBeenSet = false;
private boolean dirModeHasBeenSet = false; private boolean dirModeHasBeenSet = false;
private static final String ERROR_DIR_AND_SRC_ATTRIBUTES = "Cannot set both dir and src attributes";
private static final String ERROR_PATH_AND_PREFIX = "Cannot set both fullpath and prefix attributes";


/** Constructor for ArchiveFileSet */ /** Constructor for ArchiveFileSet */
public ArchiveFileSet() { public ArchiveFileSet() {
@@ -102,7 +105,7 @@ public abstract class ArchiveFileSet extends FileSet {
public void setDir(File dir) throws BuildException { public void setDir(File dir) throws BuildException {
checkAttributesAllowed(); checkAttributesAllowed();
if (src != null) { if (src != null) {
throw new BuildException("Cannot set both dir and src attributes");
throw new BuildException(ERROR_DIR_AND_SRC_ATTRIBUTES);
} }
super.setDir(dir); super.setDir(dir);
hasDir = true; hasDir = true;
@@ -141,7 +144,7 @@ public abstract class ArchiveFileSet extends FileSet {
public void setSrcResource(Resource src) { public void setSrcResource(Resource src) {
checkArchiveAttributesAllowed(); checkArchiveAttributesAllowed();
if (hasDir) { if (hasDir) {
throw new BuildException("Cannot set both dir and src attributes");
throw new BuildException(ERROR_DIR_AND_SRC_ATTRIBUTES);
} }
this.src = src; this.src = src;
} }
@@ -163,8 +166,8 @@ public abstract class ArchiveFileSet extends FileSet {
* @return the archive in case the archive is a file, null otherwise. * @return the archive in case the archive is a file, null otherwise.
*/ */
public File getSrc() { public File getSrc() {
if (src instanceof FileResource) {
return ((FileResource) src).getFile();
if (src instanceof FileProvider) {
return ((FileProvider) src).getFile();
} }
return null; return null;
} }
@@ -178,7 +181,7 @@ public abstract class ArchiveFileSet extends FileSet {
public void setPrefix(String prefix) { public void setPrefix(String prefix) {
checkArchiveAttributesAllowed(); checkArchiveAttributesAllowed();
if (!"".equals(prefix) && !"".equals(fullpath)) { if (!"".equals(prefix) && !"".equals(fullpath)) {
throw new BuildException("Cannot set both fullpath and prefix attributes");
throw new BuildException(ERROR_PATH_AND_PREFIX);
} }
this.prefix = prefix; this.prefix = prefix;
} }
@@ -204,7 +207,7 @@ public abstract class ArchiveFileSet extends FileSet {
public void setFullpath(String fullpath) { public void setFullpath(String fullpath) {
checkArchiveAttributesAllowed(); checkArchiveAttributesAllowed();
if (!"".equals(prefix) && !"".equals(fullpath)) { if (!"".equals(prefix) && !"".equals(fullpath)) {
throw new BuildException("Cannot set both fullpath and prefix attributes");
throw new BuildException(ERROR_PATH_AND_PREFIX);
} }
this.fullpath = fullpath; this.fullpath = fullpath;
} }
@@ -243,10 +246,10 @@ public abstract class ArchiveFileSet extends FileSet {
} }
if (!src.isExists()) { if (!src.isExists()) {
throw new BuildException( throw new BuildException(
"the archive " + src.getName() + " doesn't exist");
"The archive " + src.getName() + " doesn't exist");
} }
if (src.isDirectory()) { if (src.isDirectory()) {
throw new BuildException("the archive " + src.getName()
throw new BuildException("The archive " + src.getName()
+ " can't be a directory"); + " can't be a directory");
} }
ArchiveScanner as = newArchiveScanner(); ArchiveScanner as = newArchiveScanner();


Loading…
Cancel
Save