Skip to content

ministryofjustice/laa-crime-commons

Repository files navigation

Laa-Crime-Commons

This repository contains shared libraries that support laa crime microservices.

It currently contains a single module (crime-commons-spring-boot-starter) that autoconfigures web clients for communicating with other services and also provides several related utility classes.

CircleCI MIT license Quality Gate Status

repo standards badge

Getting Started

Pre-requisites

  • JDK 17
  • Spring Boot 3.0.4

Install dependencies and build modules with Gradle:

./gradlew clean build

Usage

To use a published package from GitHub Packages, add the package as a dependency and add the repository to your project For more information, see "Declaring dependencies" in the Gradle documentation.

  1. Authenticate to GitHub Packages
  2. Add the package dependencies to your build.gradle file
dependencies {
    implementation 'com.example:package'
}
  1. Add the repository to your build.gradle file
repositories {
    maven {
        url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY")
        credentials {
            password = project.findProperty("github-token") ?: System.getenv("GITHUB_TOKEN")
            username = project.findProperty("github-username") ?: System.getenv("GITHUB_USERNAME")
        }
    }
}

GitHub Authentication

You will need to create a gradle.properties file, specifying values for the github-username and github-token properties. These can also be set as environment variables.

Coverage

The Jacoco Gradle plugin is used to generate coverage reports:

./gradlew jacocoTestReport

These are used by SonarCloud to evaluate code quality and maintainability. Jacoco coverage reports are auto generated when builds are performed through CircleCI or new changes are merged into the main branch.

Click the SonarCloud badge above to view these metrics.

Releases

Publishing Artefacts

Each time changes are merged into the main branch, a new release is tagged and published to GitHub Packages. To perform a manual release, you will need to authenticate with GitHub (see above).

This enables you to run the following command:

./gradlew publish

Releases can also be published from branches, however, the version number will be auto-generated and requires manual approval through CircleCI. See below for more information on our versioning strategy for published modules.

Version Management

The Semver Gradle Plugin is used to implement Semantic versioning.

Once the Jar files for each module have been built in CircleCI, the latest commit will be tagged with a new version number, by default, the minor version number is incremented. However, It is possible to manually bump other parts of the version string:

For 'crime-commons-spring-boot-starter-rest-client' module:

  • bump the major number: ./gradlew "-Psemver.stage=final" "-Psemver.scope=major" "-Psemver.tagPrefix=rest-client-"
  • bump the patch number: ./gradlew "-Psemver.stage=final" "-Psemver.scope=patch" "-Psemver.tagPrefix=rest-client-"

For 'crime-commons-classes' module:

  • bump the major number: ./gradlew "-Psemver.stage=final" "-Psemver.scope=major" "-Psemver.tagPrefix=crime-commons-classes-"
  • bump the patch number: ./gradlew "-Psemver.stage=final" "-Psemver.scope=patch" "-Psemver.tagPrefix=crime-commons-classes-"

New releases will be automatically tagged and published when changes are merged into the main branch. Artifacts can also be published from feature branches, however, these require manual approval through CircleCI.

Contributing

Bug reports and pull requests are welcome. However, please make sure your changes are covered by tests and follow modern software development best practices. Otherwise, it is likely that your changes will be rejected.

  1. Clone the project (git clone https://github.com/ministryofjustice/laa-crime-commons.git)
  2. Create a feature branch (git checkout -b my-new-feature)
  3. Commit until you are happy with your contribution (git commit -am 'Add some feature')
  4. Push the branch (git push origin my-new-feature)
  5. Open a new pull request, specifying your changes in detail.