示例脚本:
<property name="foo" value="bar" />
<script language="javascript"> <![CDATA[
var echoTest = project.createTask("echo");
echoTest.setMessage("${toString:foo}");
echoTest.perform();
echoTest = project.createTask("echo");
echoTest.setMessage("${foo}");
echoTest.perform();
</script>
预期产出:
[echo] bar
[echo] bar
实际输出:
[echo] ${toString:foo}
[echo] ${foo}
...
那么如何执行Ant所做的字符串扩展呢?
答案 0 :(得分:0)
找到了解决方案。
function antResolveProperty(value) {
var propertyHelper = Packages.org.apache.tools.ant.PropertyHelper.getPropertyHelper(project);
return String(propertyHelper.replaceProperties(value));
}