ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: AW: antrc & ant.conf files
Date Tue, 20 May 2008 04:25:26 GMT
On Mon, May 19, 2008 at 7:44 AM,  <dhollis@aandoconsultancy.ltd.uk> wrote:
> I find shell scripts distinctly un-intutive, so no, I haven't tried it!

Let's look at the scripts step by step:

>  if [ -z "$ANT_HOME" -o "$ANT_HOME" = "/usr/share/ant" ]; then
>      if [ -f "/etc/ant.conf" ] ; then
>          . /etc/ant.conf
>      fi
>  fi

The outer if/then statement says if ANT_HOME isn't defined, or it is
defined as /usr/share/ant, then you check to see if the file
/etc/ant.conf exists. If it does, you execute it in the current
environment. This file should set some environment variables -- maybe
even the $ANT_HOME environment variable. This is the system wide
ant.conf file. You could set JAVA_HOME, ANT_HOME, whether to use the
jikes compiler, etc. And, these would apply to anyone who uses that
computer and doesn't have their own ANT installation.

>
>  # load user ant configuration
>  if [ -f "$HOME/.ant/ant.conf" ] ; then
>    . $HOME/.ant/ant.conf
>  fi
>  if [ -f "$HOME/.antrc" ] ; then
>    . "$HOME/.antrc"
>  fi

The first if/ten statement looks to see if a file called
$HOME/.ant/ant.conf exists. If it does, it executes it in the current
environment. Again, this file probably just sets some environment
variables including JAVA_HOME and ANT_HOME.

The second if/then statement does the same thing for $HOME/.antrc.

Files that begin with a dot are normally invisible to the user. It is
common practice to have either a .xxxrc file to set parameters or to
have a .xxx directory that contains a *.conf file that sets
parameters. Ant does it both ways for no good reason.


> Do I have to use both Set and Export for ANT_HOME, do you think?

Exporting an environment variable makes it available in all child
processes. Otherwise, it is only available in the current process. If
you define ANT_HOME in your .antrc file, you don't have to export it
since the shell script doesn't spawn another process. If you define it
before you run this script, you do have to export it or the script
won't see it.

 BTW, notice that the ant script sets

    JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home

if you don't have JAVA_HOME defined before your execute the "ant"
script on a Mac.

--
David Weintraub
qazwart@gmail.com

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


Mime
View raw message