Build backend module
build-backend-module.yml builds an OpenMRS backend module (an api + omod project) on every Java version its
OpenMRS platform supports, uploads the .omod with checksums, stages JaCoCo coverage for
Upload coverage, and deploys SNAPSHOT artifacts after a push to a release branch. It behaves like
Build Maven project, plus the OMOD handling and a Java matrix inferred from the platform version.
Usage
name: Build with Maven
on:
push:
branches: [main]
pull_request:
jobs:
build:
uses: openmrs/openmrs-contrib-gha-workflows/.github/workflows/build-backend-module.yml@main
secrets:
MAVEN_REPO_USERNAME: ${{ secrets.MAVEN_REPO_USERNAME }}
MAVEN_REPO_API_KEY: ${{ secrets.MAVEN_REPO_API_KEY }}What it does
- Prepare: runs
mvn help:effective-pomand infers the Java versions, the SNAPSHOT server ID and repository URL, and the project version. Decides whether a SNAPSHOT deploy is allowed. - Build: runs
mvn --batch-mode <maven_args> -Dmaven.deploy.skiponce per Java version, in parallel. On the main Java version it also:- stages any
jacoco.xmlreports as acoverage-reportsartifact, unlessupload_coverageis"false"; - uploads
omod/target/<finalName>.omodwith.sha1and.sha256checksums as an artifact named after the OMOD.
- stages any
- Deploy: after every build passes, runs
mvn deploy -DskipTestson the main Java version, if the SNAPSHOT deploy rules allow it. The rules are the same as for Build Maven project.
Java versions
java_versions comes from the module’s OpenMRS platform version, found in this order: an openmrs-api or
openmrs-web dependency, the same in <dependencyManagement>, then the openmrsPlatformVersion property set by the
OpenMRS module parent POM. Version ranges such as [2.4.0,) take every Java version their tiers cover.
| Platform version | Java versions |
|---|---|
| 2.0.x to 2.3.x | 8 |
| 2.4.x to 2.6.x | 8, 11 |
| 2.7.x to 2.x | 8, 11, 17, 21 |
| 3.0.0 and later | 21, 25 |
Versions below the module’s compiler target are dropped. The main Java version, which stages coverage, uploads the OMOD and deploys, is the lowest remaining version.
Platform 1.x is not in the table, so a module built against it fails with “java_versions could not be determined”.
Pass java_versions (e.g. '[8]') and main_java_version explicitly.
OpenMRS defaults
OpenMRS modules pass the MAVEN_REPO_USERNAME and MAVEN_REPO_API_KEY org secrets and inherit their deploy
repositories from the OpenMRS module parent POM, so no inputs are usually needed. Keep the workflow named
Build with Maven if you use Upload coverage.
Outside OpenMRS
The workflow expects an omod module at omod/ and fails if no .omod is built. For other Maven projects use
Build Maven project.
- Java matrix: the platform table can produce a wider matrix than you test locally (for example 8, 11, 17 and 21
for platform 2.8). Pass
java_versionsto narrow it. - SNAPSHOT deploys: off unless you set
deploy_snapshots, e.g.deploy_snapshots: ${{ github.repository_owner == 'my-org' }}. Deploys to repositories OpenMRS owns fail; see Build Maven project for the exact rules. A fork that inherits the OpenMRS parent POM’s repositories is the usual cause, so set<distributionManagement>ormaven_snapshot_repository_url. - Secret names: map differently named secrets in the caller, for example
MAVEN_REPO_USERNAME: ${{ secrets.MY_MAVEN_USER }}.secrets: inheritdoes not rename them.
Permissions
The build and deploy jobs request contents: read only.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
java_versions | string | Java versions to build against (e.g. [8, 11, 17]). If omitted, inferred from the OpenMRS platform dependency in pom.xml. | |
main_java_version | string | Java version for publishing artifacts (must be in java_versions). If omitted, inferred from Maven compiler settings, or defaults to the minimum of java_versions. | |
java_distribution | string | temurin | Java distribution |
maven_args | string | clean install | Maven Arguments |
upload_coverage | string | Stage JaCoCo reports as a coverage-reports artifact for the upload-coverage workflow to send to Codecov. Set "false" to skip; otherwise staged when JaCoCo reports are found. | |
deploy_snapshots | boolean | ${{ github.repository_owner == 'openmrs' }} | Whether to deploy SNAPSHOT artifacts to the Maven repository. Defaults to true in the openmrs org and false elsewhere, so forks that inherit a caller workflow do not deploy; outside the openmrs org, set it from an expression such as github.repository_owner == 'my-org'. When true, a deploy without MAVEN_REPO_USERNAME and MAVEN_REPO_API_KEY fails, as does a deploy to a repository only the openmrs org may use. |
deploy_branch | string | Branch name or JSON array of branch names that trigger SNAPSHOT deployment. If omitted, deploys from main, master, the default branch, and version branches (e.g. 3.x, 2.8.x). | |
maven_server_id | string | Maven server ID to use for SNAPSHOT deployment. If omitted, inferred from <distributionManagement><snapshotRepository><id> in pom.xml. | |
maven_snapshot_repository_url | string | Repository URL to deploy SNAPSHOTs to instead of <distributionManagement><snapshotRepository>. |
Secrets
| Name | Description |
|---|---|
MAVEN_REPO_USERNAME | Maven repository username |
MAVEN_REPO_API_KEY | Maven repository API key / password |