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
- Go to your repository within GitHub
- Select the Actions tab at the top
- Select ‘New workflow’
- Scroll down and select ‘Trigger JitPack Build’ pressing the ‘Set up this workflow’ button
- On the far right select ‘Start commit’
- Update the PR name, then select ‘Commit new file’
- Setup the PR as a draft so we can add the remaining file.
- Pull your feature branch
- 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/.