Skip to main content

Java

For publishing Java libraries, we use JitPack as our artifact repository and GitHub Actions to publish the libraries.

Publishing with JitPack

JitPack reads all the public HMCTS repositories and watches for new releases and tags. As soon as a new tag is found it will be available for download using the following format: com.github.hmcts:Repo:Version.

Setting up JitPack

The first time you request a project, JitPack checks out the code, builds it and sends the Jar files back to you. This can sometimes mean that without editing timeout configuration in your gradle settings users will experience a timeout the first time a tag has been requested. To resolve this issue, a github workflow has been created to build it as soon as a tag is pushed.

An example of that workflow is here: jitpack_build.yml

Using the Github Action

  1. Go to your repository within GitHub
  2. Select the Actions tab at the top
  3. Select ‘New workflow’
  4. Scroll down and select ‘Trigger JitPack Build’ pressing the ‘Set up this workflow’ button
  5. On the far right select ‘Start commit’
  6. Update the PR name, then select ‘Commit new file’
  7. Setup the PR as a draft so we can add the remaining file.
  8. Pull your feature branch
  9. Set your java version in a jitpack.yml file, see below:
jdk:
  - openjdk11

Custom configuration:

By default, JitPack compiles projects using OpenJDK Java 8 and uses ./gradlew install for the maven plugin and ./gradlew build publishToMavenLocal for the maven-publish plugin. If you use both, JitPack will default to using install. In your jitpack.yml you can override the install command like so:

jdk:
  - openjdk11

install:
  - ./gradlew build publishToMavenLocal

Downloading packages from JitPack

To download from JitPack you will need to add the JitPack repo to your list of repositories in your build.gradle files.

repositories {
    ...
    maven {
        url "https://jitpack.io"
    }
}

The dependancy information follows the following format:

  • Group: com.github.hmcts
  • Artifact: Repository Name
  • Version: Release tag, commit hash or master-SNAPSHOT

You will end up with something similar to the example below in your build.gradle files.

dependencies {
    ...
    implementation 'com.github.hmcts.$repo-name:$artifact-id'
}

Checking the Status of a Build

A list of files created from the build and the build log can be found by entering a url with the following format:

List of files from build: https://jitpack.io/com/github/hmcts/repo_name/tag/ Example: https://jitpack.io/com/github/hmcts/idam-health-checker/2.2.5

Multi-module builds

You can view the different module names by selecting the ‘Subproject’ drop-down menu on JitPack for the package, make sure you select a version first, see an example for java-logging 5.1.9.

Further information on JitPack can be found at https://docs.jitpack.io/.

This page was last reviewed on 15 August 2024. It needs to be reviewed again on 15 February 2025 by the page owner platops-build-notices .
This page was set to be reviewed before 15 February 2025 by the page owner platops-build-notices. This might mean the content is out of date.