Search code examples
javaantjunit

ant junit task -- where to download ant-junit.jar and where to put it?


I literally wasted 2 hours trying to get ant junit task working. First, I had trouble finding ant-junit.jar file but I managed to find it in a maven page. After that I put it several places(~/.ant/lib, /usr/share/ant/lib) but no luck.. I'm still getting this error:

Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found.
        This looks like one of Ant's optional components.

So I'm looking for:

  1. Official web page to download ant junit task files
  2. Correct place to put that file.

Solution

  • 1. The Ant download distribution

    Expurgated tree:

    ➜  apache-ant-1.9.4  tree lib
    lib
    ├── ant-junit.jar
    ├── ant-junit4.jar
    

    2. Your test classpath

    Just like any other test dependency.


    Tangential: The distro (or a Maven repo/search) is generally the first place to look. It’s a few minutes to download, decompress, look for the JUnit-related files, and do a tar xvf to sanity-check the missing class ref.