IDE Agnostic Instructions
Formatting Java files:
- JavaDoc parameter information is on the same line, not indented
- Line length is 128 characters
- Spaces are used instead of tabs
- Switch blocks are indented
- Indentation size is 4
Formatting Resource Files
All of resources files have to follow these conventions:
- Line length is 128 characters
- Spaces are used instead of tabs
- Indentation size is 4
Eclipse
(version 3.7 used)
Both of the code-style configurations (format and clean-up) needs to be configured to pass JBoss Community checkstyle criterion.
Java Formatter Rules
(Ctrl+Shift+F by default)
- download the formatting rules locally:
https://github.com/richfaces/build/raw/master/ide-prefs/eclipse-formatting-rules.xml - in Eclipse go to Window -> Preferences -> Java -> Code Style -> Formatter
- click Import
- select formatting rules which you have downloaded in step (1)
(see picture bellow)
Clean-up Rules
(not bound by default, use of Ctrl+Shift+O recommended)
- download the clean-up rules locally:
https://github.com/richfaces/build/raw/master/ide-prefs/eclipse-cleanup-rules.xml - in Eclipse go to Window -> Preferences -> Java -> Code Style -> Clean-up
- click Import
- select clean-up rules which you have downloaded in step (1)
Map the Clean-up Rules to Ctrl+Shift+O
- in Eclipse go to Window -> Preferences -> General -> Keys
- type "clean" into filter input ("type filter text")
- select Clean-up
- setup Binding: focus the input and type Ctrl+Shift+O as individual keys (or any other prefered shortcut)
- you will have to unbind Ctrl+Shift+O from "Organise imports" action first
Be sure to trigger Formatting and and then Clean-up (in right order) before each file save!
Formatting XML
- in Eclipse go to Window -> Preferences -> Web -> XML Files -> Editor
- setup
- Line width: 128
- Split multiple attributes each on new line: NO
- Align final bracked in multi-line element tags: NO
- Preserve whitespace in tags with PCDATA content: NO
- Clear all blank lines: NO
- Format comments: NO
- Insert whitespace before closing empty eng-tags: YES
- Indent using spaces
- Indentation size: 4
Formatting CSS
- in Eclipse go to Window -> Preferences -> Web -> CSS Files -> Editor
- setup
- Line width: 128
- Insert line break between properties: YES
- Disable wrapping in style attribute of Html: YES
- Indent using spaces
- Indentation size: 4
- Capitalization style: all Lowercase
- Line width: 128
Formatting HTML
- in Eclipse go to Window -> Preferences -> Web -> HTML Files -> Editor
- setup
- Line width: 128
- Split multiple attributes each on new line: NO
- Align final bracked in multi-line element tags: NO
- Clear all blank lines: NO
- Indent using spaces
- Indentation size: 4
- Tag names: Lowercase
- Attribute names: Lowercase
- Line width: 128
Intellij IDEA
(version 10.5 used)
- download JAR distribution with IDEA settings (contains only Code style settings):
https://github.com/richfaces/build/raw/master/ide-prefs/idea-settings.jar - in IDEA go to File -> Settings -> Import Settings
- select the downloaded JAR file
- confirm to import Code Style and File Templates
- restart IDE
Netbeans
(version 7.0 used)
- download ZIP distribution with Netbeans settings
https://github.com/richfaces/build/raw/master/ide-prefs/netbeans-jboss-community-formatter.zip - in Netbeans go to Tools -> Options
- click to Import button at bottom of Options dialog
- click Browser and select downloaded ZIP file
- there will be All -> Editor -> Other structure listed in Available Options
- select All and click OK
- restart IDE
Comments