Browse Source

Merge branch '1.9.x'

master
Stefan Bodewig 9 years ago
parent
commit
73bcc2813a
5 changed files with 36 additions and 2 deletions
  1. +5
    -0
      WHATSNEW
  2. +1
    -1
      manual/Types/fileset.html
  3. +0
    -1
      src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java
  4. +12
    -0
      src/main/org/apache/tools/ant/types/AbstractFileSet.java
  5. +18
    -0
      src/tests/antunit/types/fileset-test.xml

+ 5
- 0
WHATSNEW View File

@@ -10,6 +10,11 @@ Changes that could break older environments:
* 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:
-----------



+ 1
- 1
manual/Types/fileset.html View File

@@ -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>


+ 0
- 1
src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java View File

@@ -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;


+ 12
- 0
src/main/org/apache/tools/ant/types/AbstractFileSet.java View File

@@ -70,6 +70,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;
@@ -134,6 +135,9 @@ public abstract class AbstractFileSet extends DataType
if (isReference()) {
throw tooManyAttributes();
}
if (fileAttributeUsed && !getDir().equals(dir)) {
throw dirAndFileAreMutuallyExclusive();
}
this.dir = dir;
directoryScanner = null;
}
@@ -231,7 +235,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());
}

@@ -943,4 +951,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");
}
}

+ 18
- 0
src/tests/antunit/types/fileset-test.xml View File

@@ -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>

Loading…
Cancel
Save