Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 48259 - ant 1.6.2 ignores jars in ~/.ant/lib directory
Summary: ant 1.6.2 ignores jars in ~/.ant/lib directory
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Java team
URL: http://ant.apache.org/manual/running....
Whiteboard:
Keywords:
: 48256 48258 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-18 12:52 UTC by Haroon Rafique
Modified: 2005-09-10 08:24 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
remove extra entries from LOCALCLASSAPTH in ant launcher script (ant-launcher-classpath-1.6.1.diff,595 bytes, patch)
2004-04-18 17:40 UTC, Haroon Rafique
Details | Diff
minimalist jar file to be put inside ~/.ant/lib (useless.jar,1.08 KB, application/octet-stream)
2004-12-17 17:43 UTC, Haroon Rafique
Details
minimalist build.xml file to reproduce the bug (build.xml,329 bytes, text/plain)
2004-12-17 17:44 UTC, Haroon Rafique
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Haroon Rafique 2004-04-18 12:52:42 UTC
According to http://ant.apache.org/manual/running.html#libs, starting
from version 1.6, ant is able to add jars from user specific directory,
${user.home}/.ant/lib. I noticed that ant was ignoring that directory all
together. I'm not an ant expert but looking at the vanilla ant script found
in dist/bin/ant, I can see that they use the
org.apache.tools.ant.launch.Launcher as the class to use. However, the
gentoo /usr/bin/ant uses org.apache.tools.ant.Main as the class to use.
Looking at the ant sources, I think ./src/main/org/apache/tools/ant/launch/Launcher.java is the only
place where ant scans the ${user.home}/.ant/lib directory.

The obvious fix to try was to replace org.apache.tools.ant.Main with
org.apache.tools.ant.launch.Launcher in /usr/bin/ant. I tried that with mixed
results. To tell you the whole story I have a clover.jar file in
${user.home}/.ant/lib. Before making the Main to Launcher switch I wasn't even
getting the clover <taskdefs> to show up (since the clover.jar never made it
into the classpath). After making the switch from Main to Launcher, I could get
the task to be recognized but got errors duing javac compilation:

Compiler Adapter 'org.apache.tools.ant.taskdefs.CloverCompilerAdapter' can't be
found.

In any case, I have a pretty good idea that the gentoo ant script is broken,
since I can use the vanilla ant script without any problems (its able to see
the jars in ${user.home}/.ant/lib). Here's what I do to use the vanilla ant:

export ANT_HOME=/home/haroon/src/build/apache-ant-1.6.1/dist

and then execute ant as:

/home/haroon/src/build/apache-ant-1.6.1/dist/bin/ant

I can provide more details upon request.

Versions: 
dev-java/java-config-1.2.6
dev-java/sun-jdk-1.4.2.04-r1
dev-java/ant-1.6.1

Portage 2.0.50-r6 (default-x86-1.4, gcc-3.3.3, glibc-2.3.3_pre20040207-r0, 2.4.24-ck1)
=================================================================
System uname: 2.4.24-ck1 i686 Intel(R) Pentium(R) 4 CPU 2.60GHz
Gentoo Base System version 1.4.8
distcc 2.13 i686-pc-linux-gnu (protocols 1 and 2)
(default port 3632) [enabled]
ccache version 2.3 [enabled]
Autoconf: sys-devel/autoconf-2.59-r3
Automake: sys-devel/automake-1.8.3
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CFLAGS="-march=pentium4 -O3 -pipe -s -fomit-frame-pointer -fforce-addr -falign-functions=4 -fprefetch-loop-arrays -ffast-math"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /etc/tomcat /usr/X11R6/lib/X11/xkb
/usr/kde/2/share/config /usr/kde/3.1/share/config
/usr/kde/3.2/share/config /usr/kde/3/share/config
/usr/lib/mozilla/defaults/pref /usr/share/config
/usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/
/usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/
/usr/share/texmf/xdvi/ /var/bind /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=pentium4 -O3 -pipe -s -fomit-frame-pointer
-fforce-addr -falign-functions=4 -fprefetch-loop-arrays -ffast-math"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache distcc sandbox userpriv usersandbox"
GENTOO_MIRRORS="http://mirrors.tds.net/gentoo
ftp://ftp.gtlib.cc.gatech.edu/pub/gentoo
ftp://csociety-ftp.ecn.purdue.edu/pub/gentoo/
http://csociety-ftp.ecn.purdue.edu/pub/gentoo/
http://open-systems.ufl.edu/mirrors/gentoo"
MAKEOPTS="-j11"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage.local"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X aalib alsa apache2 apm arts avi berkdb bonobo cdr crypt cups encode
esd foomaticdb gdbm gif gpm gtk gtk2 gtkhtml guile imlib java jikes jpeg
junit ldap libg++ libwww mad mbox mikmod motif mozilla mpeg mysql ncurses
nls offensive oggvorbis opengl oss pam pdflib perl png postgres python qt
quicktime readline sdl slang spell ssl svga tcltk tcpd tetex tiff truetype
x86 xinerama xml2 xmms xv zlib"
Comment 1 Haroon Rafique 2004-04-18 12:53:19 UTC
*** Bug 48258 has been marked as a duplicate of this bug. ***
Comment 2 Haroon Rafique 2004-04-18 12:54:10 UTC
*** Bug 48256 has been marked as a duplicate of this bug. ***
Comment 3 Haroon Rafique 2004-04-18 14:16:51 UTC
Upgrading to ant-1.6.1-r1 I noticed that Launcher class is now used to start ant. That's a good sign.

