tags:

views:

108

answers:

1

I have a problem where I don't want to have to call a setEnv.sh file before i call my ant target that calls an exec task.

Right now I have a way to save the environment variables in setenv.properties file in the key=value notation.

The exec task for some reason does not see the variables that are set in the .properties file.... (I know i could use the env tag but the setenv.properties is dynamically generated)

setenv.properties:

HELLO=XYZ

part of my build.xml :

<property file="setenv.properties"/>
<target name="test" depends="setEnv">
   <exec  executable="/bin/ksh" newenvironment="false">
     <arg value="test.ksh" /> 
   </exec>
</target>

test.sh :

echo ${HELLO}

Any thoughts?

A: 

Try this:

<target name="test" depends="setEnv">
   <property file="setenv.properties"/>
   <exec  executable="/bin/ksh" newenvironment="false">
     <arg value="test.ksh" /> 
   </exec>
</target>

When you put the element outside the element it will be evaluated globally before any targets are executed. Putting the tag on the line before the element and inside the tag delays evaluation of the setenv.properties file until the last possible moment and well after the setenv.properties file has been generated by a target run prior to the "test" target.

ChrisH
Yea I thought that was the problem originaly and generated the file by hand. Still no luck. It looks like the Exec command does not use the file properties at all I notice that it takes in an env tag where you have to specify key value pares but it seems to not like a properties file as an input
Mike