1

I want in my ant target set value of enviroment with name "project_env", but I cant understand how... I tried this:

 <exec executable="export" >
  <env key="PROJECT_ENV" value="prod"/>
</exec>

but I see only error

Execute failed: java.io.IOException: Cannot run program "export": java.io.IOException: error=2, No such file or directory

Where is my mistake?

bearhunterUA
  • 259
  • 5
  • 15

2 Answers2

2

If you want to achieve specfic export var on unix or its set counterpart on windows. This is just ant's style & allows you to have exports of variables within/specific to targets

<exec executable="sh">
   <arg value="export PROJECT_ENV=prod"/>
</exec>
1

The export command is a shell command, specific to certain command shells, not a separate executable. That's why you're getting that error.

You could wrap the execution of your ant script in a shell script. The shell script would set any prerequisite environment variables, then call ant. For example:

#!/bin/bash
export PROJECT_ENV=prod
ant -f build.xml
dgwatson
  • 66
  • 6
  • You might also want to look at http://stackoverflow.com/questions/5607580/how-to-set-the-path-environment-variable-from-ant-script – mikemil Feb 06 '14 at 15:21