目前我正在使用以下解决方法(在此处描述)来隐藏“mypassword”,但我想知道是否有更优雅的解决方案?
构建.xml
<?xml version="1.0" encoding="UTF-8"?>
<project default="test">
<target name="test" depends="">
<echo message="Testing..."/>
<echo message="Turning verbose off... you should NOT see the arguments..."/>
<script language="javascript">
var logger = project.getBuildListeners().firstElement();
// 2 works to turn off verbose
logger.setMessageOutputLevel(2);
</script>
<exec dir="." executable="cmd">
<arg line="/c dummy.bat mypassword"/>
</exec>
<echo message="Turning verbose on... you should see the arguments..."/>
<script language="javascript">
var logger = project.getBuildListeners().firstElement();
// 3 works to turn verbose back on
logger.setMessageOutputLevel(3);
</script>
<exec dir="." executable="cmd">
<arg line="/c dummy.bat mypassword"/>
</exec>
</target>
</project>
假人.bat
@echo off
echo dummy
输出
test:
[echo] Testing...
[echo] Turning verbose off... you should NOT see the arguments...
[exec] dummy
[echo] Turning verbose on... you should see the arguments...
[exec] Current OS is Windows XP
[exec] Executing 'cmd' with arguments:
[exec] '/c'
[exec] 'dummy.bat'
[exec] 'mypassword'
[exec]
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
[exec] dummy