How to Force Build With FIXME Blocks to Fail in Ant

Java Ant

If you need to attach a reminder to some particular piece of code in order to change or fix it later, you can mark it with //XXX, //TODO, //FIXME comments. Even though most IDEs can recognize these comments and add them to a task list, it is still easy to forget about their existence as nothing forces you to go over that list. If you are looking for some stronger solution, you can easily use Ant to fail a build if it contains some specific comment marks.

Here is Ant script that fails a build if sources contain //FIXME comment:

<target name="fixmeCheck" if="productionBuild">
        <fail message="FIXME block found.">
                    <resourcecount count="0">
                        <fileset dir="./src/" includes="**/*.java">
                            <contains text="//FIXME" casesensitive="yes"/>

This solution works well if you have two builds - for local development and for production server, as you don't want to fail your local build every time, only production.

Now if you are experimenting with something or testing some changes, you can just mark that piece of code with //FIXME comment and be sure that you won't forget about it when making a production build.

Sep 1, 2009
profile for serg at Stack Overflow, Q&A for professional and enthusiast programmers