General Formatting Conventions
The OFBiz project follows the Sun coding standards for Java source code. For information regarding this standard please visit http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
For Groovy we suggest you read http://www.groovy-lang.org/style-guide.html but we don't expect people to follow all details there, still a good read..
HTML code should be XHTML compliant. Groovy and Javascript files should follow the same conventions as Java files.
We don't want tab characters in text files in SVN, because different editors and tools interpret tabs differently. All indentation should be done purely with spaces.
In accordance with this standard we use 4 space indention rather than tabs, and set the tab size to 8 spaces to make code with tabs easier to pick out. Make sure no code contains tab characters.
For XML/HTML/FTL files we follow the standard XML/HTML/FTL format (TODO: add link to a reference here). XML/HTML/FTL files should use 2 spaces instead of 4, but there are still number of files using 4 space indention. So it's better to keep the indentation used in each file to avoid confusion when committing.
To change tabs to spaces in Eclipse, change these preferences in Window -> Preferences->
- Java -> Code Style -> Code Formatter -> In dropdown pick -> Java Conventions built-in -> Indentation, select Tab policy as "Spaces Only". Enter a new name for this profile and click "OK".
- General -> Editors -> Text Editors -> Insert spaces for tabs
- XML -> XML Files -> Editors -> Text Editors -> Indent using spaces (4)
- Unfortunately the main FreeMarker plugins has no similar functionnality yet. But there is somehow a (sometimes annoying) solution :
- Install AnyEdit plugin (http://andrei.gmxhome.de/eclipse/) and set its parameters in General -> Editors -> AnyEdit Tools. When using AnyEdit plugin, you should set it to
- Convert tab to space (it's by default in last versions)
- Add filters (like *.js, *.css) for files you don't want to auto-convert)
- Install AnyEdit plugin (http://andrei.gmxhome.de/eclipse/) and set its parameters in General -> Editors -> AnyEdit Tools. When using AnyEdit plugin, you should set it to
In Eclipse, for Java, you may use Ctrl+I to be sure of correct indentation.
Files paths
- Java
The OFBiz project follows the Maven Standard Directory Layout to organise its Java file. At the moment of writing there are only a few unit tests (but a lot of what we so far integration tests) so you will mostly find the ../src/main/java/org/apache/ofbiz.. path in components but in few components in framework (base, entity, start, webapp) you will also find the ..src/test/java/org/apache/ofbiz.. path - Groovy
We decided to use a groovyScripts sub-folder under components folders to put parsed Groovy scripts, groovyScripts rather that script because other script languages could be used in the future
Even if it's no used yet we reservedf the groovy sub-folder under components folders for pre-compiled Groovy. A distant goal is to replace Minilang by a Groovy DSL - Freemarker
The Freemarker templates are in template sub-folders under components folders - Minilang
The Minilang map processors and minilang scripts are in minilang sub-folders under components folders