diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4a3f72a785..e999d22533 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,7 +22,6 @@ permissions: jobs: build: - runs-on: ${{ matrix.os }} strategy: matrix: @@ -43,10 +42,45 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - - name: Set up JDK ${{ matrix.java }} + - name: Select JDK toolchain version + run: | + case '${{ matrix.java }}' in + 8) + echo 'HC_BUILD_TOOLCHAIN_VERSION=1.8' >> "$GITHUB_ENV" + ;; + *) + echo 'HC_BUILD_TOOLCHAIN_VERSION=${{ matrix.java }}' >> "$GITHUB_ENV" + ;; + esac + - name: Set up toolchain JDK ${{ matrix.java }} + id: setup-java-toolchain uses: actions/setup-java@v5 with: distribution: 'temurin' java-version: ${{ matrix.java }} + - name: Set up JDK 17 for Maven + uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '17' + - name: Configure Maven toolchains + env: + TOOLCHAIN_JAVA_HOME: ${{ steps.setup-java-toolchain.outputs.path }} + run: | + mkdir -p "${HOME}/.m2" + cat > "${HOME}/.m2/toolchains.xml" < + + + jdk + + ${HC_BUILD_TOOLCHAIN_VERSION} + + + ${TOOLCHAIN_JAVA_HOME} + + + + EOF - name: Build with Maven - run: ./mvnw -V --file pom.xml --no-transfer-progress -DtrimStackTrace=false -Djunit.jupiter.execution.parallel.enabled=false -P-use-toolchains,docker + run: ./mvnw -V --file pom.xml --no-transfer-progress -DtrimStackTrace=false -Djunit.jupiter.execution.parallel.enabled=false -Dhc.build.toolchain.version="${HC_BUILD_TOOLCHAIN_VERSION}" -Pdocker diff --git a/pom.xml b/pom.xml index 7d5bff61e7..f7f71957db 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,8 @@ 1.8 1.8 + + ${maven.compiler.source} 5.5-alpha1 2.25.3 1.20.0 @@ -340,6 +342,27 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 3.5.0 + + + enforce-java-runtime + + enforce + + + + + [17,) + Apache HttpComponents Client requires Java 17 or newer to run Maven. Use toolchains to compile and test with older JDKs. + + + + + + com.github.siom79.japicmp japicmp-maven-plugin @@ -432,6 +455,37 @@ + + use-toolchains + + + ${user.home}/.m2/toolchains.xml + + + + + + org.apache.maven.plugins + maven-toolchains-plugin + 3.2.0 + + + + ${hc.build.toolchain.version} + + + + + + + toolchain + + + + + + +