ant port Was: /usr/local/bin/javavmwrapper and "classpath"

Herve Quiroz hq at freebsd.org
Wed Aug 25 07:19:58 PDT 2004


Jan,

On Tue, Aug 24, 2004 at 03:40:54PM +0100, Jan Grant wrote:
> Following up from my previous email (which came across as more grumpy 
> than I intended, apologies), can I ask: is anyone using the apache-ant 
> port in anger?
> 
> I've had extreme difficulties with it thus far. In particular, the 
> script seems to rely on the existence of a CLASSPATH variable it never 
> sets. Additionally, it doesn't select any of the *.jar files in 
> /usr/local/ant/lib by default, which has the effect of turning off any 
> of the optional ant tasks.

Actually, the script sets LOCALCLASSPATH which is the classpath needed
to run ant. And it leaves the user-defined CLASSPATH variable to be used
as a parameter with '-lib' so Ant will automatically get optional JARs
from your user-defined current CLASSPATH. That's how I understand the
script anyway, so I may be wrong here.

Now, from the Ant manual (/usr/local/ant/docs/manual/running.html):

  Prior to Ant 1.6, all jars in the ANT_HOME/lib would be added to the
  CLASSPATH used to run Ant. This was done in the scripts that started
  Ant. From Ant 1.6, two directories are scanned by default and more can
  be added as required. The default directories scanned are ANT_HOME/lib
  and a user specific directory, ${user.home}/.ant/lib.

That makes me believe that everything from ${ANT_HOME}/lib should be
included in the classpath by Ant himself. I still need to have a deeper
look at things to know precisely how this occurs. Maybe our 'ant' script
is missing the following argument:

  -Dant.library.dir=\"$ANT_LIB\"

That's probably the main problem when using platform-specific scripts:
porters need to be careful when updating the port if the orignal script
is applied some major changes.

> Am I doing something wrong? I've wound up including the following in my 
> ~/.antrc as a workaround:
> 
> [[
> JAVA_HOME=/usr/local/jdk1.4.2 export JAVA_HOME
> 
> lcp=$(  \
>         find -s /usr/local/ant/lib -name '*.jar' | while read jar ; do
>                 echo -n ":${jar}"
>         done | sed -e 's/://' )
> 
> LOCALCLASSPATH=$JAVA_HOME/lib/tools.jar:$lcp
> ]]

Just my two cents: actually you don't need the 'sed' step, as you may
start a CLASSPATH statement by a ':' without trouble. The following will
work (at least it works on my system):

$ java -cp ::. HelloWorld

BTW, I think devel/apache-ant should use 'javavm' from java/javavmwrapper
to remove some unneeded logic from the script. We are currently working
on improving javavmwrapper so I will take care of this issue right
after commiting the current changes.

> Which means if bsf.jar and js.jar are available in the usual place 
> (/usr/local/share/java/whatever...) then the script tasks etc are again 
> available... but I'd expect /usr/local/bin/ant to do this kind of thing 
> on my behalf.

As I said above, what you are asking for is just Ant "official"
behaviour, so I agree that we need to fix things here. Still, there are
some issues that need to be clarified (such as the -Dant.library.dir
parameter I mentioned).

You seem to be a Ant hacker (given the hint you give below), so you
could probably help us on this one.

Opinions anyone ?

Herve


More information about the freebsd-java mailing list