The Maven style for Java is mainly:html
Readingness: Specify code grouping members, if needed. For instance in a Mojo class, you could have:express
public class MyMojo { // ---------------------------------------------------------------------- // Mojo components // ---------------------------------------------------------------------- /** * Artifact factory. * * @component */ private ArtifactFactory artifactFactory; ... // ---------------------------------------------------------------------- // Mojo parameters // ---------------------------------------------------------------------- /** * The POM. * * @parameter expression="${project}" * @required */ private MavenProject project; ... // ---------------------------------------------------------------------- // Mojo options // ---------------------------------------------------------------------- ... // ---------------------------------------------------------------------- // Public methods // ---------------------------------------------------------------------- /** * {@inheritDoc} */ public void execute() throws MojoExecutionException { ... } // ---------------------------------------------------------------------- // Protected methods // ---------------------------------------------------------------------- ... // ---------------------------------------------------------------------- // Private methods // ---------------------------------------------------------------------- ... // ---------------------------------------------------------------------- // Static methods // ---------------------------------------------------------------------- ... }
The Maven style for XML files is mainly:apache
Line Breaks: Always use a new line with indentation for complex XML types and no line break for simple XML types. Always use a new line to separate XML sections or blocks, for instance:app
<aTag> <simpleType>This is a simple type</simpleType> <complexType> <simpleType>This is a complex type</simpleType> </complexType> </aTag>
In some cases, adding comments could improve the readability of blocks, for instance:less
<!-- Simple XML documentation -->
ormaven
<!-- ====================================================================== --> <!-- Block documentation --> <!-- ====================================================================== -->
The team has voted during the end of June 2008 to follow a specific POM convention to ordering POM elements. The consequence of this vote is that the Maven project descriptor is no more considered as the reference for the ordering.ide
The following is the recommended ordering for all Maven POM files:svn
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion/> <parent/> <groupId/> <artifactId/> <version/> <packaging/> <name/> <description/> <url/> <inceptionYear/> <organization/> <licenses/> <developers/> <contributors/> <mailingLists/> <prerequisites/> <modules/> <scm/> <issueManagement/> <ciManagement/> <distributionManagement/> <properties/> <dependencyManagement/> <dependencies/> <repositories/> <pluginRepositories/> <build/> <reporting/> <profiles/> </project>