Hello Michael,
--- Michael Silverman <[EMAIL PROTECTED]>
wrote:
> Hi All,
>
> I have two questions and I would really appreciate
> your assistance.
>
> 1. How do I get the drive letter which ant is
> running from (under windows of
> course)?
> Something like getting the first char of
> ${basedir} is good enough for
> me (I think...)
You can do it using <propertyregexp> from ant-contrib
or if you want pure Ant solution you can use the
following <macrodef>:
<project>
<macrodef name="getDriveLetter">
<attribute name="absPath"
default="${basedir}"/>
<attribute name="result"/>
<sequential>
<echo file=".tempfile">@{absPath}</echo>
<replaceregexp file=".tempfile" match="\\(.*)"
replace=""/>
<loadfile srcfile=".tempfile"
property="@{result}"/>
<delete file=".tempfile" failonerror="false"/>
</sequential>
</macrodef>
<getDriveLetter result="drive"/>
<echo>$${drive} is ${drive}</echo>
</project>
There may be some trick with <pathconvert> as well.
> 2. Is there a way to set the windows path through
> ant? It doesn't have to be
> permanent,
> I just want to append a dir to the windows path
> during the running of ant
> (because of a DLL issue).
> I tried to use the exec task but it didn't work:
> I couldn't execute 'set'
> because it is not
> an executable file and if I execute 'cmd.exe'
> with arguments 'set
> Path=...' , then the path
> is only changed in the cmd.exe process and not
> outside of it (the change
> is not visible
> to ant after cmd.exe has ended).
I suppose you are calling a windows command with
<exec>. You can use <exec>'s nested element <env> and
pass through it the desired env variable.
Hope this helps
Regards
Ivan
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]