Writing and maintaining Maven projects POM is boring. This parent POM is simplifying those tasks in the context of my open source projects by:
- defining common project and developer properties that can be easily overridden in a single place;
- defining a convenient set of configuration default (if you use GitHub, GitHub Actions, Sonatype OSSRH, Docker Hub).
- providing dependency and plugin management
Just inherit from it in your project :
<?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>fr.marcwrobel</groupId>
<artifactId>parent</artifactId>
<version>3.2.0</version>
<relativePath/>
</parent>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>x.y.z-SNAPSHOT</version>
<name>name</name>
<description>description</description>
<url>https://url.com</url>
<inceptionYear>2020</inceptionYear>
...
<!-- only override if needed -->
<properties>
<this.java.version>1.8</this.java.version>
<this.maven.version>3.8.5</this.maven.version>
<dev.name>Marc Wrobel</dev.name>
<dev.username>marcwrobel</dev.username>
<dev.email>marc.wrobel@gmail.com</dev.email>
<dev.url>http://www.marcwrobel.fr/</dev.url>
...
</properties>
</project>
All inherited information can be overridden, especially properties (take a look at this
parent POM for an exhaustive list). Remember you can display the effective POM
using maven-help-plugin
in your project:
mvn help:effective-pom
You must also declare a maven-versions-rules.xml
file at the root of
your project.
- default Maven configuration for
organization
,developers
,scm
,issueManagement
,ciManagement
,distributionManagement
anddefaultGoal
, - dependency management for dozens of libraries (Apache Commons, java extensions, Groovy, Spring, Hibernate to name a few),
- plugin management for cyclonedx-maven-plugin (the configuration should work in most situations),
- plugin management for flatten-maven-plugin (CI-friendly configuration),
- plugin management for
git-commit-id-plugin
(provided by
spring-boot-starter-parent
but non-verbose), - plugin management for jacoco-maven-plugin (activation),
- plugin management for
jib-maven-plugin
(default
from
andto
), - plugin management for
kotlin-maven-plugin
(provided by
spring-boot-starter-parent
), - plugin management for
maven-compiler-plugin
(provided by
spring-boot-starter-parent
), - plugin management for maven-enforcer-plugin (activation and configuration rules for Java and Maven versions),
- plugin management for
maven-failsafe-plugin
(provided by
spring-boot-starter-parent
), - plugin management for
maven-release-plugin
(change
tagNameFormat
). - plugin management for spotless-maven-plugin (binding to the verify phase),
- plugin management and project configuration for sonar-maven-plugin,
- plugin management and project configuration for versions-maven-plugin,
- plugin management for
spring-boot-maven-plugin
(provided by
spring-boot-starter-parent
). - a
release
profile, activated automatically during release withmaven-release-plugin
, which triggers :- sources attachment with maven-source-plugin,
- javadoc attachment with [maven-javadoc-plugin,
- a PGP signature with maven-gpg-plugin.
- an
analyze
profile, that must be activated manually, which triggers thejacoco
agent during unit or integration tests in order to calculate code coverage for SonarQube.
The maven-enforcer-plugin
is the only plugin activated by default.
Take a look at the POM for more information.
This POM is inheriting from
spring-boot-starter-parent
in order to:
- take advantage of the Spring Boot team's work on dependencies (with
spring-boot-dependencies
); - benefit from some good plugin management defaults.
Because this POM is relying so much on spring-boot-starter-parent
its major and minor
versions are also following those of Spring Boot.
Take a look at the contribution guide.
Start a discussion, raise an issue or contribute with a pull-request (please take a look at the contribution guide before).
And for the things that must be kept private (only !), such as security issues, email me at marc.wrobel@gmail.com.