Skip to main content

Java

For publishing Java libraries, we now use Azure Artifacts (preferred platform default). Previously, we used JitPack as our artifact repository to publish the libraries, which is now deprecated and scheduled for removal from the platform by July 2025.

Publishing with Azure DevOps Artifacts

You will need to set up a Github Action in your repo, using the centralised GitHub Action template below as a starting point. This template will watch for new tags, and upon a new tag being available, will package and publish your project to our Azure DevOps Artifacts feed hmcts-lib.

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 ADO Artifact 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

Gradle setup

You will also need to add the following repositories block to the publishing section of your build.gradle file:

publishing {
  repositories {
    maven {
      name = "AzureArtifacts"
      url = uri("https://pkgs.dev.azure.com/hmcts/Artifacts/_packaging/hmcts-lib/maven/v1")
      credentials {
        username = System.getenv("AZURE_DEVOPS_ARTIFACT_USERNAME")
        password = System.getenv("AZURE_DEVOPS_ARTIFACT_TOKEN")
      }
    }
  }
}

For example, see rse-cft-lib

Now, when you produce a new tag a build will be triggered in Azure DevOps, and make your artifact available for download

Downloading packages from Azure DevOps Artifacts

To download from ADO Artifacts you will need to add the feed to your list of repositories in your build.gradle files.

maven {
  url 'https://pkgs.dev.azure.com/hmcts/Artifacts/_packaging/hmcts-lib/maven/v1'
}

The dependency 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.java-logging:logging:test-6.1.8'
}

Publishing with JitPack (deprecated and to be removed)

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 31 March 2025. It needs to be reviewed again on 30 September 2025 by the page owner platops-build-notices .
This page was set to be reviewed before 30 September 2025 by the page owner platops-build-notices. This might mean the content is out of date.