Ant 类路径结构是否像属性一样不可变?
Are Ant path-like structures immutable like properties?
Ant 手册非常清楚 properties are immutable(ie 一旦设置了 属性 值,后续 <property>
将无法更改元素):
Property
Description
Sets a property (by name and value), or set of properties (from file or resource) in the project. Properties are case sensitive.
Properties are immutable: whoever sets a property first freezes it for the rest of the build; they are most definitely not variables.
我想了解 path-like structures 是否与 <path>
、<classpath>
等一样。它并没有在 Ant 手册中向我跳出来。
与属性不同,类路径结构在 Ant 中是可变的。每次后续更新都会更改以前的版本。
输入build.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="AntPathTest" basedir=".">
<property name="foo" value="bar"/>
<property name="foo" value="baz"/>
<path id="spam">
<pathelement path="ham"/>
</path>
<path id="spam">
<pathelement path="eggs"/>
</path>
<echo message="foo => ${foo}"/>
<pathconvert property="spam" refid="spam"/>
<echo message="spam => ${spam}"/>
</project>
来自 $ ant
的输出
Buildfile: /path/to/AntPathTest/build.xml
[echo] foo => bar
[echo] spam => /path/to/AntPathTest/eggs
Ant 手册非常清楚 properties are immutable(ie 一旦设置了 属性 值,后续 <property>
将无法更改元素):
Property
Description
Sets a property (by name and value), or set of properties (from file or resource) in the project. Properties are case sensitive.
Properties are immutable: whoever sets a property first freezes it for the rest of the build; they are most definitely not variables.
我想了解 path-like structures 是否与 <path>
、<classpath>
等一样。它并没有在 Ant 手册中向我跳出来。
与属性不同,类路径结构在 Ant 中是可变的。每次后续更新都会更改以前的版本。
输入build.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="AntPathTest" basedir=".">
<property name="foo" value="bar"/>
<property name="foo" value="baz"/>
<path id="spam">
<pathelement path="ham"/>
</path>
<path id="spam">
<pathelement path="eggs"/>
</path>
<echo message="foo => ${foo}"/>
<pathconvert property="spam" refid="spam"/>
<echo message="spam => ${spam}"/>
</project>
来自 $ ant
的输出
Buildfile: /path/to/AntPathTest/build.xml
[echo] foo => bar
[echo] spam => /path/to/AntPathTest/eggs