Java 소스에서 ANT를 사용하여 태그 (TODO : ETC)를 확인하는 방법
문제
개발 중에만 코드에서 이와 같은 것을 보는 것이 일반적입니다.
//XXX: not in production!
String password = "hello"; // getActualPassword(...);
...
catch(Exception e) { /* TODO: Auto-generated catch block*/ }
ANT가 a) 경고 (todo : / fixme : tags) 또는 실패 (xxx : 또는 simmilar)를받을 수 있기를 바랍니다.
빌드 서버는 Linux이며, 집으로 성장하고 개미를 기반으로합니다. Windows가 아닌 경우 적어도 Linux에서 작업해야합니다.
대안이 파일 커밋을 차단하는 경우 Perforce를 사용합니다.
우리는 또한 Eclipse를 사용하지만 치명적인 오류로 만들 수 있다고 생각하지 않습니다. (예, 작업보기가 있지만 빌드 브레이커로 특정 태그를 높이고 싶습니다).
해결책
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.
You could also use the Ant TODO task.