What‘s the difference between ant's property value and property location

落花浮王杯 提交于 2019-12-10 14:57:59

问题


Ant's config file--build.xml has the property element. And according to the offical-doc,the property has the attributes-value and location. But I don't understand why we need location? Can I set the path as a value in property? Then no need for location.


回答1:


location is used if you want to do relative paths.

notice in this example, they use location. no absolute path needed. http://ant.apache.org/manual/using.html

either location or value (mutually exclusive) can be used if you're doing absolute paths




回答2:


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.

Source : http://ant.apache.org/manual/Tasks/property.html

Example, someone want to store lib dir path in a variable then it can be done as shown below.

<property name="lib.dir" location ="project_home/lib"/>

and you can use the above property as shown below.

<fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
        </fileset>.


来源:https://stackoverflow.com/questions/14628457/what-s-the-difference-between-ants-property-value-and-property-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!