Browse Source

Add ignoremissing attribute to <apply>.

PR:  29585


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276587 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 21 years ago
parent
commit
5f9698fab4
5 changed files with 69 additions and 2 deletions
  1. +6
    -0
      WHATSNEW
  2. +6
    -0
      docs/manual/CoreTasks/apply.html
  3. +41
    -0
      src/etc/testcases/taskdefs/exec/apply.xml
  4. +12
    -2
      src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  5. +4
    -0
      src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java

+ 6
- 0
WHATSNEW View File

@@ -33,6 +33,10 @@ Other changes:
* A new base class DispatchTask has been added to facilitate elegant
creation of tasks with multiple actions.

* <apply> has a new ignoremissing attribute (default true for BC)
which will allow nonexistent files specified via <filelist>s to
be passed to the executable. Bugzilla Report 29585.

Changes from Ant 1.6.1 to current Ant 1.6 CVS version
=====================================================

@@ -229,6 +233,8 @@ Other changes:

* Add deleteonexit attribute to <delete>.

* Added Target.getIf/Unless(). Bugzilla Report 29320.

Changes from Ant 1.6.0 to Ant 1.6.1
=============================================



+ 6
- 0
docs/manual/CoreTasks/apply.html View File

@@ -248,6 +248,12 @@ to send input to it is via the input and inputstring attributes.</p>
Defaults to <code>false</code>. <em>Since Ant 1.6.</em></td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">ignoremissing</td>
<td valign="top">Whether to ignore nonexistent files specified
via filelists. <em>Since Ant 1.7.</em></td>
<td align="center" valign="top">No, default is <i>true</i></td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>fileset</h4>


+ 41
- 0
src/etc/testcases/taskdefs/exec/apply.xml View File

@@ -303,6 +303,47 @@
</apply>
</target>

<target name="ignoremissing">
<filelist id="xylist" dir="${basedir}" files="x,y" />
<filelist id="xyzlist" dir="${basedir}" files="x,y,z" />

<touch file="x" />
<touch file="y" />

<pathconvert property="xy" pathsep="${line.separator}">
<path>
<filelist refid="xylist" />
</path>
</pathconvert>

<pathconvert property="xyz" pathsep="${line.separator}">
<path>
<filelist refid="xyzlist" />
</path>
</pathconvert>

<apply executable="echo" ignoremissing="true"
outputproperty="ignoretrue" append="true">
<filelist refid="xyzlist" />
</apply>

<apply executable="echo" ignoremissing="false"
outputproperty="ignorefalse" append="true">
<filelist refid="xyzlist" />
</apply>

<fail>
<condition>
<not>
<and>
<equals arg1="${xy}" arg2="${ignoretrue}" />
<equals arg1="${xyz}" arg2="${ignorefalse}" />
</and>
</not>
</condition>
</fail>
</target>

<target name="cleanup">
<delete>
<fileset refid="xyz" />


+ 12
- 2
src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java View File

@@ -71,6 +71,7 @@ public class ExecuteOn extends ExecTask {
private int maxParallel = -1;
private boolean addSourceFile = true;
private boolean verbose = false;
private boolean ignoreMissing = true;

/**
* Has &lt;srcfile&gt; been specified before &lt;targetfile&gt;
@@ -182,6 +183,15 @@ public class ExecuteOn extends ExecTask {
verbose = b;
}

/**
* Whether to ignore nonexistent files from filelists.
*
* @since Ant 1.7
*/
public void setIgnoremissing(boolean b) {
ignoreMissing = b;
}

/**
* Marker that indicates where the name of the source file should
* be put on the command line.
@@ -354,10 +364,10 @@ public class ExecuteOn extends ExecTask {

for (int j = 0; j < names.length; j++) {
File f = new File(base, names[j]);
if ((f.isFile() && !"dir".equals(type))
if ((!ignoreMissing) || (f.isFile() && !"dir".equals(type))
|| (f.isDirectory() && !"file".equals(type))) {

if (f.isFile()) {
if (ignoreMissing || f.isFile()) {
totalFiles++;
} else {
totalDirs++;


+ 4
- 0
src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java View File

@@ -550,6 +550,10 @@ public class ExecuteOnTest extends BuildFileTest {
assertNull("unexpected redirector.err content", getFileString("redirector.err"));
}

public void testIgnoreMissing() {
executeTarget("ignoremissing");
}

//borrowed from TokenFilterTest
private String getFileString(String filename) throws IOException {
String result = null;


Loading…
Cancel
Save