You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Matt Reason <ma...@movielink.com> on 2004/01/22 02:15:53 UTC

Is there a way to set environment variables inside ANT?

 
Is there an ant equivalent of:
set PATH=%PATH%;C:\Program Files\TortoiseCVS
 
I'm trying to do a CVS checkout in ANT on a windows machine.  CVS is not
in my path.  I'd really like to add CVS to my path in the build.xml and
not need to wrap the build.xml with a batch file.
 
I would like to do something like this:
 
  <exec executable="echo" newenvironment="true">
   <env key="Path" Path="${myenv.Path};C:\Program Files\TortoiseCVS"/>
  </exec>
  <echoproperties/>
 
But that does not work.  Am I missing something?  Why do I have to call
an executable at all?  Should I be trying to set Path or myenv.path?
Should I be calling ant with exec recursively?
 
Thanks in advance,
 
Matt
 
 
 

Re: Is there a way to set environment variables inside ANT?

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Thu, 22 Jan 2004 12:15 pm, Matt Reason wrote:
> Is there an ant equivalent of:
> set PATH=%PATH%;C:\Program Files\TortoiseCVS
>
> I'm trying to do a CVS checkout in ANT on a windows machine.  CVS is not
> in my path.  I'd really like to add CVS to my path in the build.xml and
> not need to wrap the build.xml with a batch file.
>
> I would like to do something like this:
>
>   <exec executable="echo" newenvironment="true">
>    <env key="Path" Path="${myenv.Path};C:\Program Files\TortoiseCVS"/>
>   </exec>
>   <echoproperties/>
>
> But that does not work.  

The mechanism shoud be fine but your example probably doesn't work because 
echo is not a command - it is a builtin of the Windows cmd.exe shell. Also 
the path setting will only affect the command being executed. It does not 
"change" the path setting for other execs. IOW, I'm not sure what the 
echoproperties task is there for but it won't do much.

You should use the Path when you try to execute TortoiseCVS's command, or 
better still, if you know where it is, just execute it directly (this depends 
on whether TortoiseCVS requires the path to be set, of course).

Conor


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Is there a way to set environment variables inside ANT?

Posted by Graham Reeds <gr...@ntlworld.com>.
> Is there an ant equivalent of:
> set PATH=%PATH%;C:\Program Files\TortoiseCVS
>
> I'm trying to do a CVS checkout in ANT on a windows machine.  CVS is not
> in my path.  I'd really like to add CVS to my path in the build.xml and
> not need to wrap the build.xml with a batch file.
>
> I would like to do something like this:
>
>   <exec executable="echo" newenvironment="true">
>    <env key="Path" Path="${myenv.Path};C:\Program Files\TortoiseCVS"/>
>   </exec>
>   <echoproperties/>
>
> But that does not work.  Am I missing something?  Why do I have to call
> an executable at all?  Should I be trying to set Path or myenv.path?
> Should I be calling ant with exec recursively?
>
> Thanks in advance,

There is.  I was (and still am) having trouble with calling Ant (see my
question and responses on 'Ant 1.6.0 Long Filename support'.

The last response had the lines:
2) to run ant without CLASSPATH set, change your build files to include
explicitly servlet.jar or j2ee.jar in the classpath when compiling your
servlets,

using the classpath nested element of javac.
[QUOTE]
something like this
<property environment="env"/>
<javac ....>
    <classpath>
           <pathelement
location="${env.CATALINA_HOME}/common/lib/servlet.jar"/>
          ... other path elements needed to compile your servlets
     </classpath>
</javac>
[/QUOTE]

which I guess could mean you could add the pathelement as your CVS
directory?

Or:
<property name="cvs.home"	value="$c:\Program Files\TortoiseCVS" />

and just use an expicit call to '${cvs.home}\cvs -c myFile.java' (or
whatever the syntax is for CVS - I haven't used it in about 8 or 9 years.

I haven't had the time to try it out.  Decorating, relationships, and my
full-time job have all conspired to stop me from my hobby.

HTH, G.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org