Is there a way to conditionally set a property?
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Travis_Prescott
Posted On:   Thursday, January 17, 2002 08:50 AM

I would like to push my build to a different location based upon the user’s input. For example, a user could call ant using –Dinput=value. Based on the value, I envision ant setting a property indicating the location the build is to be moved. And ideally, I could drive this from a property file so I could change the locations at will with no changes to the build file. Basically, I am trying to abstract the location of the build so that the user only knows he/she is pushing to “test” and not have to know the fully qualified network location. I have read quite a bit on , , and some on the conditional logic in ant. I still can’t seem to stumble on a simple solution. Does anyone have ideas on a good way to do this?

Re: Is there a way to conditionally set a property?

Posted By:   Erik_Hatcher  
Posted On:   Thursday, January 17, 2002 10:19 AM

You can just build a path based on the value of 'input':




Would this do the trick? If you need more control you can use or conditional targets with if/unless attributes.

Re: Is there a way to conditionally set a property?

Posted By:   Travis_Prescott  
Posted On:   Thursday, January 17, 2002 09:12 AM

I got it and thought I'd post a solution. It is painfully easy - guess I was just looking in the wrong direction.

The following will work using . It will print "success" b/c, obviously, ${test1} == ${test1}. Changing the args to ${test1} and ${test2} will fail the test and set the property ${test} will not be set. Sorry for all the posts :-)















test=${test}


Re: Is there a way to conditionally set a property?

Posted By:   Travis_Prescott  
Posted On:   Thursday, January 17, 2002 08:58 AM

I just found which seems to work when the condition depends on system resources but to further explain/confuse the above, I think that I am looking to set a property based on the value of *another* property. This would give me a solution but still may not be ideal - I am sure that there are better ways to do this...
About | Sitemap | Contact