I found the problem myself. To do the build from source, you need to add junit.jar to Ant's lib directory. Go to ANT_HOME/lib and copy junit.jar to it. Hope someone else finds this information useful.
I think the reason it has to be there is because the CactusTask extends an AntTask and in order for Ant to compile a new task, it uses its own classpath to do so. That is why defining the location of junit.jar in the build.xml did not help. That's my best guess anyway.