Here's build.xml file that I'm using:

<project name="money_demo" default="code" basedir=".">
     <description>
         moneytest build file
     </description>

     <property name="src" location="src"/>
     <property name="build" location="build"/>
     <path id="build.classpath">
                <pathelement path="${user.home}/.ant/lib/junit.jar"/>
                <pathelement path="${user.home}/.ant/lib/clover.jar"/>
                <pathelement path="${build}"/>
     </path>

    <!-- Creates Destination directory and compiles files in source directory-->
     <target name="code" >
            <mkdir dir="${build}"/>
            <javac srcdir="${src}" destdir="${build}"/>
     </target>

    <!-- runs the tests -->
     <target name="test">
            <java classname="MoneyTest"
              fork="yes">
            <classpath refid="build.classpath"/>
            </java>
     </target>
    <!-- clover -->
     <target name="with.clover">
        <taskdef resource="clovertasks"/>
        <clover-setup initString="demo_coverage.db"/>
     </target>
    <!-- Delete the ${build} directory-->
     <target name="clean">
            <delete dir="${build}"/>
     </target>
</project>

Running:
  ant with.clover code
gives me:

Buildfile: build.xml

with.clover:

code:
    [mkdir] Created dir: /home/haroon/src/build/clover-1.2.4_02/tutorial/build
    [javac] Compiling 4 source files to /home/haroon/src/build/clover-1.2.4_02/tutorial/build

BUILD FAILED
/home/haroon/src/build/clover-1.2.4_02/tutorial/build.xml:17: Compiler Adapter 'org.apache.tools.ant.taskdefs.CloverCompilerAdapter' can't be found.

Total time: 1 second

Using vanilla ant by first setting ANT_HOME to:
    export ANT_HOME=/home/haroon/src/build/apache-ant-1.6.1/dist/
and running:
    /home/haroon/src/build/apache-ant-1.6.1/dist/bin/ant with.clover code
gives me:

Buildfile: build.xml

with.clover:

code:
    [javac] Compiling 4 source files to /home/haroon/src/build/clover-1.2.4_02/tutorial/build
   [clover] Clover Version 1.2.4_02, built on January 26 2004
   [clover] loaded from: file:/home/haroon/.ant/lib/clover.jar
   [clover] Open Source License registered to the XXXX Project.
This license of Clover is provided to support the development of XXXX only.

   [clover] Updating database at '/home/haroon/src/build/clover-1.2.4_02/tutorial/demo_coverage.db'
   [clover] Clover all over. Instrumented 4 files.

BUILD SUCCESSFUL
Total time: 3 seconds
Comment 4 Haroon Rafique 2004-04-18 14:31:55 UTC
Here's an even simpler test case:

<project name="clover.available" default="main" basedir=".">
    <available property="clover.available"
        classname="org.apache.tools.ant.taskdefs.CloverCompilerAdapter"/>
    <target name="main" depends="debug">
    </target>
    <target name="debug" if="clover.available">
        <echo message="CloverCompilerAdapter was found"/>
    </target>
</project>

Works with vanilla ant script (after setting ANT_HOME as explained in comment 3 and description) and doesn't work with gentoo ant script.
Comment 5 Haroon Rafique 2004-04-18 17:28:47 UTC
This just keeps getting wierder and wierder. The test case described in comment 4, works if I use the following command line:

/opt/sun-jdk-1.4.2.04/bin/java \
    -classpath /usr/share/ant/lib/ant-launcher.jar \
    -Dant.home=/usr/share/ant \
    org.apache.tools.ant.launch.Launcher \
    -lib /opt/sun-jdk-1.4.2.04/jre/lib/rt.jar:.:.

