在 Ant 中可以延迟或阻止 属性 求值吗?

Can property evaluation be delayed or prevented in Ant?

我有一个第三方 Tomcat webapp,它配置了一个在部署前用 ant 处理过的 .properties 文件。

一个 属性 DB.cache.dir 定义将在何处创建一些临时文件。我希望这个 属性 到 逐字地评估 ${java.io.tmpdir}。目的是当 运行 时,webapp 将使用 Tomcat 运行 的 java.io.tmpdir 值,而不是 ant 配置时的值。

我尝试使用 \ escape 但运气不好,无法在网上找到答案。

请指教

# How to prevent evaluation for this property?
DB.cache.dir=${java.io.tmpdir}

您需要用另一个美元符号转义美元符号,例如:

DB.cache.dir=$${java.io.tmpdir}

来自 Ant 文档中的 Properties, Property Expansion, $$ Expansion

In its default configuration Ant will expand the text $$ to a single $ and suppress the normal property expansion mechanism for the text immediately following it, i.e., $${key} expands to ${key} and not value even though a property named key was defined and had the value value.