Ant echo-task 和换行

Ant's echo-task and line-wraping

我们需要回显一些相当长的字符串,ant 脚本在 wrapped.

行看起来会更好
<echo file="my.log">Really loooong line, that needs to appear without line breaks in the output, but which I'd still like to wrap in the ant-script</echo>

一般来说,XML 中的换行取决于应用程序——所以我的问题是特定于 ant 应用程序的。我可以在上面的示例中添加换行符 以某种方式 ,但仍然让每一行在输出中显示完整吗?

(使用反斜杠转义换行符 (\) 不起作用...)

将字符串放入 属性,根据需要换行,然后在 echo 任务中使用 属性。

像这样:

<property name="string" value="Really loooong line,
that needs to appear without line breaks in the output,
but which I'd still like to wrap in the ant-script." />    
<echo>${string}</echo>

产生这个输出:

[echo] Really loooong line, that needs to appear without line breaks in the output, but which I'd still like to wrap in the ant-script.

相对于:

<echo>Really loooong line,
that needs to appear without line breaks in the output,
but which I'd still like to wrap in the ant-script.</echo>

产生

[echo] Really loooong line,
[echo] that needs to appear without line breaks in the output,
[echo] but which I'd still like to wrap in the ant-script.

或者将字符串放在消息参数中,这也有效:

<echo message="Really loooong line,
that needs to appear without line breaks in the output,
but which I'd still like to wrap in the ant-script." />