FAQ
Repository: ant
Updated Branches:
   refs/heads/master f44dd8255 -> 440021dbf


must not set file and dir in <fileset>

https://bz.apache.org/bugzilla/show_bug.cgi?id=59402


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/de5b4058
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/de5b4058
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/de5b4058

Branch: refs/heads/master
Commit: de5b4058b9bb039cdb17082fc543098de598ece2
Parents: 0edf3ca
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Sun May 22 16:33:24 2016 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Sun May 22 17:07:03 2016 +0200

----------------------------------------------------------------------
  WHATSNEW | 5 +++++
  manual/Types/fileset.html | 2 +-
  .../tools/ant/taskdefs/AbstractJarSignerTask.java | 1 -
  .../apache/tools/ant/types/AbstractFileSet.java | 12 ++++++++++++
  src/tests/antunit/types/fileset-test.xml | 18 ++++++++++++++++++
  5 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/de5b4058/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index e01128c..25a0464 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -4,6 +4,11 @@ Changes from Ant 1.9.7 TO Ant 1.9.8
  Changes that could break older environments:
  -------------------------------------------

+ * <fileset>/<zipfileset>/<tarfileset> exhibited undefined
+ behavior when both the dir and file attribute have been used on the
+ same instance. This will now cause the build to fail.
+ Bugzilla Report 59402
+
  Fixed bugs:
  -----------


http://git-wip-us.apache.org/repos/asf/ant/blob/de5b4058/manual/Types/fileset.html
----------------------------------------------------------------------
diff --git a/manual/Types/fileset.html b/manual/Types/fileset.html
index 9a7c7d7..3d90172 100644
--- a/manual/Types/fileset.html
+++ b/manual/Types/fileset.html
@@ -50,7 +50,7 @@ equivalent to an <code>&lt;and&gt;</code> selector container.</p>
    <tr>
      <td valign="top">dir</td>
      <td valign="top">the root of the directory tree of this FileSet.</td>
- <td valign="middle" align="center" rowspan="2">Either dir or file must be specified</td>
+ <td valign="middle" align="center" rowspan="2">Exactly one of dir or file must be specified</td>
    </tr>
    <tr>
      <td valign="top">file</td>

http://git-wip-us.apache.org/repos/asf/ant/blob/de5b4058/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java b/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
index bc8c031..c93173b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
@@ -382,7 +382,6 @@ public abstract class AbstractJarSignerTask extends Task {
              FileSet sourceJar = new FileSet();
              sourceJar.setProject(getProject());
              sourceJar.setFile(jar);
- sourceJar.setDir(jar.getParentFile());
              sources.add(sourceJar);
          }
          return sources;

http://git-wip-us.apache.org/repos/asf/ant/blob/de5b4058/src/main/org/apache/tools/ant/types/AbstractFileSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/AbstractFileSet.java b/src/main/org/apache/tools/ant/types/AbstractFileSet.java
index 8f274a0..e3b8aa8 100644
--- a/src/main/org/apache/tools/ant/types/AbstractFileSet.java
+++ b/src/main/org/apache/tools/ant/types/AbstractFileSet.java
@@ -67,6 +67,7 @@ public abstract class AbstractFileSet extends DataType
      private List<FileSelector> selectors = new ArrayList<FileSelector>();

      private File dir;
+ private boolean fileAttributeUsed;
      private boolean useDefaultExcludes = true;
      private boolean caseSensitive = true;
      private boolean followSymlinks = true;
@@ -131,6 +132,9 @@ public abstract class AbstractFileSet extends DataType
          if (isReference()) {
              throw tooManyAttributes();
          }
+ if (fileAttributeUsed && !getDir().equals(dir)) {
+ throw dirAndFileAreMutuallyExclusive();
+ }
          this.dir = dir;
          directoryScanner = null;
      }
@@ -228,7 +232,11 @@ public abstract class AbstractFileSet extends DataType
          if (isReference()) {
              throw tooManyAttributes();
          }
+ if (getDir() != null) {
+ throw dirAndFileAreMutuallyExclusive();
+ }
          setDir(file.getParentFile());
+ fileAttributeUsed = true;
          createInclude().setName(file.getName());
      }

@@ -919,4 +927,8 @@ public abstract class AbstractFileSet extends DataType
              setChecked(true);
          }
      }
+
+ private BuildException dirAndFileAreMutuallyExclusive() {
+ return new BuildException("you can only specify one of the dir and file attributes");
+ }
  }

http://git-wip-us.apache.org/repos/asf/ant/blob/de5b4058/src/tests/antunit/types/fileset-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/types/fileset-test.xml b/src/tests/antunit/types/fileset-test.xml
index 9580a1c..ea39dec 100644
--- a/src/tests/antunit/types/fileset-test.xml
+++ b/src/tests/antunit/types/fileset-test.xml
@@ -64,4 +64,22 @@
      <au:assertLogContains text="fileset-test.xml"/>
    </target>

+ <target name="test-fileset-dir-and-file-exception">
+ <mkdir dir="${output}"/>
+ <au:expectfailure expectedmessage="you can only specify one of the dir and file attributes">
+ <copy todir="${output}">
+ <fileset dir="foo" file="bar" />
+ </copy>
+ </au:expectfailure>
+ </target>
+
+ <target name="test-fileset-file-and-dir-exception">
+ <mkdir dir="${output}"/>
+ <au:expectfailure expectedmessage="you can only specify one of the dir and file attributes">
+ <copy todir="${output}">
+ <fileset file="bar" dir="foo"/>
+ </copy>
+ </au:expectfailure>
+ </target>
+
  </project>

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 4 | next ›
Discussion Overview
groupnotifications @
categoriesant
postedMay 22, '16 at 3:15p
activeMay 22, '16 at 3:17p
posts4
users1
websiteant.apache.org

1 user in discussion

Bodewig: 4 posts

People

Translate

site design / logo © 2017 Grokbase