you can just use Java Preprocessor and I guess it will be better way than flags
http://code.google.com/p/java-comment-preprocessor/
flags of course allow to cut and to add blocks on the compilation phase but preprocessor allows to make the process much more flexible