Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Inheritance Ant属性文件可以定义继承吗?_Inheritance_Ant - Fatal编程技术网

Inheritance Ant属性文件可以定义继承吗?

Inheritance Ant属性文件可以定义继承吗?,inheritance,ant,Inheritance,Ant,我希望使用Ant属性文件,以便一个属性文件继承另一个属性文件,但我不确定这是否可行 例如: base.properties: prop1=base child.properties (inherit from base.properties): prop1=child // this should override prop1 in base.properties 我知道我可以通过cmd行以正确的顺序传递它们,但我希望通过在文件本身中定义继承来实现 你知道我怎样才能做到这一点吗 谢谢 蚂蚁属

我希望使用Ant属性文件,以便一个属性文件继承另一个属性文件,但我不确定这是否可行

例如:

base.properties:
prop1=base

child.properties (inherit from base.properties):
prop1=child // this should override prop1 in base.properties
我知道我可以通过cmd行以正确的顺序传递它们,但我希望通过在文件本身中定义继承来实现

你知道我怎样才能做到这一点吗


谢谢

蚂蚁属性是不可变的。如果首先加载child.properties,则将使用其中的所有属性定义,而不是base.properties

这也是命令行重写工作的原因


因此,按照从子级到父级的顺序加载文件,您将有一些层次结构的相似性。

核心Ant不支持您所查找的内容

典型的模式是以级联方式在构建文件中加载属性,例如:

<property file="${user.home}/${product}/${product.version}/build.properties"/>
<property file="${user.home}/${product}/build.properties"/>
<property file="${user.home}/build.properties"/>
<property file="build.properties"/>


这些文件并不都需要存在。无论存在哪个文件,都将按该顺序加载。这提供了有选择地覆盖属性的简单方法。

正确。在这种情况下,如果属性文件的顺序正确,它们基本上会覆盖基础。但是有没有一种方法可以基于文件中定义的继承进行重写?