Migrate build infrastructure from Gradle to Maven #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Maven Build | |
| on: | |
| push: | |
| branches: [main, support/5.x.x] | |
| pull_request: | |
| branches: [main, support/5.x.x] | |
| workflow_dispatch: | |
| jobs: | |
| build-java-latest: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Move generated sources to correct package | |
| run: .\scripts\copyFilesOnBuild.ps1 -inputPath '.\src\main\java\com\microsoft\graph\generated' | |
| shell: pwsh | |
| - name: Build with Maven | |
| run: ./mvnw verify --no-transfer-progress | |
| - name: Upload Unit Test Results | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: UnitTests | |
| path: | | |
| target/surefire-reports/** | |
| - name: Upload a Build Artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: drop | |
| path: | | |
| target/*.jar | |
| pom.xml | |
| mvnw | |
| mvnw.cmd | |
| .mvn/** | |
| scripts/** | |
| build-java-8: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: 8 | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Move generated sources to correct package | |
| run: .\scripts\copyFilesOnBuild.ps1 -inputPath '.\src\main\java\com\microsoft\graph\generated' | |
| shell: pwsh | |
| - name: Build with Java 8 | |
| run: ./mvnw compile --no-transfer-progress | |
| build: | |
| needs: [build-java-latest, build-java-8] | |
| runs-on: ubuntu-latest | |
| if: ${{ always() }} | |
| steps: | |
| - name: Determine build status | |
| run: | | |
| if [ "${{ needs.build-java-latest.result }}" == "success" ] && [ "${{ needs.build-java-8.result }}" == "success" ]; then | |
| exit 0 | |
| else | |
| exit 1 | |
| fi | |