ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Bug 3129
Date Tue, 10 Sep 2002 15:49:10 GMT
I stand correct Stefan ;-) Thanks for straightening me out. Here's a Which
task (summarily tested) that does perform as expected. Cheers, --DD

Debug output (minus class loader stuff) of summary test:
-which:
+User task: which     com.lgc.buildmagic.Which
Setting project property: -which-defined -> true

test-which:
   +Task: which
Searching P:\com_lgc\dsp\dsp-core\tools\ant\bin
Setting project property: ant.bat ->
P:\com_lgc\dsp\dsp-core\tools\ant\bin\ant.bat
Set property expected = P:/com_lgc/dsp/dsp-core/tools/ant/bin/ant.bat
Setting project property: expected ->
P:/com_lgc/dsp/dsp-core/tools/ant/bin/ant.bat
Set property ant.batU = P:/com_lgc/dsp/dsp-core/tools/ant/bin/ant.bat
Setting project property: ant.batU ->
P:/com_lgc/dsp/dsp-core/tools/ant/bin/ant.bat
Condition true; setting found to true
Setting project property: found -> true
   +Task: which
Searching C:\WINNT\system32
Searching C:\WINNT
Searching C:\WINNT\System32\Wbem
Searching C:\pro\exceed\Accessories
Searching C:\pro\bin
Setting project property: cvs.exe -> C:\pro\bin\cvs.exe
cvs.exe = C:\pro\bin\cvs.exe

Summary test:
  <target name="test-which" depends="compile, -which">
    <which property="ant.bat" basename="ant.bat">
      <searchpathelement location="${ant.home}/bin" />
    </which>
    <pathconvert targetos="unix" property="expected">
      <path path="${ant.home}/bin/ant.bat" />
    </pathconvert>
    <pathconvert targetos="unix" property="ant.batU">
      <path path="${ant.bat}" />
    </pathconvert>
    <condition property="found">
      <equals arg1="${ant.batU}" arg2="${expected}" />
    </condition>
    <fail message="ant.bat = ${ant.batU} != ${expected}"
          unless="found" />

    <which property="cvs.exe" basename="cvs.exe" searchpath="${env.Path}" />
    <echo message="cvs.exe = ${cvs.exe}" />
  </target>

  <target name="-which" unless="-which-defined">
    <taskdef name="which" classname="com.lgc.buildmagic.Which"
             classpath="${classes}" />
    <property name="-which-defined" value="true" />
  </target>

-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org] 
Sent: Tuesday, September 10, 2002 1:18 AM
To: ant-dev@jakarta.apache.org
Subject: Re: Bug 3129

On Mon, 9 Sep 2002, Dominique Devienne <DDevienne@lgc.com> wrote:

> You can get the absolute pathname of your executable on Win32 using:
> 
> <available property="ssh.exe" file="ssh.exe" filepath="${env.Path}"
> />
> 
> and use ${ssh.exe} thereafter.

Are you sure?

I'd think this property would be either unset or "true" after that
task.  Yep:

[bodewig@bodewig bodewig]$ cat > /tmp/ssh.xml 
<project default="foo">
  <target name="foo">
    <property environment="env"/>
    <available property="ssh" file="ssh" filepath="${env.PATH}"/>
    <echo>${ssh}</echo>
  </target>
</project>
[bodewig@bodewig bodewig]$ ant -f /tmp/ssh.xml -verbose
Apache Ant version 1.6alpha compiled on September 9 2002
Buildfile: /tmp/ssh.xml
...
foo:
 [property] Loading Environment env.
[available] Found: ssh in /usr/bin
     [echo] true

BUILD SUCCESSFUL
Total time: 3 seconds

Stefan


Mime
View raw message