Skip to content
Jody Garnett edited this page Jul 12, 2017 · 1 revision

GSIP 2 - Automated Code Formatting

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 {panel} 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). {panel}

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

  • Andrea Aime
  • Justin Deoliveira
Clone this wiki locally