I maintain the build for a large Java EE/Maven/Hudson/Perforce project with about 20 developers spread across the world.
The solution in-place for code formatting is to format the codebase using Jalopy when the developer runs the build, thereby ensuring any code which has not been formatted gets formatted prior to check-in.
The main problem with this solution, is that if the developer doesn’t run a full Maven build before checking in (say they run the unit tests from Eclipse) their code won’t get formatted. Then, the next developer who edit the file may have many, many diffs in unrelated sections of the code after they run the formatter.
What source formatting strategy has worked best for you on large projects? Another option I had considered is formatting nightly using an automated process.
The Maven build should just be reporting formatting errors using something like Checkstyle and not automatically formatting the code. That’s what your description seemed to imply. This way errors are reported to the developer/Hudson at build time and they can be resolved as needed.
I’d also suggest using a tool like Sonar to keep a history of formatting errors over time (see their time machine functionality).