ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Locke <j...@muppetlabs.com>
Subject Re: Env Properties & Linux?
Date Sun, 13 Jul 2003 22:37:16 GMT

if you're trying to access environment variables defined in your shell,
that is no longer possible in Java (and therefore is not possible in Ant or
any other pure-java application). 

we know this is true because this is the definition of System.getenv:

    public static String getenv(String name) {
    throw new Error("getenv no longer supported, use properties and -D 
instead: " + name);
    }

if you want to access $NUMBER_OF_PROCESSORS from your unix environment,
you will have to invoke ant with 
-DNUMBER_OF_PROCESSORS=$NUMBER_OF_PROCESSORS
in order to define the system environment variable.

Jason Varsoke wrote:

>I'm trying to get access to the system environment properties on Linux
>(Specifically SuSE 8.2).  I mention this because the manual states that
>this tag doesn't work for all platforms -- though I'd be surprised if
>Linux was such a platform.  Anyway here's my test build.xml
>
><project name="env" default="debug">
>
>   <!-- tasks -->
>   <target name="debug">
>   <property environment="env"/>
>   <property name="junit.home"        value="${env.JUNIT_HOME}"/>
>   <echo message="Number of Processors = ${env.NUMBER_OF_PROCESSORS}"/>
>   <echo message="ANT_HOME is set to = ${env.ANT_HOME}"/>
>   <echo message="${junit.home}"/>
>   <echo message="${env.JUNIT_HOME}"/>
>   </target>
></project>
>
>And here's what I get as a result (with the -v param)
>
>sancho% ant -v
>Apache Ant version 1.5.3 compiled on April 16 2003
>Buildfile: build.xml
>Detected Java version: 1.4 in: /usr/local/j2sdk1.4.1_02/jre
>Detected OS: Linux
>parsing buildfile build.xml with URI =
>file:/home/jvarsoke/src/java/test/ant/build.xml
>Project base dir set to: /home/jvarsoke/src/java/test/ant
>Build sequence for target `debug' is [debug]
>Complete build sequence is [debug]
>
>debug:
> [property] Loading Environment env.
>Property ${env.JUNIT_HOME} has not been set
>Property ${env.NUMBER_OF_PROCESSORS} has not been set
>     [echo] Number of Processors = ${env.NUMBER_OF_PROCESSORS}
>Property ${env.ANT_HOME} has not been set
>     [echo] ANT_HOME is set to = ${env.ANT_HOME}
>     [echo] ${env.JUNIT_HOME}
>Property ${env.JUNIT_HOME} has not been set
>     [echo] ${env.JUNIT_HOME}
>
>BUILD SUCCESSFUL
>Total time: 6 seconds
>
>Do I have Ant configured wrong or something?
>
>thanks for the help,
>-jason
>
>
>__________________________________
>Do you Yahoo!?
>SBC Yahoo! DSL - Now only $29.95 per month!
>http://sbc.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>  
>


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


Mime
View raw message