Repository navigation
109 lines (109 loc) · 3.63 KB
/
Copy pathjava-build-template.yml
File metadata and controls
109 lines (109 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# SPDX-FileCopyrightText: Copyright (C) 2025 Fabrício Barros Cabral
# SPDX-License-Identifier: MIT
---
# yamllint disable rule:line-length
name: java-build-template
'on':
workflow_call:
inputs:
working-directory:
description: "Set the working directory"
required: false
default: "."
type: string
defaults:
run:
shell: bash -xeuo pipefail {0}
permissions:
contents: read
jobs:
java-linux-build-template:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
java: [17, 21]
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Java SDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Configure Maven cache
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-
- name: Build Maven project
working-directory: ${{ inputs.working-directory }}
run: |
[[ -x "mvnw" ]] && mvn="./mvnw" || mvn="mvn"
args=(--errors --batch-mode install)
profile=$(grep -q "<id>qulice</id>" pom.xml && echo "-Pqulice")
[[ -n "${profile}" ]] && args+=("${profile}")
${mvn} "${args[@]}"
java-macos-build-template:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-14, macos-15]
java: [17, 21]
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Java SDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Configure Maven cache
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ github.job }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ github.job }}-
- name: Build Maven project
working-directory: ${{ inputs.working-directory }}
run: |
[[ -x "mvnw" ]] && mvn="./mvnw" || mvn="mvn"
args=(--errors --batch-mode install)
profile=$(grep -q "<id>qulice</id>" pom.xml && echo "-Pqulice")
[[ -n "${profile}" ]] && args+=("${profile}")
${mvn} "${args[@]}"
java-windows-build-template:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, windows-2025]
java: [17, 21]
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Java SDK
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Configure Maven cache
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ github.job }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ github.job }}-
- name: Build Maven project
shell: cmd
working-directory: ${{ inputs.working-directory }}
run: |
@echo off
for /f "delims=" %%i in ('findstr "<id>qulice</id>" pom.xml') do set "Q=1"
if exist "mvnw.cmd" (set "M=mvnw.cmd") else (set "M=mvn")
%M% --errors --batch-mode install %Q:~-2,-1%-Pqulice