Bug 2036419 - Ant could not detect library in `/usr/share/ant/lib`, `$HOME/.ant/lib`, and a directory added on the command line with the -lib argument
Summary: Ant could not detect library in `/usr/share/ant/lib`, `$HOME/.ant/lib`, and a...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: ant
Version: 35
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mikolaj Izdebski
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-01 07:18 UTC by Didik Supriadi
Modified: 2022-01-05 10:46 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-01-05 10:46:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Didik Supriadi 2022-01-01 07:18:06 UTC
Description of problem:

When I tried to use ant for downloading ivy in a project, it downloads ivy in `$HOME/.ant/lib/ivy.jar` (the usual location). But the problem is, `ant` could not detect the library. The output says:

> This appears to be an antlib declaration. 
> Action: Check that the implementing library exists in one of:
>         -/usr/share/ant/lib
>         -/home/dsupriadi/.ant/lib
>         -a directory added on the command line with the -lib argument

Trying to move ivy.jar in `/usr/share/ant/lib` or run ant with -lib didn't do anything and the output is still the same.

Version-Release number of selected component (if applicable):
1.10.11-2.f35

How reproducible:
always

Steps to Reproduce:
1. download/put ivy.jar at $HOME/.ant/lib
2. run ant in java project that contains ivy.xml

Actual results:

BUILD FAILED
/home/dsupriadi/Fork/project/build.xml:67: Problem: failed to create task or type antlib:org.apache.ivy.ant:cachepath
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
        -/usr/share/ant/lib
        -/home/dsupriadi/.ant/lib
        -a directory added on the command line with the -lib argument


Total time: 1 second


Expected results:

(it runs successfully)

Comment 1 Didik Supriadi 2022-01-01 09:18:09 UTC
Running `java -cp $(build-classpath ant/ant-launcher) org.apache.tools.ant.launch.Launcher` solves my problem.

But now I'm confused, why `java -cp $(build-classpath ant/ant ant/ant-launcher) org.apache.tools.ant.launch.Launcher` doesn't work?

I tried it with upstream jars, but the error is the same.

Comment 2 Mikolaj Izdebski 2022-01-05 10:46:43 UTC
This is not a bug in Ant.

When Ant is launched in "RPM mode" (which is default for Ant packaged for Fedora) then the mechanism of loading JARs from $HOME/.ant/lib is not used - ant JARs are loaded from /usr/share/ant/lib and extension JARs (such as third-party tasks) are loaded from standard directories (such as /usr/share/java and /usr/lib/java) according to configuration files in /etc/ant.d/. This is intentional.

To disable "RPM mode" of launching Ant you can set rpm_mode=false in one of Ant configuration files (globally in /etc/ant.conf, or per-user in $HOME/.ant/ant.conf). Another possibility is running Ant with --noconfig option.

References:
Upstream bug: https://bz.apache.org/bugzilla/show_bug.cgi?id=44849
Related RHEL 5 bug: https://bugzilla.redhat.com/show_bug.cgi?id=443523


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