Template for a multi module project using Maven 3.2.x and Java 17+.
- Maven Wrapper
- Inherits from JBoss Parent POM
- Multi module:
- Parent POM with basic info, properties and minimal plugin definitions
- Build config containing checkstyle rules, formatter definition and license template
- BOM declaring project dependencies
- Parent code module with dependency and plugin management
- Code module with some dummy code
- WildFly checkstyle configuration
- Maven Enforcer Plugin with rules enforcing
- secure repositories over HTTPS
- Java >=17
- Maven >= 3.2.5
- Maven License Plugin
- Maven Formatter Plugin
- Maven ImpSort Plugin
- Sample dependencies Eclipse Collections and JUnit 5
- SLF4J and Logback support
- Empty JUnit 5 unit test
- Support for keeping a changelog
- Sample code of conduct and contribution guide
- Release profile which generates and signs source and JavaDoc JARs
- Deployment to Maven Central using a GitHub workflow
- Clone or copy the repo
- Adjust Maven coordinates in
pom.xml
- Adjust name, description, URL, organization and developers in
pom.xml
- Adjust
repo.scm.connection
andrepo.scm.url
inpom.xml
- Adjust or remove unnecessary plugins/configuration in
pom.xml
- Add dependencies, code, and tests
If you want to keep the contribution guide, make the following adjustments:
- Replace all URLs and paths containing
maven-multi-module-template
inCONTRIBUTING.md
There are many options for how to release and deploy new versions. This project takes an opinionated approach using a bash script to kick off a new release and a GitHub workflow for doing the actual release and deploying all artifacts to Maven Central.
The project already fulfills all requirements and recommendations for deploying to Maven Central:
- the POM contains all required metadata
- source and Javadoc JARs are produced
- all artifacts are signed
- the Nexus Staging Maven Plugin is used for deployment
The project uses https://s01.oss.sonatype.org/ for the deployment to Maven Central. It's configured as property repo.sonatype.url
in the POM. Please change the URL to your needs.
The script release.sh
starts a new release. You should make the following adjustments:
- specify your git remotes using the array
GIT_REMOTES
. If you're working on a forked repository this is most likely("origin" "upstream")
- adjust the variable
WORKFLOW_URL
to your needs
The release script requires two parameters:
./release.sh <release-version> <next-version>
The release script verifies
- that you don't have uncommitted changes
- that both
release-version
andnext-version
are semantic versions - that
next-version
is greater thanrelease-version
- that no tag
v<release-version>
exists
If everything is fine, the script
- bumps the project version to
<release-version>
- updates the header and links in the changelog (there should already be entries made by you!)
- commits & pushes the changes
- creates & pushes a new tag
v<release-version>
(which triggers the release workflow) - bumps to the next snapshot version
<next-version>-SNAPSHOT
- commits & pushes changes
By pushing the tag to GitHub, the release workflow kicks in.
The release workflow is defined in release.yml
. It operates fully automated and relies on several secrets that have to be configured:
OSSRH_USERNAME
: The username for the Sonatype JIRAOSSRH_PASSWORD
: The password for the Sonatype JIRAMAVEN_GPG_PASSPHRASE
: The passphrase for your private GPG keyMAVEN_GPG_PRIVATE_KEY
: The private key in ASCII format. You can use a command likegpg --armor --export-secret-keys <key-id> | pbcopy
to export and copy the private key to the clipboard (on macOS).
The release workflow builds and deploys the project. Upon successful execution, a new GitHub release is created. The name of the release uses the name of the project as specified in the POM followed by <release-version>.Final
.
This repository contains various scripts to automate tasks.
Formats the codebase by applying the following maven goals:
The goals use the plugin configuration in pom.xml and the resources in etc.
Validates the codebase by applying the following maven goals:
enforcer:enforce
checkstyle:check
license-maven-plugin:check
formatter-maven-plugin:validate
impsort-maven-plugin:check
The goals use the plugin configuration in pom.xml and the resources in etc.
Starts a new release (see above).