Jalopy is a Java source code formatter, which has a plug-in for Ant. Most modern IDE already includes source code formatting functionality. However, having a common source code formatter for the whole team, integrated in the build process, provides a standardized style formatting.
After downloading the Jalopy Ant plug-in, place the jar files in your project directory. Personally, I am happy with the default style. However, if you would like to customize the style, for example adding javadoc, you can use the preference.bat or preference.sh executable that comes with the download. You can export the style you customized to an xml file, which can be placed in your project directory and referenced in your ant task.
<?xml version="1.0" ?>
<project name="myProject" default="format" basedir="." >
<property name="dir.jalopy" value="${basedir}/lib" />
<property name="dir.src.java" value="${basedir}/src/java" />
<!-- ==================================================================== -->
<!-- Defines the Jalopy task -->
<!-- ==================================================================== -->
<taskdef name="jalopy"
classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
<classpath>
<fileset dir="${dir.jalopy}">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<!-- ==================================================================== -->
<!-- Formats all source files -->
<!-- ==================================================================== -->
<target name="format">
<jalopy convention="convenrion.xml">
<fileset dir="${dir.src.java}">
<include name="**/*.java" />
</fileset>
</jalopy>
</target>
</project>