Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 853
roast_soul Avatar asked Jan 31 '13 14:01

roast_soul


People also ask

What is an Ant value?

Ant properties are key, value pairs you can configure inside your Ant build script. Typically you use properties for values that you need to refer to multiple times in your Ant build script. For instance, the source directory of your Java code, or the build output directory.

How do I override property value in Ant?

Ant Properties are set once and then can never be overridden. That's why setting any property on the command line via a -Dproperty=value will always override anything you've set in the file; the property is set and then nothing can override it. This way: Anything set at the command line takes precedence over build.

How do you set an Ant property?

The <property> task is used to set the Ant properties. The property value is immutable, once the value is set you cannot change it. To set a property to a specific value you use Name/value assignment. To set a property to a location you use Name/location assignment.


2 Answers

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

like image 124
fduso Avatar answered Oct 03 '22 13:10

fduso


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>.
like image 34
Subba Avatar answered Oct 03 '22 13:10

Subba