Bug 755325

Summary: ant cannot find ant-antlr
Product: [Fedora] Fedora Reporter: Jerry James <loganjerry>
Component: antAssignee: Jaromír Cápík <jcapik>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 16CC: akurtako, java-sig-commits, mmatejov, ovasik, pcheung, sochotni, tradej
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-07 11:58:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jerry James 2011-11-20 17:44:02 UTC
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 'Sheldon' Radej 2011-11-22 15:40:00 UTC
I'll look into it.

Comment 2 Jerry James 2011-11-22 17:01:48 UTC
Thanks, Tomas.

Comment 3 Fedora Admin XMLRPC Client 2012-01-11 11:58:28 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 4 Tomas 'Sheldon' Radej 2012-01-16 14:01:17 UTC
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 17:26:56 UTC
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-17 03:34:40 UTC
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 08:43:52 UTC
What happens when you do this before running ant:
export CLASSPATH="`build-classpath ant/ant-antlr antlr`"
?

Comment 8 Jerry James 2012-01-19 03:03:40 UTC
That build completes successfully after adding that to the spec file.

Comment 9 Stanislav Ochotnicky 2012-01-19 08:56:58 UTC
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 09:40:52 UTC
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 15:45:30 UTC
Great work!  Thanks for tracking this down.

Comment 12 Tomas 'Sheldon' Radej 2012-01-30 09:29:37 UTC
I made a patch that removes the test and contacted upstream:

https://issues.apache.org/bugzilla/show_bug.cgi?id=52556

Comment 13 Tomas 'Sheldon' Radej 2012-02-02 15:48:26 UTC
Upstream accepted the patch, so I'll push the updated version of the package in the repo on Monday.

Comment 14 Tomas 'Sheldon' Radej 2012-02-07 16:56:13 UTC
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 17:13:44 UTC
Will do.  Thanks, Tomas and Stanislav!

Comment 16 Tomas 'Sheldon' Radej 2012-03-07 11:58:04 UTC
Closing the bug.