Reputation: 531
I have a project with 3 targets for different build variants each having their own property file defined like this:
<target name="dev">
<property file="dev.properties" />
<antcall target="build" />
</target>
<target name="test">
<property file="test.properties" />
<antcall target="build" />
</target>
<target name="prod">
<property file="prod.properties" />
<antcall target="build" />
</target>
All property files define the same properties. Now I need to make a target which would build them all, I tried something like:
<target name="all">
<antcall target="dev" />
<antcall target="test" />
<antcall target="prod" />
</target>
But the problem is that ant properties are immutable and I end up with properties from dev.properties for all builds. What's the recommended approach if I want to build all three targets with their own properties?
Upvotes: 1
Views: 374
Reputation: 77931
Wouldn't it be a lot simpler to have a single build script, and then decide it's purpose at run-time?
For example:
ant -propertyfile build-dev.properties
ant -propertyfile build-test.properties
ant -propertyfile build-prod.properties
..
This approach is more flexible when automating your builds using something like Jenkins. It can detect source code changes and run each build type automatically (and in parallel) if that is the desired outcome.
Upvotes: 2