Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patrickfav/mvn-common-parent
A maven configuration which can be used as a commons config parent for POM files
https://github.com/patrickfav/mvn-common-parent
common maven maven-parent
Last synced: about 2 months ago
JSON representation
A maven configuration which can be used as a commons config parent for POM files
- Host: GitHub
- URL: https://github.com/patrickfav/mvn-common-parent
- Owner: patrickfav
- License: apache-2.0
- Created: 2019-03-16T14:46:01.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-08-07T09:51:38.000Z (over 1 year ago)
- Last Synced: 2023-08-07T10:54:36.395Z (over 1 year ago)
- Topics: common, maven, maven-parent
- Size: 392 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# Maven Common Configuration
A maven configuration which is used as commons config parent for POM files for my maven open source projects. Defines a lot of defaults in `pluginManagement` and some in `dependencyManagement` and activates some plugins.[![Maven Central](https://img.shields.io/maven-central/v/at.favre.lib/common-parent)](https://mvnrepository.com/artifact/at.favre.lib/common-parent)
[![Github Actions](https://github.com/patrickfav/mvn-common-parent/actions/workflows/build_deploy.yml/badge.svg)](https://github.com/patrickfav/mvn-common-parent/actions)## Features
Here is a high level feature set of this project:
* Flexible JDK compiler config with using profiles
* [Checkstyle](http://checkstyle.sourceforge.net/)
* [Google Errorprone](https://github.com/google/error-prone) (Java 7)
* [Maven enforcer](https://maven.apache.org/enforcer/maven-enforcer-plugin/) (for Maven version)
* [Versions plugin](https://www.mojohaus.org/versions-maven-plugin/)
* [OWASP dependency checker](https://jeremylong.github.io/DependencyCheck/dependency-check-maven/)
* [Jacoco](https://www.eclemma.org/jacoco/) + [Coveralls](https://coveralls.io/)
* [Jarsigner](https://maven.apache.org/plugins/maven-jarsigner-plugin/)
* [Checksum](https://checksum-maven-plugin.nicoulaj.net/)
* Default versions for plugins in the [Super POM](http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html)
* Default versions for [junit](https://junit.org/junit4/), jackson, [bytes](https://github.com/patrickfav/bytes-java) and more## Setup
Use as parent pom:
```xml
4.0.0
at.favre.lib
common-parent
[current-version]
...```
Don't forget to overwrite `...` config, otherwise it will be inherited from this project.
### Maven Wrapper (recommended)
It is recommended to use [maven wrapper](https://maven.apache.org/wrapper/) in a new project. Initialize with:
```bash
mvn wrapper:wrapper
```then you can use `mvnw` instead of `mvn`. The advantage is that everybody (+ci) uses a pre-defined maven version. Even [IntelliJ has Maven wrapper support](https://plugins.jetbrains.com/plugin/10633-maven-wrapper-support).
## Configuration
There are many ways to easily customize the parent configuration without the need to change the POM itself. Have a look at the `commonConfig.*` properties in the POM and override them as you please in your ``.
Important config:
```xml
false
```Additionally, you can use maven itself to override certain settings. For instance if you want to deactivate checkstyle, just add
```xml
org.apache.maven.plugins
maven-checkstyle-plugin
true
```### JDK Config
To set the JDK you want to use, this config uses profiles. The easiest way to activate one of the is to generate the file `.mvn/maven.config` and add e.g.:
```properties
-DcommonConfig.compiler.profile=jdk8_w_errorprone
```Currently possible values:
* `jdk7`
* `jdk7_w_errorprone`
* `jdk8`
* `jdk8_w_errorprone`
* `jdk11`
* `jdk11_w_errorprone`
* `jdk17`
* `jdk17_w_errorprone`You can check if the correct profile is set with
```bash
mvnw help:active-profiles
mvnw help:all-profiles
```
### Jacoco Minimum Coverage RulesIf the Jacoco plugin is used, some minimum coverage ratio checks are active. Change them with these properties:
* `commonConfig.jacoco.check.linecov` (60% default)
* `commonConfig.jacoco.check.methodcov` (70% default)
* `commonConfig.jacoco.check.classcov` (80% default)You may disable the check by setting `commonConfig.jacoco.check.disable` to `true`.
### Reference to Project Root
If you need to use e.g. a file that lives within your project (e.g. the keystore file for jar-signing) make sure you
use the correct base path. There are two useful variables to help you:* `${project.basedir}` is the path of your current module
* `${session.executionRootDirectory}` is the root path of your projects (and all your modules) - can be used in
submodules### Deploy
To deploy use activate the profile `deploy` and then you can use the nexus-staging plugin which deploys to
sonatype staging, closes the staging repo, then releases it to Maven Central:```bash
./mvnw -B verify nexus-staging:deploy -P deploy && \
./mvnw -B nexus-staging:release -P deploy
```The `verify` is necessary so that the correct lifecycle phase is called and gpg sign is activated.
This will also activate gpg sign which needs proper setup in `settings.xml`.
As side effect, this will also set property `commonConfig.deployMode.active` if you want to activate other profiles in accordance for example.See also https://github.com/sonatype/nexus-maven-plugins/tree/main/staging/maven-plugin
## Built-In Plugins Explained
### Analyze
Check the created `pom` with
```bash
./mvnw help:effective-pom
```You may check for updates of any plugins or dependencies with
```bash
./mvnw versions:display-dependency-updates
```### Versions-Plugin
Check for possible dependency updates
```bash
./mvnw versions:display-dependency-updates
./mvnw versions:display-plugin-updates
./mvnw versions:display-property-updates
```Set version through command line (or ci script)
```bash
./mvnw versions:set -DnewVersion=1.2.3-SNAPSHOT
```## Related Projects
* externalized [checkstyle-config](https://github.com/patrickfav/checkstyle-config)
# License
Copyright 2019 Patrick Favre-Bulle
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.