I am trying to use ant's include or import tasks to use a common build file. I am stuck at retrieving properties from included file.
These are my non-working samples, trying to retrieve "child-property"
Using ant import
parent file
<?xml version="1.0" encoding="UTF-8"?>
<project name="parent" basedir=".">
<import file="child.xml" />
<target name="parent-target">
<antcall target="child-target" />
<echo message="(From Parent) ${child-property}" />
</target>
</project>
child file
<?xml version="1.0" encoding="UTF-8"?>
<project name="child" basedir=".">
<target name="child-target">
<property name="child-property" value="i am child value" />
<echo message="(From Child) ${child-property}" />
</target>
</project>
output
parent-target:
child-target:
[echo] (From Child) i am child value
[echo] (From Parent) ${child-property}
Using ant include
parent file
<project name="parent" basedir=".">
<include file="child.xml" />
<target name="parent-target">
<antcall target="child.child-target" />
<echo message="(From Parent) ${child-property}" />
<echo message="(From Parent2) ${child.child-property}" />
</target>
</project>
child file
same as above
output
parent-target:
child.child-target:
[echo] (From Child) i am child value
[echo] (From Parent) ${child-property}
[echo] (From Parent2) ${child.child-property}
How can I access "child-property" from parent?