FAQ
Repository: ant
Updated Branches:
   refs/heads/1.9.x 0edf3ca25 -> de5b4058b


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/1.9.x
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

  • Bodewig at May 22, 2016 at 3:17 pm
    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>
  • Bodewig at May 22, 2016 at 3:17 pm
    Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/ant


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

    Branch: refs/heads/master
    Commit: 440021dbf9111717ccc2a30c99087e71c3a39001
    Parents: 73bcc28 f44dd82
    Author: Stefan Bodewig <bodewig@apache.org>
    Authored: Sun May 22 17:17:24 2016 +0200
    Committer: Stefan Bodewig <bodewig@apache.org>
    Committed: Sun May 22 17:17:24 2016 +0200

    ----------------------------------------------------------------------
      build.xml | 22 +++++++++++-----------
      1 file changed, 11 insertions(+), 11 deletions(-)
    ----------------------------------------------------------------------
  • Bodewig at May 22, 2016 at 3:17 pm
    Merge branch '1.9.x'


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

    Branch: refs/heads/master
    Commit: 73bcc2813a6a61eeeefce554bb922531c7353183
    Parents: 3c37952 de5b405
    Author: Stefan Bodewig <bodewig@apache.org>
    Authored: Sun May 22 17:16:37 2016 +0200
    Committer: Stefan Bodewig <bodewig@apache.org>
    Committed: Sun May 22 17:16:37 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/73bcc281/WHATSNEW
    ----------------------------------------------------------------------
    diff --cc WHATSNEW
    index 3420958,25a0464..d91c476
    --- a/WHATSNEW
    +++ b/WHATSNEW
    @@@ -4,12 -4,11 +4,17 @@@ Changes from Ant 1.9.7 TO Ant 1.10.
       Changes that could break older environments:
       -------------------------------------------

      + * Ant 1.10.x requires Java8 or newer at compile or build time.
      + The 1.9.x series wil stay compatible with Java5.
      +
      + * The <apt> task has been removed since apt itself has been removed
      + with Java8.
      +
    + * <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/73bcc281/src/main/org/apache/tools/ant/types/AbstractFileSet.java
    ----------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
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 © 2018 Grokbase