Skip to content

Commit a74d3ef

Browse files
committed
[optimise] Use Maven Daemon in CI jobs that have multiple mvn invoking steps
1 parent 46288bf commit a74d3ef

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'install-mvnd'
2+
description: 'Install the maven daemon'
3+
inputs:
4+
version:
5+
description: 'The version of the maven daemon to install'
6+
required: true
7+
default: '0.9.0'
8+
outputs:
9+
mvnd-dir:
10+
description: "The directory where the command mvnd is located"
11+
value: ${{ steps.mvnd-location.outputs.mvnd-dir }}
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Download mvnd (Linux)
16+
if: runner.os == 'Linux'
17+
shell: bash
18+
run: |
19+
curl -fsSL -o mvnd.zip https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/maven-mvnd-${{ inputs.version }}-linux-amd64.zip
20+
curl -fsSL -o mvnd.zip.sha256 https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/maven-mvnd-${{ inputs.version }}-linux-amd64.zip.sha256
21+
- name: Download mvnd (macOS)
22+
if: runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
curl -fsSL -o mvnd.zip https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/maven-mvnd-${{ inputs.version }}-darwin-amd64.zip
26+
curl -fsSL -o mvnd.zip.sha256 https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/maven-mvnd-${{ inputs.version }}-darwin-amd64.zip.sha256
27+
- name: Download mvnd (Windows)
28+
if: runner.os == 'Windows'
29+
shell: bash
30+
run: |
31+
curl -fsSL -o mvnd.zip https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/maven-mvnd-${{ inputs.version }}-windows-amd64.zip
32+
curl -fsSL -o mvnd.zip.sha256 https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/maven-mvnd-${{ inputs.version }}-windows-amd64.zip.sha256
33+
- name: Install sha256sum (macOS)
34+
if: runner.os == 'macOS'
35+
shell: bash
36+
run: brew install coreutils
37+
- name: Verify sha256sum
38+
shell: bash
39+
run: echo "$(cat mvnd.zip.sha256) mvnd.zip" | sha256sum --check
40+
- name: Unzip mvnd
41+
shell: bash
42+
run: unzip mvnd.zip -d /tmp/
43+
- id: mvnd-location
44+
shell: bash
45+
run: |
46+
MVND_BIN_DIR="$(find /tmp/ -maxdepth 1 -name 'maven-mvnd-${{ inputs.version }}-*-amd64' -type d)/bin"
47+
if [ "$RUNNER_OS" == "Windows" ]; then
48+
MVND_BIN_DIR="$(cygpath --absolute --long-name --windows $MVND_BIN_DIR)"
49+
fi
50+
echo "mvnd-dir=${MVND_BIN_DIR}" >> $GITHUB_OUTPUT

.github/workflows/ci-test.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ jobs:
4545
distribution: temurin
4646
java-version: ${{ env.DEV_JDK }}
4747
cache: 'maven'
48+
- name: Install Maven Daemon
49+
id: install-mvnd
50+
uses: ./.github/actions/install-mvnd
4851
- name: Maven Build
4952
timeout-minutes: 10
50-
run: mvn -V -B -T 1C compile test-compile -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
53+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B -T 1C compile test-compile -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
5154
- name: Maven Test
5255
timeout-minutes: 60
53-
run: mvn -V -B verify -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
56+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B verify -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
5457
- name: Javadoc (Linux only)
5558
if: ${{ matrix.os == 'ubuntu-latest' }}
56-
run: mvn -V -B -q -T 1C install javadoc:javadoc -DskipTests -D'dependency-check.skip' -D'license.skip' --projects '!exist-distribution,!exist-installer' --also-make
59+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B -q -T 1C install javadoc:javadoc -DskipTests -D'dependency-check.skip' -D'license.skip' --projects '!exist-distribution,!exist-installer' --also-make
5760
- name: Maven Code Coverage (Develop branch on Linux only)
5861
if: ${{ github.ref == 'refs/heads/develop' && matrix.os == 'ubuntu-latest' }}
5962
env:
@@ -62,7 +65,7 @@ jobs:
6265
CI_BUILD_NUMBER: ${{ github.run_id }}
6366
CI_BUILD_URL: https://github.com/${{ github.repository }}/commit/${{ github.event.after }}/checks
6467
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
65-
run: mvn -V -B jacoco:report coveralls:report
68+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B jacoco:report coveralls:report
6669
- name: Archive build logs
6770
if: always()
6871
uses: actions/upload-artifact@v3

0 commit comments

Comments
 (0)