mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
Update maven-build.yml
This commit is contained in:
parent
cabb74ed53
commit
071c5d3d56
1 changed files with 29 additions and 19 deletions
48
.github/workflows/maven-build.yml
vendored
48
.github/workflows/maven-build.yml
vendored
|
@ -1,29 +1,39 @@
|
||||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
name: Maven Cache Testing Pipeline
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
|
||||||
|
|
||||||
name: Java CI with Maven
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
pull_request:
|
- main # Runs pipeline on push to main branch
|
||||||
branches: [ main ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
java: [ '17' ]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
# Step 1: Checkout the code from the repository
|
||||||
- name: Set up JDK ${{matrix.java}}
|
- name: Checkout code
|
||||||
uses: actions/setup-java@v4
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Step 2: Set up JDK 17
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
java-version: ${{matrix.java}}
|
java-version: '17'
|
||||||
distribution: 'adopt'
|
distribution: 'temurin'
|
||||||
cache: maven
|
|
||||||
- name: Build with Maven Wrapper
|
# Step 3: Cache Maven dependencies to speed up future builds
|
||||||
run: ./mvnw -B package
|
- name: Cache Maven dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.m2/repository # Cache Maven's local repository
|
||||||
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} # Cache key based on OS and pom.xml
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven- # Restore from the closest matching cache if an exact match is unavailable
|
||||||
|
|
||||||
|
# Step 4: Build the Maven project
|
||||||
|
- name: Build the application
|
||||||
|
run: ./mvnw clean package
|
||||||
|
|
||||||
|
# Step 5: Display the Maven version and build summary (Optional)
|
||||||
|
- name: Display Maven version
|
||||||
|
run: ./mvnw --version
|
||||||
|
|
Loading…
Reference in a new issue