Ant, subprojects, and properties

how-to
Sep 16, 20091 min

Today I had to spend some reasonable amount of time to solve the problem related to Ant subprojects – Ant projects that are called with task from the master Ant project. Yes, some masochists are still using weird complex build procedures based on Ant subprojects 🙂 My problem was that it appeared impossible to pass a property from Ant subproject up to the master. And I desperately needed to propagate the status of some subproject’s junit task up to the master project. The approach that I finally worked out – use of temp properties files. You fill in the temp properties file in the subproject, then read it in the master projects like this: master project:


<ant dir="subproject"/>
<property file="${some_temp_dir}/tmp.properties"/>
<echo message="${propFromSubProject}"/>

subproject:


<propertyfile file="${some_temp_dir}/tmp.properties">
<entry key="propFromSubProject" value="hello"/>
</propertyfile>