Friday, March 24, 2017

Ant notes

Multiple environments - properties overrides

By defining property files first one will override the next one that is defined:

<property file="build.${user.name}.properties" description="Local customizations, overrides"/>
<property file="build.properties" />


This means if you have property named databaseUrl defined in both files, the one with your username will have more precedence.

To ignore overrides that are based on user.name one can use antcall task instead depends and override params.
Example is bellow. In it you can override properties someParameter_1 and someParameter_2, by using antcall.

<target name="dist">

<antcall target="build">
<param name="someParameter_1" value="newValue"/>
<param name="someParameter_2" value="newValue"/>
</antcall>

<delete dir="${dist.dir}" />
<mkdir dir="${dist.dir}" />

<tar destfile="${dist.dir}/myProduct-${version}.tar.gz" compression="gzip">
<tarfileset dir="${build.dir}" />
</tar>
</target>


Ref

Managing Multiple Build Environments
Built-in Ant Properties
Apache Ant Wiki
AntCall

No comments:

Post a Comment