简体   繁体   中英

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

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.

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

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>.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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