[go: nahoru, domu]

Skip to content

Template for a multi module project using Maven 3.2.x and Java 11+.

License

Notifications You must be signed in to change notification settings

hpehl/maven-multi-module-template

Repository files navigation

Maven Multi Module Template

Template for a multi module project using Maven 3.2.x and Java 17+.

Features

Get Started

  1. Clone or copy the repo
  2. Adjust Maven coordinates in pom.xml
  3. Adjust name, description, URL, organization and developers in pom.xml
  4. Adjust repo.scm.connection and repo.scm.url in pom.xml
  5. Adjust or remove unnecessary plugins/configuration in pom.xml
  6. 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 in CONTRIBUTING.md

Release Management & Deployment

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 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.

Release Script

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 and next-version are semantic versions
  • that next-version is greater than release-version
  • that no tag v<release-version> exists

If everything is fine, the script

  1. bumps the project version to <release-version>
  2. updates the header and links in the changelog (there should already be entries made by you!)
  3. commits & pushes the changes
  4. creates & pushes a new tag v<release-version> (which triggers the release workflow)
  5. bumps to the next snapshot version <next-version>-SNAPSHOT
  6. commits & pushes changes

By pushing the tag to GitHub, the release workflow kicks in.

Release Workflow

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 JIRA
  • OSSRH_PASSWORD: The password for the Sonatype JIRA
  • MAVEN_GPG_PASSPHRASE: The passphrase for your private GPG key
  • MAVEN_GPG_PRIVATE_KEY: The private key in ASCII format. You can use a command like gpg --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.

Scripts

This repository contains various scripts to automate tasks.

format.sh

Formats the codebase by applying the following maven goals:

The goals use the plugin configuration in pom.xml and the resources in etc.

validate.sh

Validates the codebase by applying the following maven goals:

The goals use the plugin configuration in pom.xml and the resources in etc.

release.sh

Starts a new release (see above).