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.
Ant的配置文件 - build.xml具有property元素。根据官方文档,该属性具有属性值和位置。但我不明白为什么我们需要位置?我可以将路径设置为属性中的值吗?然后不需要位置。
2 个解决方案
#1
3
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
注意在这个例子中,他们使用位置。不需要绝对路径。 http://ant.apache.org/manual/using.html
either location or value (mutually exclusive) can be used if you're doing absolute paths
如果您正在执行绝对路径,则可以使用位置或值(互斥)
#2
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
资料来源: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.
例如,有人想在变量中存储lib目录路径然后可以如下所示完成。
<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>.
#1
3
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
注意在这个例子中,他们使用位置。不需要绝对路径。 http://ant.apache.org/manual/using.html
either location or value (mutually exclusive) can be used if you're doing absolute paths
如果您正在执行绝对路径,则可以使用位置或值(互斥)
#2
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
资料来源: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.
例如,有人想在变量中存储lib目录路径然后可以如下所示完成。
<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>.