ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Burton" <bi...@progress.com>
Subject Re: broken build problem with relative path to ant.jar
Date Sat, 18 Nov 2000 02:41:15 GMT
Hello,

There are several issues with the script you are using to start Ant.  I'm
not familiar with jBoss so there are certain assumptions I'm making about
the directory structure that may not be correct ...

Luke Taylor wrote:
> 
> Hi,
> 
> I've recently switched to using ant 1.2 and have come across problems
> with the build for jBoss (the EJB server) and similar builds from the
> project. They have the ant.jar file included  in <basedir>/lib to allow
> them to build independently of any installation, and this file is added
> along with the parser etc. to the classpath that is used when running
> the ant program i.e
> 
> set CP=..\..\lib\ant.jar
> set CP=%CP%;..\..\lib\xml.jar
> set CP=%CP%;..\..\lib\javac.jar
> 
> java -classpath "%CP%" org.apache.tools.ant.Main %1 %2 %3 %4 %5

This doesn't set the property ant.home.  For instance, in the ant.bat
script included with Ant 1.2, you will find:
    -Dant.home="%ANT_HOME%"
on the command line to run Ant.  The ant.bat script tries to guess where
Ant is installed and will not run if it cannot make this determination.

> This works OK with previous versions of ant, but the javac command
> results in an error with v 1.2 (and the current nightly build):
> 
> The file or path you specified (..\..\lib\ant.jar) is invalid releative
> (sic :-) to H:\jBoss

You could make the following changes to get around this:

In H:\jBoss create a batch file called gethome.bat with the following
lines:
  rem Set this to where jBoss is installed
  set JBOSS_HOME=H:\jBoss

Then modify the build.bat and any other scripts that need to know the
jBoss installation directory do this:
  if exist ..\..\gethome.bat call ..\..\gethome
  if x%JBOSS_HOME%==x goto NOHOME

  set CP=%JBOSS_HOME%\lib\ant.jar
  set CP=%CP%;%JBOSS_HOME%\lib\xml.jar
  set CP=%CP%;%JBOSS_HOME%\lib\xmlbeans.jar
  set CP=%CP%;%JBOSS_HOME%\build\classes
  set CP=%CP%;%JBOSS_HOME%\lib\javac.jar

  java -classpath "%CP%" -Dant.home=%JBOSS_HOME% org.apache.tools.ant.Main
%1 %2 %3 %4 %5
  goto EOF

  :NOHOME
  echo ERROR: JBOSS_HOME was not set to the installation directory

  :EOF

In case you are wondering, there is no obvious "pwd" equivalent you can
call in a .bat file.  The "cd" command with no arguments echos the current
directory but there's no obvious way you can't set a variable from it. 
However, I just discovered there is a way to save the current directory
into a variable on Windows NT/2000 only, not 95/98. 
  rem set pwd to the current directory
  for /f %%i in ('cd') do set pwd=%%i
so the above is the equivalent of pwd=`pwd` or pwd=$(pwd) on UNIX.  So you
could now use %pwd% to set CP.  However, it's still probably better to set
JBOSS_HOME explicitly and use that.

A better option might be to install a full copy of Ant 1.2 in it's own
directory instead of trying to merge parts of Ant into the jBoss tree
(which I assume you're doing).  Then in NT's My Computer, Environment,
create a User Variable ANT_HOME pointing to the location where Ant is
installed.  This will take effect on any new MS-DOS command prompt windows
you open.  To do builds, run ant.bat in the Ant distribution instead of
the build.bat in jBoss.

Hope this helps,
-Bill

> So it seems to be trying to make use of the classpath use to run ant,
> and tring to resolve it relative to the basedir, rather than the
> directory from which the script was run. I guess using NT isn't helping
> things either :-(.
> 
> Any suggestions on what might be causing this and how I can get it to
> work?
> 
> Thanks,
> 
> Luke.
> 
> --
>  Luke Taylor.
>  PGP Key ID: 0x57E9523C

-- 
Bill Burton, Senior Internet Software Engineer
E-mail: billb@progress.com
Progress Software Corporation

Mime
View raw message