Manual:Coding conventions/Java

This page describes the coding conventions used within files of the man>Special:MyLanguage/Manual:Code|MediaWiki codebase written in Java. See also the man>Special:MyLanguage/Manual:Coding conventions#All languages|general conventions that apply to all program languages, including Java.

MediaWiki Java code is inspired by the [https://google.github.io/styleguide/javaguide.html Google Java Style]. It differs at least in the following:


 * indent with 4 spaces

A xml>gerrit:plugins/gitiles/wikimedia/discovery/discovery-maven-tool-configs/+/refs/heads/master/src/main/resources/org/wikimedia/discovery/build/tools/checkstyle/checkstyle.xml|Checkstyle configuration file is used for verification by the [https://maven.apache.org/plugins/maven-checkstyle-plugin/ Maven Checkstyle Plugin]. This file is bundled in the discovery-maven-tool-configs project and can be used as a dependency as shown in the discovery-parent-pom project.

Various other conventions are embodied in the plugin configurations found in the discovery-parent-pom project. See the README.md in that project for additional documentation. You can use that parent pom directly, or pick the pieces which makes the most sense for a specific project.