Obviously the above line is a stripped down version of what is
the actual command run by /usr/bin/ant, which incidentally is
(introduced new lines for formatting classpath):

/opt/sun-jdk-1.4.2.04/bin/java \
    -classpath \
    /usr/share/ant/lib/ant-launcher.jar:
    /opt/sun-jdk-1.4.2.04/jre/lib/rt.jar:.:.:
    /opt/sun-jdk-1.4.2.04/jre/lib/rt.jar:.:.:
    /usr/share/ant/lib/ant.jar:
    /usr/share/ant/lib/ant-launcher.jar:
    /usr/share/ant-optional/lib/ant-antlr.jar:
    /usr/share/ant-optional/lib/ant-jakarta-bcel.jar:
    /usr/share/ant-optional/lib/ant-junit.jar:
    /usr/share/ant-optional/lib/ant-vaj.jar:
    /usr/share/ant-optional/lib/ant-apache-bsf.jar:
    /usr/share/ant-optional/lib/ant-jakarta-log4j.jar:
    /usr/share/ant-optional/lib/ant-weblogic.jar:
    /usr/share/ant-optional/lib/ant-apache-resolver.jar:
    /usr/share/ant-optional/lib/ant-jakarta-oro.jar:
    /usr/share/ant-optional/lib/ant-netrexx.jar:
    /usr/share/ant-optional/lib/ant-xalan1.jar:
    /usr/share/ant-optional/lib/ant-nodeps.jar:
    /usr/share/ant-optional/lib/ant-jakarta-regexp.jar:
    /usr/share/ant-optional/lib/ant-xalan2.jar:
    /usr/share/ant-optional/lib/ant-commons-logging.jar:
    /usr/share/ant-optional/lib/ant-javamail.jar:
    /usr/share/ant-optional/lib/ant-starteam.jar:
    /usr/share/ant-optional/lib/ant-xslp.jar:
    /usr/share/ant-optional/lib/ant-commons-net.jar:
    /usr/share/ant-optional/lib/ant-jdepend.jar:
    /usr/share/ant-optional/lib/ant-stylebook.jar:
    /usr/share/ant-optional/lib/ant-icontract.jar:
    /usr/share/ant-optional/lib/ant-jmf.jar:
    /usr/share/ant-optional/lib/ant-swing.jar:
    /usr/share/ant-optional/lib/ant-jai.jar:
    /usr/share/ant-optional/lib/ant-jsch.jar:
    /usr/share/ant-optional/lib/ant-trax.jar:
    /usr/share/log4j/lib/log4j-1.2.8.jar:
    /usr/share/xerces/lib/xercesImpl.jar:
    /usr/share/xerces/lib/xercesSamples.jar:
    /usr/share/xerces/lib/xml-apis.jar:
    /usr/share/xerces/lib/xmlParserAPIs.jar:
    /usr/share/xalan/lib/xalan.jar:
    /usr/share/junit/lib/junit.jar:
    /usr/share/antlr/lib/antlr.debug.jar:
    /usr/share/antlr/lib/antlr.jar:
    /usr/share/antlr/lib/antlrall.jar:
    /usr/share/bcel/lib/bcel.jar:
    /usr/share/regexp/lib/regexp-1.3.jar:
    /usr/share/bsh/lib/bsh-2.0b1.jar:
    /usr/share/commons-beanutils/lib/commons-beanutils.jar:
    /usr/share/commons-logging/lib/commons-logging-api.jar:
    /usr/share/commons-logging/lib/commons-logging.jar:
    /usr/share/commons-logging/lib/commons-logging-api.jar:
    /usr/share/commons-logging/lib/commons-logging.jar:
    /usr/share/commons-net/lib/commons-net-1.0.1-dev.jar:
    /usr/share/oro/lib/oro.jar:
    /usr/share/jdepend/lib/jdepend.jar:
    /usr/share/jsch/lib/jsch.jar:
    /usr/share/regexp/lib/regexp-1.3.jar:
    /usr/share/rhino/lib/js.jar:
    /usr/share/jython/lib/jython.jar:
    /opt/sun-jdk-1.4.2.04/lib/tools.jar \
    -Dant.home=/usr/share/ant \
    org.apache.tools.ant.launch.Launcher \
    -lib /opt/sun-jdk-1.4.2.04/jre/lib/rt.jar:.:.:
    /opt/sun-jdk-1.4.2.04/jre/lib/rt.jar:.:.

