Bug 755325 - ant cannot find ant-antlr
ant cannot find ant-antlr
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: ant (Show other bugs)
16
All Linux
unspecified Severity high
: ---
: ---
Assigned To: Jaromír Cápík
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-20 12:44 EST by Jerry James
Modified: 2016-01-31 20:55 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-03-07 06:58:04 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jerry James 2011-11-20 12:44:02 EST
Description of problem:
I'm trying to compile a project that uses antlr with ant.  It fails like this:

------------------------------------------------------------------------------
BUILD FAILED
build.xml:337: Problem: failed to create task or type antlr
Cause: the class org.apache.tools.ant.taskdefs.optional.ANTLR was not found.
        This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
        -/usr/share/ant/lib
        -/home/jamesjer/.ant/lib
        -a directory added on the command line with the -lib argument

Do not panic, this is a common problem.
The commonest cause is a missing JAR.

This is not a bug; it is a configuration problem
------------------------------------------------------------------------------

I have the ant-antlr package installed, so ant-antlr.jar *is* in /usr/share/ant/lib.

Version-Release number of selected component (if applicable):
ant-antlr-1.8.2-6.fc16.noarch

How reproducible:
Always

Steps to Reproduce:
1. Attempt to build an antlr-using project with ant
2.
3.
  
Actual results:
Ant reports that it cannot find the class in ant-antlr.jar.

Expected results:
Ant is able to find the class.

Additional info:
The problem is that the configuration file is misnamed.  Instead of /etc/ant.d/antlr, it should be named /etc/ant.d/ant-antlr, and it should contain this:

ant-antlr ant/ant-antlr

After creating the file with those contents, my project now builds.
Comment 1 Tomas Radej 2011-11-22 10:40:00 EST
I'll look into it.
Comment 2 Jerry James 2011-11-22 12:01:48 EST
Thanks, Tomas.
Comment 3 Fedora Admin XMLRPC Client 2012-01-11 06:58:28 EST
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 4 Tomas Radej 2012-01-16 09:01:17 EST
Jerry, could you please provide more data on what project you are building etc.? Antlr and ant-antlr are different projects, so the problem is probably somewhere else.
Comment 5 Stanislav Ochotnicky 2012-01-16 12:26:56 EST
Just a wild quess since I didn't look into this that much. Do you by any chance set "OPT_JAR_LIST" environment variable? If so, then ant will ignore anything that is set in /etc/ant.d/*. 

Name of file in /etc/ant.d/ has absolutely no meaning, though I agree it should be named after the package so ant-antlr here.

As for the contents: "ant-antlr ant/ant-antlr"  means ant will try to put 2 jar files on classpath by running build-classpath on "ant-antlr" and "ant/ant-anlr". It will fail with the first since there is no ant-antlr.jar in any directory used by build-classpath.
Comment 6 Jerry James 2012-01-16 22:34:40 EST
Hmmm, I'm probably just terminally confused.  I'm trying to build jReality, which has a bunch of other dependencies.  If you look at http://jjames.fedorapeople.org/, you can find all of them, except for jinput, which is still under review.

I do not have OPT_JAR_LIST set in my environment, nor in the spec file, and a grep through the jReality sources doesn't turn it up either.

What I do know is that I get the build failure in comment 1 with the stock Fedora RPMs installed, and that adding the new file I mentioned allowed the project to build.  Given comment 5, I don't know why that helped, but it did.
Comment 7 Stanislav Ochotnicky 2012-01-17 03:43:52 EST
What happens when you do this before running ant:
export CLASSPATH="`build-classpath ant/ant-antlr antlr`"
?
Comment 8 Jerry James 2012-01-18 22:03:40 EST
That build completes successfully after adding that to the spec file.
Comment 9 Stanislav Ochotnicky 2012-01-19 03:56:58 EST
OK, I believe I found the bug(s):
1. For some reason /usr/bin/ant will skip building classpath if the dependency in the file is a substring of the filename in ant.d (i.e. if the /etc/ant.d/antlr file contains "*antlr*" it will not do build-classpath on it. I wonder how come this hasn't been discovered sooner, so there might be some weird reason for it...
For details look at line 180 of /usr/bin/ant (commenting it out should make everything work)

2. ant-antlr3 ant.d file probably misses stringtemplate in the contents. This is unrelated to this bug, just found it while testing
Comment 10 Stanislav Ochotnicky 2012-01-19 04:40:52 EST
A small correction in 1. point. Ant will skip the dependency if it thinks it's already present in OPT_JAR_LIST. So if you have "antlr ant/ant-antlr" both will get on classpath, but if you do "ant/ant-antlr antlr", the check will fail on second dependency (because OPT_JAR_LIST already contains "antlr" substring) and thus it will not get on classpath.

This seems to be to prevent duplicating jars on classpath, but to me it looks like it's causing more troubles than it's solving.
Comment 11 Jerry James 2012-01-19 10:45:30 EST
Great work!  Thanks for tracking this down.
Comment 12 Tomas Radej 2012-01-30 04:29:37 EST
I made a patch that removes the test and contacted upstream:

https://issues.apache.org/bugzilla/show_bug.cgi?id=52556
Comment 13 Tomas Radej 2012-02-02 10:48:26 EST
Upstream accepted the patch, so I'll push the updated version of the package in the repo on Monday.
Comment 14 Tomas Radej 2012-02-07 11:56:13 EST
The patched version was built successfully (v1.8.2-9), please try it once it gets in rawhide (http://koji.fedoraproject.org/koji/taskinfo?taskID=3769495). Thank you.
Comment 15 Jerry James 2012-02-07 12:13:44 EST
Will do.  Thanks, Tomas and Stanislav!
Comment 16 Tomas Radej 2012-03-07 06:58:04 EST
Closing the bug.

Note You need to log in before you can comment on or make changes to this bug.