From 267492df5827611c5fa13f2ff35a05a8152e2664 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Tue, 19 Sep 2006 22:01:56 +0000 Subject: [PATCH] Fix for 39439: in does not work. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@447991 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 ++ .../tools/ant/taskdefs/optional/Cab.java | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index fff64d702..efd58740a 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -15,6 +15,8 @@ Fixed bugs: * was broken (Regression from beta1). Bugzilla report 40547. +* nested fileset in did not work. Bugzilla report 39439. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java index fffa955f7..1339f92a5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java @@ -95,6 +95,9 @@ public class Cab extends MatchingTask { * Adds a set of files to archive. */ public void addFileset(FileSet set) { + if (filesets.size() > 0) { + throw new BuildException("Only one nested fileset allowed"); + } filesets.addElement(set); } @@ -105,13 +108,17 @@ public class Cab extends MatchingTask { */ protected void checkConfiguration() throws BuildException { if (baseDir == null && filesets.size() == 0) { - throw new BuildException("basedir attribute or at least one " - + "nested filest is required!", + throw new BuildException("basedir attribute or one " + + "nested fileset is required!", getLocation()); } if (baseDir != null && !baseDir.exists()) { throw new BuildException("basedir does not exist!", getLocation()); } + if (baseDir != null && filesets.size() > 0) { + throw new BuildException( + "Both basedir attribute and a nested fileset is not allowed"); + } if (cabFile == null) { throw new BuildException("cabfile attribute must be set!", getLocation()); @@ -179,7 +186,7 @@ public class Cab extends MatchingTask { /** * Get the complete list of files to be included in the cab. Filenames - * are gathered from filesets if any have been added, otherwise from the + * are gathered from the fileset if it has been added, otherwise from the * traditional include parameters. */ protected Vector getFileList() throws BuildException { @@ -188,14 +195,10 @@ public class Cab extends MatchingTask { if (baseDir != null) { // get files from old methods - includes and nested include appendFiles(files, super.getDirectoryScanner(baseDir)); - } - - // get files from filesets - for (int i = 0; i < filesets.size(); i++) { - FileSet fs = (FileSet) filesets.elementAt(i); - if (fs != null) { - appendFiles(files, fs.getDirectoryScanner(getProject())); - } + } else { + FileSet fs = (FileSet) filesets.elementAt(0); + baseDir = fs.getDir(); + appendFiles(files, fs.getDirectoryScanner(getProject())); } return files;