it's common to see something like this in code, hopefully only during development:
//XXX: not in production!
String password = "hello"; // getActualPassword(...);
...
catch(Exception e) { /* TODO: Auto-generated catch block*/ }
I would like ant to be able to a) warn (on TODO: / FIXME: tags) or fail (on XXX: or simmilar)
The build server is linux, home grown and based on ant. Would need to work at least on linux if not on windows.
We also use perforce if an alternative is to block file commits.
We also use eclipse, however I don't think you can make it a fatal error. (yes, there's the tasks view, however I would like to be able to elevate certain tags to build-breakers)
Maybe you can use Checkstyle. I think there is a check for TODO comments and checkstyle can be run as an Ant task so you might achieve what you want.
You can use ant conditions for these checks:
<condition property="isSourceFileOK">
<not>
<isfileselected file="${source}">
<contains text="TODO" casesensitive="yes"/>
</isfileselected>
</not>
</condition>
<fail unless="isSourceFileOK" message="Source contains TODO!" />
As for the Perforce variant, you will likely want to write a trigger for that. See the perforce docu about triggers for more information. In your case, you'd write a 'change-content' trigger in order to see the file-content on the Perforce server before file-commit.
Within the trigger you can use p4 files //depot/...@4711
to get a list of files of the change (in this case 4711, but is handed over on the command line to the trigger. For each of the files you'd use p4 print -q //depot/path/to/file@4711
to get the content of the file and scan this for your keywords (TODO/XXX). You could print a warning on stdout in case of TODO and exit with code 0, so that the commit succeeds and exit with code 1 in the case of XXX so that the commit fails.
First, jassuncao is correct; Checkstyle does what you are asking, according to the docs here. At the risk of incurring "don't reinvent the wheel" wrath, I might also suggest that what you are wanting to accomplish is a nice problem for someone who wants to learn how to write Ant tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With