Using Ant Task Junit produces missing library error

I’d like the ability to execute my unit tests in compiled form instead of having all the classes sitting in a directory. I’ve investigated some of the options available for this, and it seems that Ant is the most likely candidate. I can get this working on the command line directly using JUnit, but am having issues modifying the default Gradle Ant task to contain a needed library:

Problem: failed to create task or type junit

Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found.

This looks like one of Ant’s optional components.

Action: Check that the appropriate optional JAR exists in

-ANT_HOME/lib

-the IDE Ant configuration dialogs

I’m using the Groovy plugin, and have all the JUnit libraries necessary in compile (and testCompile for that matter)… but I’m having issues getting this included in my Ant class path.

Thanks.

You will need to add a configuration containing ant-junit jar to the classpath in your ‘taskdef’ call. See section 17.1.1 of the manual for an example of doing that.

1 Like