To reiterate, the long version above DOES NOT work and the stripped down
version DOES work.
Comment 6 Haroon Rafique 2004-04-18 17:40:28 UTC
Created attachment 29589 [details, diff]
remove extra entries from LOCALCLASSAPTH in ant launcher script

After making this change (see unified diff), my problem is fixed. I have
the following questions though:

1) Did I break anything by making this fix?
2) Why was the loonnnnngggg LOCALCLASSPATH necessary given that the Launcher
class
sort of does the same thing?

Cheers and thanks in advance for your attention.
Comment 7 Thomas Matthijs (RETIRED) gentoo-dev 2004-07-23 14:29:55 UTC
could you please test if ant-1.6.2-r1 fixes this?
if it doesn't please reopon the bug
Comment 8 Haroon Rafique 2004-08-11 07:34:07 UTC
I am running ant-1.6.2-r2 and I can confirm that this is fixed.
Comment 9 Haroon Rafique 2004-09-07 13:10:00 UTC
verified and closed.
Comment 10 Haroon Rafique 2004-12-17 08:41:49 UTC
This problem has reappeared.

$> epm -q ant-core ant-tasks ant
ant-core-1.6.2
ant-tasks-1.6.2-r5
ant-1.6.2-r6

I have clover.jar inside my ~/.ant/lib directory. I expect ant to see this jar file. A simple build.xml file to demonstrate the problem:

<project name="clover.available" default="main" basedir=".">
    <available property="clover.available"
        classname="org.apache.tools.ant.taskdefs.CloverCompilerAdapter"/>
    <target name="main" depends="debug">
    </target>
    <target name="debug" if="clover.available">
        <echo message="CloverCompilerAdapter was found"/>
    </target>
</project>

If ant was successfully able to see clover.jar (from inside ~/.ant/lib) you will see a message "CloverCompilerAdapter was found". Using the ant supplied with gentoo, ant does NOT see the jars inside the lib file.

Buildfile: build.xml

debug:

main:

BUILD SUCCESSFUL
Total time: 0 seconds

To demonstrate that "vanilla ant" (built from source) does not exhibit this behavior, simply build ant from scratch, e.g.:

cd ~/src/build
tar xjvf /usr/portage/distfiles/apache-ant-1.6.2-src.tar.bz2 
cd apache-ant-1.6.2/
./build.sh

After a successful build, you can use the "vanilla ant" by modifying your ANT_HOME variable to:

export ANT_HOME=/home/haroon/src/build/apache-ant-1.6.2/dist

Rerun the above build.xml again:

$ANT_HOME/bin/ant

and you will see as output:

Buildfile: build.xml

debug:
     [echo] CloverCompilerAdapter was found

main:

BUILD SUCCESSFUL
Total time: 0 seconds

If downloading clover.jar is a problem, I can try and come up with a minimalist jar file and a corresponding build.xml file which demonstrates the problem.
Comment 11 Haroon Rafique 2004-12-17 17:43:29 UTC
Created attachment 46243 [details]
minimalist jar file to be put inside ~/.ant/lib
Comment 12 Haroon Rafique 2004-12-17 17:44:34 UTC
Created attachment 46244 [details]
minimalist build.xml file to reproduce the bug
Comment 13 Haroon Rafique 2004-12-20 10:36:39 UTC
Commenting out line 105 in /usr/bin/ant let's me see jars inside ~/.ant/lib/. FYI, line 105 is where LOCALCLASSPATH has stuff added to it for ant-core, ant-tasks, log4j, xerces-2, etc....

So, now that we know that line 105 is the culprit, how do we go about not breaking the ant default behavior and also integrating all these extra packages?
Comment 14 Thomas Matthijs (RETIRED) gentoo-dev 2005-07-09 08:15:58 UTC
can anyone verify that just removing 'ant-core,ant-tasks' from the
LOCALCLASSPATH= java-config -p
line, makes things work?
Comment 15 Haroon Rafique 2005-07-11 09:31:07 UTC
(In reply to comment #14)
> can anyone verify that just removing 'ant-core,ant-tasks' from the
> LOCALCLASSPATH= java-config -p
> line, makes things work?

Yes, taking out ant-core,ant-tasks from the LOCALCLASSPATH= java-config
--classpath line works for me.

For anyone else following the thread, the attachments found in comment 11,
comment 12 can be used to reproduce this bug. The rest of the discussion (in
previous comments) is detailed because I was trying to diagnose the problem,
until I was able to shrink it down to the minimalist attachments found in
comment 11 and comment 12.
Comment 16 Thomas Matthijs (RETIRED) gentoo-dev 2005-09-10 08:24:43 UTC
Fixed with ant-core-1.6.5