tags:

views:

316

answers:

3

Is there an Ant equivalent to the 'profile' concept in Maven?

I'd like to be able to specify a different set of targets to build (out of one Ant file) depending on an argument. So in Maven I can specify a profile and then activate it like so: mvn groupId:artifactId:goal -Denvironment=test

So say my build.xml contains:

<target name="profile1">...</>

and

<target name="profile2">...</>

How could I specify at compile time which I want to execute?

+1  A: 

You can read properties from files using the property or loadproperties tasks.

Depending on exactly what you're trying to replicate this might do.

Dave Webb
Thx. I already have properties being injected... this isn't quite what I'm looking for. I updated the question with more specific details.
Cuga
+1  A: 

You can pass arguments to ant when you invoke it

ant -DProfile=foo

Then ${Profile} will substitute for foo

This is a sucky workaround but it should be able to pass arguments via the command line if that is your goal.

sal
A: 

For the first case: "ant profile1". The second case is left as an exercise.

Seriously, the list of targets you want to execute is already an argument to ant. I think you need to make your example a little more explicit.

Zac Thompson