Currently I use an IDE for all my builds and unit tests. Now I have a need to use ant. I found a few simple ant build.xml scripts but they didn’t support a separate Junit test/ dir. My projects are structured as follows:
src/ com/foo/ com/bar/ test/ -- Mirror of src/, with all *Test.java files. com/foo/ com/bar/ lib/ -- All Java libs, including junit 4.
How can a construct a small ant script that builds my src/ and test/ Java classes then runs all my JUnit tests?
I define
<path>elements for each target.This is an excerpt from my build file, you’ll have to adapt some paths and properties, but you can get the idea:
And if you need to refine this to your needs, as cotton.m says, go read the ant task docs. Using ant with your specific directory structure does require some knowledge of the tool, don’t expect you’ll easily find ready-made examples that just work with your exact requirements.