I have the same issue as bug http://bugs.gentoo.org/show_bug.cgi?id=231968 but with ant 1.8.1 instead of 1.7.1. I don't have enough privilege to reopen that bug, so here's a new one.
The /usr/bin/ant wrapper sets ANT_HOME as /usr/share/ant-core instead of /usr/share/ant. It might be the desired behavior for portage, but for end-users it's definitely not.
Steps to Reproduce:
1. Get source code from a random Java project, which happens to use several random ant tasks. In my case, http://jogamp.org/jogl/doc/HowToBuild.html
2. Upstream says you just have to type 'ant'. You do that. It works on non-Gentoo machines. It fails on Gentoo with messages like "package org.apache.tools.ant.taskdefs.optional.junit does not exist".
3. The documentation at http://www.gentoo.org/proj/en/java/ant-guide.xml says that I should type e.g. 'ANT_TASKS="pmd checkstyle" ant' instead of 'ant'. I try 'ANT_TASKS="all" ant', but it still won't find junit. I try 'ANT_TASKS="junit" ant', now it finds junit, but it fails with "class org.apache.tools.ant.taskdefs.optional.Javah was not found".
4. Scream in horror and throw your chair on your coworker (who happens to be your boss).
This should really work and dunno why it doesn't. You don't have to define ANT_TASKS="all" because it's the default.
Is dev-java/ant installed with all deps of the same version?
What's output of 'ant --execdebug -diagnostics'?
Created attachment 252385 [details]
output of 'ant --execdebug -diagnostics'
> Is dev-java/ant installed with all deps of the same version?
Yes, just checked:
$ emerge -pv $(qlist -I -C dev-java/ant-)
[ebuild R ] dev-java/ant-core-1.8.1 USE="-doc -source" 0 kB
[ebuild R ] dev-java/ant-nodeps-1.8.1 0 kB
[ebuild R ] dev-java/ant-antlr-1.8.1 0 kB
[ebuild R ] dev-java/ant-apache-log4j-1.8.1 0 kB
[ebuild R ] dev-java/ant-apache-oro-1.8.1 0 kB
[ebuild R ] dev-java/ant-apache-regexp-1.8.1 0 kB
[ebuild R ] dev-java/ant-apache-resolver-1.8.1 0 kB
[ebuild R ] dev-java/ant-commons-logging-1.8.1 0 kB
[ebuild R ] dev-java/ant-commons-net-1.8.1 0 kB
[ebuild R ] dev-java/ant-jdepend-1.8.1 0 kB
[ebuild R ] dev-java/ant-junit-1.8.1 0 kB
[ebuild R ] dev-java/ant-swing-1.8.1 0 kB
[ebuild R ] dev-java/ant-eclipse-ecj-3.5.2 0 kB
[ebuild R ] dev-java/ant-owanttask-1.1-r12 0 kB
[ebuild R ] dev-java/ant-apache-bcel-1.8.1 0 kB
[ebuild R ] dev-java/ant-trax-1.8.1 0 kB
[ebuild R ] dev-java/ant-apache-xalan2-1.8.1 0 kB
[ebuild R ] dev-java/ant-1.8.1 USE="X antlr bcel bsf commonslogging commonsnet jdepend log4j oro regexp resolver -jai -javamail -jmf -jsch -testutil" 0 kB
Total: 19 packages (19 reinstalls), Size of downloads: 0 kB
> What's output of 'ant --execdebug -diagnostics'?
$ env | grep -i ant
$ grep -ri ant /etc/portage/
/etc/portage/package.use:dev-java/ant -javamail -jsch
I don't think I'm doing anything unusual there.
Sorry for forgetting about this. Still no idea what went wrong here, everything you posted looks good and junit should be available.
The request for ANT_HOME itself is dupe of 300970.
*** This bug has been marked as a duplicate of bug 300970 ***