This page last changed on Jan 09, 2007 by aaime.

Overview

Adding automated code formatting to the maven build so that code formatting is always done.
Proposed By:
Justin Deoliveira
Proposal Type:
Process
Assigned to release:
1.4.0
State:
Aproved, waiting on Jalopy bug(s)
Voting history:
Jody Garnett +1
Rob Atkinson +1
Alessio Fabiani +1
Andrea Aime +1
Gabriel Roldán +1

Links

Email discussion:
http://www.nabble.com/code-formatting-on-trunk%2C-commit-etiquette-tf2028778.html

Other wiki discussions:

Motivations

Differnt developers use different platforms and different development environemnts, which can lead to code being formatted in strange ways. Furthermore, every programmer has a differnt style. A consistent look and feel througout a codebase adds an heir of professionalism to a project. By adding an automated formatter to the maven build every time the code is compiled it will be formatted, and consistent for everyone.

Proposal

Using the jalopy-maven-plugin in the geoserver build. Either to run the format task on every compiliation, or to make it developer policy to run the format task manualy before every commit.

Coding Conventions

From Andrea Aime

Here is my suggestion: plain old java formatting rules
Personally I'd like to see the code wrapped at 100 columns instead of 80, but that's just me.

Moreover, we must turn off jalopy javadoc comment formatter since it breaks as soon as the html is the comment is invalid with nasty error messages (aka, difficult to say what was wrong).

In parallel, I'd say we should dump an Eclipse code formatting template so that developers can format also without the build (I'm assuming the most of us are using Eclipse, feel free to dump settings for other ide too).

Implementation

The initial pom setup can go as follows:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>jalopy-maven-plugin</artifactId>
  <configuration>
     <convention>jalopy.xml</convention>
     <failOnError>false</failOnError>
   </configuration>
</plugin>

Setting up the formatter to run on a compile :

<execution>
    <phase>compile</phase>
    <goals>
      <goal>format</goal>
    </goals>
  </execution>

The jalopy geoserver convention attached to this page is a plain java coding convention with 100 colums wrapping and a custom Geoserver header.
The old jalopy geoserver convention attached to this page is the original Geoserver 1.3.0 convention, basically a modified plain java coding convention with 100 colums wrapping, Geoserver header and with
members reordering.

Participants


I think we're going to need someone to run jalopy on the full source tree, since some files have not been properly formatted, and if we just put it in the build then some developer changes will get mixed in with commits.

Also note we already have a jalopy file. It was in documents/jalopy.geoserver.xml on the 1.3.x source tree, not sure where it ended up in 1.4

Posted by cholmes at Aug 08, 2006 14:27
Document generated by Confluence on May 14, 2014 23:00