Browse Source

Added loginputstring attribute to redirector.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277628 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 20 years ago
parent
commit
8d779414b7
6 changed files with 76 additions and 9 deletions
  1. +2
    -0
      WHATSNEW
  2. +11
    -4
      docs/manual/CoreTypes/redirector.html
  3. +17
    -0
      src/etc/testcases/types/redirector.xml
  4. +20
    -2
      src/main/org/apache/tools/ant/taskdefs/Redirector.java
  5. +19
    -1
      src/main/org/apache/tools/ant/types/RedirectorElement.java
  6. +7
    -2
      src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java

+ 2
- 0
WHATSNEW View File

@@ -108,6 +108,8 @@ Other changes:
* zip/jar/war/ear supports level attribute for deflate compression level.
Bugzilla report 25513.

* Added loginputstring attribute to the redirector type.

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



+ 11
- 4
docs/manual/CoreTypes/redirector.html View File

@@ -107,10 +107,17 @@ source (input) and destination (output/error) files. <em>Since Ant 1.6.2</em>
<tr>
<td valign="top">alwayslog</td>
<td valign="top">Always send to the log in addition to
any other destination. Default <code>false</code>.
<i>Since Ant 1.6.3</i>.
any other destination. <i>Since Ant 1.6.3</i>.
</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No, default is <code>false</code></td>
</tr>
<tr>
<td valign="top">loginputstring</td>
<td valign="top">Controls the display of <i>inputstring</i>'s value in
log messages. Set to <code>false</code> when sending sensitive data
(e.g. passwords) to external processes. <i>Since Ant 1.6.3</i>.
</td>
<td align="center" valign="top">No, default is <code>true</code></td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
@@ -153,7 +160,7 @@ Tasks known to support I/O redirection:
dependent on the supporting task. Any possible points of confusion
should be noted at the task level.</p>
<hr />
<p align="center">Copyright &copy; 2004 The Apache Software Foundation. All rights
<p align="center">Copyright &copy; 2004-2005 The Apache Software Foundation. All rights
Reserved.</p>

</body>


+ 17
- 0
src/etc/testcases/types/redirector.xml View File

@@ -21,4 +21,21 @@
</redirector>
</target>

<target name="testLogInputString" depends="cat-check" if="can-cat">
<exec executable="cat">
<redirector inputstring="foo" loginputstring="false" />
</exec>
</target>

<target name="cat-check">
<property environment="env" />
<condition property="can-cat">
<or>
<available file="cat" filepath="${env.PATH}" property="can-cat" />
<available file="cat.exe" filepath="${env.PATH}" property="can-cat" />
<available file="cat.exe" filepath="${env.Path}" property="can-cat" />
</or>
</condition>
</target>

</project>

+ 20
- 2
src/main/org/apache/tools/ant/taskdefs/Redirector.java View File

@@ -167,6 +167,9 @@ public class Redirector {
/** The thread group used for starting <code>StreamPumper</code> threads */
private ThreadGroup threadGroup = new ThreadGroup("redirector");

/** whether to log the inputstring */
private boolean logInputString = true;

/**
* Create a redirector instance for the given task
*
@@ -214,6 +217,16 @@ public class Redirector {
this.inputString = inputString;
}

/**
* Set whether to include the value of the input string in log messages.
* Defaults to true.
* @param logInputString true or false.
* @since Ant 1.7
*/
public void setLogInputString(boolean logInputString) {
this.logInputString = logInputString;
}

/**
* Set a stream to use as input.
*
@@ -577,8 +590,13 @@ public class Redirector {
}
((ConcatFileInputStream) inputStream).setManagingComponent(managingTask);
} else if (inputString != null) {
managingTask.log("Using input \"" + inputString + "\"",
Project.MSG_VERBOSE);
StringBuffer buf = new StringBuffer("Using input ");
if (logInputString) {
buf.append('"').append(inputString).append('"');
} else {
buf.append("string");
}
managingTask.log(buf.toString(), Project.MSG_VERBOSE);
inputStream = new ByteArrayInputStream(inputString.getBytes());
}



+ 19
- 1
src/main/org/apache/tools/ant/types/RedirectorElement.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004 The Apache Software Foundation.
* Copyright 2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -98,6 +98,9 @@ public class RedirectorElement extends DataType {
/** The input encoding */
private String inputEncoding;

/** whether to log the inputstring */
private Boolean logInputString;

/**
* Add the input file mapper.
* @param inputMapper <CODE>Mapper</CODE>.
@@ -210,6 +213,18 @@ public class RedirectorElement extends DataType {
this.inputString = inputString;
}

/**
* Set whether to include the value of the input string in log messages.
* Defaults to true.
* @param logInputString true or false.
* @since Ant 1.7
*/
public void setLogInputString(boolean logInputString) {
if (isReference()) {
throw tooManyAttributes();
}
this.logInputString = logInputString ? Boolean.TRUE : Boolean.FALSE;
}

/**
* File the output of the process is redirected to. If error is not
@@ -439,6 +454,9 @@ public class RedirectorElement extends DataType {
if (inputString != null) {
redirector.setInputString(inputString);
}
if (logInputString != null) {
redirector.setLogInputString(logInputString.booleanValue());
}
if (inputMapper != null) {
String[] inputTargets = null;
try {


+ 7
- 2
src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004 The Apache Software Foundation.
* Copyright 2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
*/
package org.apache.tools.ant.types;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildFileTest;

public class RedirectorElementTest extends BuildFileTest {
@@ -25,7 +26,7 @@ public class RedirectorElementTest extends BuildFileTest {
}

public void setUp() {
configureProject("src/etc/testcases/types/redirector.xml");
configureProject("src/etc/testcases/types/redirector.xml", Project.MSG_VERBOSE);
}

public void test1() {
@@ -48,4 +49,8 @@ public class RedirectorElementTest extends BuildFileTest {
executeTarget("test4");
}

public void testLogInputString() {
executeTarget("testLogInputString");
assertDebuglogContaining("Using input string");
}
}

Loading…
Cancel
Save