I currently use Ant to build Java software.
However, all development that I have done so far was not very complex. So, ant was sufficient for me.
Recently, I have started working on a bit complex project that requires some conditional checks while building. I find doing that a little complex with ant.
Is there any better way to do conditional checks in Ant. Or please suggest me a better tool, if any.
PS: I am not a Ant Pro. So, I might be missing something. So, please let methose condition know if I am missing some feature of Ant.
Switching build technology to Gradle or Maven are the best choices if you’re ready to embrace a more modern build technology.
On the other hand if you only need to occasionally extend your build logic I’d suggest an intermediate approach of embedding a scripting language within your build (Better in my opinion that using the ant-contrib tasks).
A good candiate is groovy, which has excellent integration with the parent ANT build settings. (Groovy is also the technology behind Gradle)
Example
You did not indicate what kind of conditional checks you wanted to perform.
The following example parses all Java source files checking for the presence of the “hello world” string.
When found it sets the ANT property somethingwrong which prevents the build from executing.,
Note how groovy can iterate thru an ANT fileset and set ANT properties.