This works for me: in the main project file, the default target value depends on the target from commontasks.xml, which depends on the target from the main project file:
<project name="main" default="default">
<import file="commontasks.xml" as="common" />
<target name="default" depends="common.hello" description="the main project">
</target>
<target name="initMain">
<echo>initializing main</echo>
<property name="aValue" value="MAIN" />
</target>
<project name="commontasks" >
<target name="hello" depends="initMain">
<echo>hello from common tasks</echo>
<echo>aValue: ${aValue}</echo>
</target>
When I run the ant construct, I get:
initMain:
[echo] initializing main
common.hello:
[echo] hello from common tasks
[echo] aValue: MAIN
default:
BUILD SUCCESSFUL
The dependency of target defaultdepends on hellodepends on initMain, and hellocan use the properties defined in initMain.
source
share