I tried my hands on, but I am afraid that we can not set environment variable using ant.
Vijaykumar Patil
Greenhorn
Joined: Jan 15, 2013
Posts: 6
posted
0
Hi Harshavardhan,
Thanks for the reply and trying it.
After googling, I came to know that we can set the environment variable using a wrapper shell script.
But I need an working example if anybody has here. As I also tried, but no luck.
It did get set, but only in the shell launched by Ant. Once that shell exited, the value disappeared. I think that even is you ran "sh sample.sh" that foo would not be set in your shell, you would have to do something like ". sample.sh" which causes the script to be run in your current shell.
But rather that trying to do something that is impossible, why don't you tell us why your real requirements are, we might be able to provide some suggestions. Being able to set an env var via Ant is a proposed technical solution to a problem, it is not a requirement. Tell us what the problem is.
I agree with you that the env var foo will not set in the current shell.
But how to set in the current shell? is there any way to do it by ant?
Yes, ". sample.sh" or "source sample.sh" will set the env var foo to bar.
How to do it using ant (build.xml) ?
The requirement is:
If ant runs the target new_target, should set the env var foo to bar.
$ ant new_target