Parent POM for all MojoHaus hosted Apache Maven plugins and components.
Changelog
How to use the POM
- for general information about using a parent pom take a look at http://maven.apache.org/guides/introduction/introduction-to-the-pom.html.
- it boils down to define a parent element in your own POM:
<?xml version="1.0" encoding="UTF-8"?>
<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>4.0.0</modelVersion>
<parent>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mojo-parent</artifactId>
<version>74</version>
</parent>
<groupId>sample-groupId</groupId>
<artifactId>sample-project</artifactId>
<version>1-SNAPSHOT</version>
[...]
</project>
Spotless - automatic code formatting
MojoHaus
Parent POM contains configuration for spotless-maven-plugin
with options:
- palantir code formatter
- imports order as:
- javax
- java
- other imports
- static import
In order to use spotless
in your project, you should add to your pom.xml
Newer version of spotless requires JDK 11, so it must be add in profile unless your project requires 11 by default.
<properties>
<recommendedJavaBuildVersion>11</recommendedJavaBuildVersion>
</properties>
<profiles>
<profile>
<id>java11+</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
When spotless
will be enabled, each build will be check according to correct code format.
To fix code, simply run:
mvn spotless:apply
Checkstyle
You can use checkstyle
in order to verify code on each build.
Checkstyle can be enabled by adding to build/plugins`:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
When you want to use checkstyle
together with spotless
, please add:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${checkstyle.spotless.config}</configLocation>
</configuration>
</plugin>
Big code reformat
After applying bigger reformatting it is recommended to add or update a .git-blame-ignore-revs
file
in the root of the repository containing a line with the SHA1 of the formatting commit to ignore those changes
when using git blame
(or equivalent concepts).
This is automatically considered by GitHub
and can optionally be considered with local git blame
Latest releases
… may be found at Maven Central.
Deploy site to github
To deploy a site to github using maven-scm-publish-plugin:
- Add a new branch
gh-pages
manually. - Add
src/site/resources/.nojekyll
to add hidden files (e.g. for jacoco) as well. - Then after a release do:
cd target/checkout
mvn -Preporting verify site-deploy