Bug 772375 - ant not using jars in ~/.ant/lib
Summary: ant not using jars in ~/.ant/lib
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: ant
Version: 16
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Mikolaj Izdebski
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-07 03:36 UTC by Scott Shambarger
Modified: 2012-05-07 09:41 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-05-07 09:41:20 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Scott Shambarger 2012-01-07 03:36:31 UTC
Description of problem:
ant build using jar in ~/.ant/lib fails

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

How reproducible:
Always

Steps to Reproduce:
1. Place required .jar file in ~/.ant/lib, in this case maven-ant-tasks.jar (v2.1.3) downloaded from http://maven.apache.org/ant-tasks
2. Create build.xml file that uses classes in .jar file (see below)
3. Type ant, and encounter error
  
Actual results:

Buildfile: /opt/devel/test/build.xml

BUILD FAILED
/opt/devel/test/build.xml:5: Problem: failed to create task or type antlib:org.apache.maven.artifact.ant:remoteRepository
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
        -/opt/devel/.ant/lib
        -a directory added on the command line with the -lib argument

Expected results:
Buildfile: /opt/devel/test/build.xml

help:
     [echo] Test

BUILD SUCCESSFUL

Additional info:

Directory ~/test contains the file build.xml, contents:
--- start build.xml
<?xml version="1.0" ?>

<project name="Test" default="help" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">

  <artifact:remoteRepository id="my.repository" url="http://example.com">
    <snapshots updatePolicy="always" />
  </artifact:remoteRepository>
  <target name="help">
    <echo message="Test"/>
  </target>
</project>
--- end build.xml

This project references artifact:remoteRepository, which is implemented in ~/.ant/lib/maven-ant-tasks.jar (present in user's directory and downloaded directly from http://maven.apache.org/ant-tasks/download.html).

Installing ant-1.8.2-bin from http://ant.apache.org/bindownload.cgi, and setting ANT_HOME to the install directory results in the expected result.  Using the RPM ant-1.8.2 results in the actual results (with ANT_HOME set or unset).

It's possible to work around the problem with a <typedef> in build.xml but that requires updating each and every build.xml file in the source repository, and does not follow the guidelines for maven-ant-tasks on http://maven.apache.org/ant-tasks/installation.html

Jar libraries in /usr/share/ant/lib and ~/.ant/lib should be considered when ant runs (and does on the release binary).  The RPM build does not seem to work correctly.

There doesn't appear to be any documentation supplied with ant-1.8.2 that provides guidelines for any modified behavior of the ant release relative to the apache.org release.

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

Comment 2 Mikolaj Izdebski 2012-05-07 09:41:20 UTC
I am not able to reproduce this bug -- ant was able to use libraries in ~/.ant/lib as expected (see below).

This problem may specific to maven-ant-tasks, which is known to be broken (maven-ant-tasks doesn't work with current version of maven shipped with Fedora). You can consider using aether-ant-tasks instead (not yet packaged for Fedora, but the work is in progress, see #817533).


$ cat /etc/fedora-release 
Fedora release 16 (Verne)

$ ant -version
Apache Ant(TM) version 1.8.2 compiled on July 6 2011

$ ls -go
total 8
-rw-rw-r--. 1 91 May  7 11:23 build.xml
-rw-rw-r--. 1 29 May  7 11:27 foo.java

$ cat build.xml 
<project>
  <target name="foo">
    <javac srcdir="." destdir="."/>
  </target>
</project>

$ cat foo.java 
class foo { int x = bar.y; }

$ find ~/.ant/lib
/home/kojan/.ant/lib
/home/kojan/.ant/lib/bar.jar

$ jar tf ~/.ant/lib/bar.jar
META-INF/
META-INF/MANIFEST.MF
bar.class

$ ant foo
Buildfile: /home/kojan/temp/ant-bug/build.xml

foo:
    [javac] /home/kojan/temp/ant-bug/build.xml:3: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /home/kojan/temp/ant-bug

BUILD SUCCESSFUL
Total time: 3 seconds

$ rm ~/.ant/lib/bar.jar

$ rm foo.class 

$ ant foo
Buildfile: /home/kojan/temp/ant-bug/build.xml

foo:
    [javac] /home/kojan/temp/ant-bug/build.xml:3: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /home/kojan/temp/ant-bug
    [javac] foo.java:1: cannot find symbol
    [javac] symbol  : variable bar
    [javac] location: class foo
    [javac] class foo { int x = bar.y; }
    [javac]                     ^
    [javac] 1 error

BUILD FAILED
/home/kojan/temp/ant-bug/build.xml:3: Compile failed; see the compiler error output for details.


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