git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277628 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -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 | |||
| ===================================================== | |||
| @@ -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 © 2004 The Apache Software Foundation. All rights | |||
| <p align="center">Copyright © 2004-2005 The Apache Software Foundation. All rights | |||
| Reserved.</p> | |||
| </body> | |||
| @@ -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> | |||
| @@ -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()); | |||
| } | |||
| @@ -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 { | |||
| @@ -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"); | |||
| } | |||
| } | |||