https://bz.apache.org/bugzilla/show_bug.cgi?id=59402master
| @@ -4,6 +4,11 @@ Changes from Ant 1.9.7 TO Ant 1.9.8 | |||||
| Changes that could break older environments: | 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: | Fixed bugs: | ||||
| ----------- | ----------- | ||||
| @@ -50,7 +50,7 @@ equivalent to an <code><and></code> selector container.</p> | |||||
| <tr> | <tr> | ||||
| <td valign="top">dir</td> | <td valign="top">dir</td> | ||||
| <td valign="top">the root of the directory tree of this FileSet.</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> | ||||
| <tr> | <tr> | ||||
| <td valign="top">file</td> | <td valign="top">file</td> | ||||
| @@ -382,7 +382,6 @@ public abstract class AbstractJarSignerTask extends Task { | |||||
| FileSet sourceJar = new FileSet(); | FileSet sourceJar = new FileSet(); | ||||
| sourceJar.setProject(getProject()); | sourceJar.setProject(getProject()); | ||||
| sourceJar.setFile(jar); | sourceJar.setFile(jar); | ||||
| sourceJar.setDir(jar.getParentFile()); | |||||
| sources.add(sourceJar); | sources.add(sourceJar); | ||||
| } | } | ||||
| return sources; | return sources; | ||||
| @@ -67,6 +67,7 @@ public abstract class AbstractFileSet extends DataType | |||||
| private List<FileSelector> selectors = new ArrayList<FileSelector>(); | private List<FileSelector> selectors = new ArrayList<FileSelector>(); | ||||
| private File dir; | private File dir; | ||||
| private boolean fileAttributeUsed; | |||||
| private boolean useDefaultExcludes = true; | private boolean useDefaultExcludes = true; | ||||
| private boolean caseSensitive = true; | private boolean caseSensitive = true; | ||||
| private boolean followSymlinks = true; | private boolean followSymlinks = true; | ||||
| @@ -131,6 +132,9 @@ public abstract class AbstractFileSet extends DataType | |||||
| if (isReference()) { | if (isReference()) { | ||||
| throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
| } | } | ||||
| if (fileAttributeUsed && !getDir().equals(dir)) { | |||||
| throw dirAndFileAreMutuallyExclusive(); | |||||
| } | |||||
| this.dir = dir; | this.dir = dir; | ||||
| directoryScanner = null; | directoryScanner = null; | ||||
| } | } | ||||
| @@ -228,7 +232,11 @@ public abstract class AbstractFileSet extends DataType | |||||
| if (isReference()) { | if (isReference()) { | ||||
| throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
| } | } | ||||
| if (getDir() != null) { | |||||
| throw dirAndFileAreMutuallyExclusive(); | |||||
| } | |||||
| setDir(file.getParentFile()); | setDir(file.getParentFile()); | ||||
| fileAttributeUsed = true; | |||||
| createInclude().setName(file.getName()); | createInclude().setName(file.getName()); | ||||
| } | } | ||||
| @@ -919,4 +927,8 @@ public abstract class AbstractFileSet extends DataType | |||||
| setChecked(true); | setChecked(true); | ||||
| } | } | ||||
| } | } | ||||
| private BuildException dirAndFileAreMutuallyExclusive() { | |||||
| return new BuildException("you can only specify one of the dir and file attributes"); | |||||
| } | |||||
| } | } | ||||
| @@ -64,4 +64,22 @@ | |||||
| <au:assertLogContains text="fileset-test.xml"/> | <au:assertLogContains text="fileset-test.xml"/> | ||||
| </target> | </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> | </project> | ||||