ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <rambiusparkisan...@yahoo.com>
Subject Re: Detecting an environment variable
Date Wed, 23 Jun 2004 10:46:48 GMT
Hi Robert,

--- Robert Mark Bram <relaxedrob@optusnet.com.au>
wrote:
> Hi All!
> 
Setting env variables is an issue not only for and and
build.xml's but for Java in general.

> 1)
> How can I check to see if an environment variable
> has been set? I would 
> like to do this: set a property for jiniHome only if
> JINI_HOME has not 
> been set..
This will be smth of the kinf, (not tested):
<property environment="env"/>
<condition name="is.jini.home.set">
    <isset property="env.JINI_HOME"/>
</condition>

<target name="setJiniHome" unless="is.jini.home.set">
    <property name="jini.home" value="<some-value>">
</target>

> 
> 2)
> How can an install script 'guess' at the directories
> of some API's?
> When they say that it will try to guess the location
> of Java, for example, 
> is it just checking if JAVA_HOME is set?
And in my opinion is is enough. You can explore these
also
1) use which command. It is on all *nix environement
and a quick google for "which.exe" shows that it is
available for windwos.
2) consider this 
  <target name="findJava">
      <property environment="env"/>
      <whichresource property="path.java.exec"
resource="java" classpath="${env.PATH}"/>
      <echo message="${path.java.exec}"/>
  </target>

On my env it outputs
findJava:
     [echo] file:/usr/java/j2sdk/bin/java

2) is a kind of perversion since the docs for
<whichresource> say: Find a class or resource on the
supplied classpath, so I think it is designed to
search mainly for classes.

Both 1) and 2) are fragile since they rely on having
java executable in your PATH variable and if you have
java installed but not added java to the PATH both
attempts will fail.

HTH Ivan

> 
> Thanks for any advice!
> 
> Rob
> :)
> 
> 
> -- 
> Robert Mark Bram
> B.Comp.(Systems Development/Business Systems)
> B.Net.Comp.(Hons)
> Doctor of Philosophy Student
> 
> School of Network Computing
> Faculty of Information Technology
> Monash University
> Peninsula Campus
> McMahons Rd
> Frankston, VIC 3199
> AUSTRALIA
> 
> Phone:  61 3 9904 4394
> Facsimile:  61 3 9904 4124
> Email: robert.mark.bram@infotech.monash.edu.au
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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


Mime
View raw message