繁体   English   中英

蚂蚁 <property> 任务:“价值”和“位置”之间有区别吗?

[英]Ant <property> task: is there a difference between 'value' and 'location'?

property设置为引用文件路径时,使用valuelocation参数之间有区别吗?

https://ant.apache.org/manual/Tasks/property.html上的文档指出:

value设置属性的值

location将属性设置为给定文件的绝对文件名。

那么, value一般价值观, location只是文件路径?


在现实生活中的示例中,这两行代码之间有区别吗? 如果是这样,它将产生什么实际影响?

    <property name="cobertura.dir" value="C:/Cobertura/cobertura-1.9" />
    <property name="cobertura.dir" location="C:/Cobertura/cobertura-1.9" />

您已经参考过的ANT手册中对此进行了说明...

location : Sets the property to the absolute filename of the given file. 
If the value of this attribute is an absolute path, it is left unchanged (with / and \ characters converted to the current platforms conventions). 
Otherwise it is taken as a path relative to the project's basedir and expanded.

因此,您可以选择指定绝对/相对路径。

因此,如果要进行相对路径,则使用位置。 如果您要执行绝对路径,则可以使用位置或值(互斥)

万一它对其他人有帮助:

http://www.javapractices.com/topic/TopicAction.do?Id=135上 ,作者建议:

对于代表文件或目录的属性,请使用“位置”属性,而不是“值”

.properties文件等同于使用<property name='x' value='y'>因为未使用'location'属性。 不建议将其用于文件和目录,因为这不会解析相对引用。 如果确实在属性文件中指定位置,则该位置应该是绝对的,而不是相对的。 此外,您需要转义反斜杠。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM