Skip to content

Commit b91400b

Browse files
committed
Fix Maven 4 CI setup with separate JDK install
The s4u/setup-maven-action@v1.19.0 does not provide reliable outputs for java-home and maven-home, causing the build-m4 job to fail. Changes: - Split combined setup into separate steps: - Use actions/setup-java@v5 for JDK 17 (id: setup-jdk17) - Use stCarolas/setup-maven@v5 for Maven 4 - Add dynamic Maven home detection: - Find mvn in PATH using command -v - Resolve symlinks with readlink/realpath - Calculate M4_HOME from mvn binary location - Maintain JDK 17 as default JAVA_HOME for Maven 4 builds - Keep JDK 11 available for compatibility (JAVA11_HOME) This aligns the build-m4 job setup with the proven approach used in build-legacy, ensuring reliable cross-platform builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Introduced in the course of support-and-care/maven-support-and-care#137
1 parent 367ffb8 commit b91400b

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,38 @@ jobs:
206206
distribution: 'temurin'
207207
java-version: '11.0.28'
208208

209-
- name: Set up Maven 4 with JDK 17
210-
id: setup-maven4
211-
uses: s4u/setup-maven-action@v1.19.0
209+
- name: Set up JDK 17
210+
id: setup-jdk17
211+
uses: actions/setup-java@v5
212212
with:
213+
distribution: 'temurin'
213214
java-version: '17'
214-
java-distribution: 'temurin'
215+
216+
- name: Set up Maven 4
217+
uses: stCarolas/setup-maven@v5
218+
with:
215219
maven-version: '4.0.0-rc-4'
216220

217221
- name: Create .envrc with Java and Maven paths
218222
shell: bash
219223
env:
220224
JAVA11_PATH: ${{ steps.setup-jdk11.outputs.path }}
221-
JAVA17_PATH: ${{ steps.setup-maven4.outputs.java-home }}
222-
MAVEN4_PATH: ${{ steps.setup-maven4.outputs.maven-home }}
225+
JAVA17_PATH: ${{ steps.setup-jdk17.outputs.path }}
223226
run: |
227+
# Detect Maven home
228+
if command -v mvn > /dev/null; then
229+
MVN_PATH="$(command -v mvn)"
230+
# Resolve symlinks
231+
if [[ "$RUNNER_OS" == "Linux" ]] || [[ "$RUNNER_OS" == "macOS" ]]; then
232+
MVN_PATH="$(readlink -f "$MVN_PATH" 2>/dev/null || realpath "$MVN_PATH" 2>/dev/null || echo "$MVN_PATH")"
233+
fi
234+
# Maven home is two directories up from the mvn binary
235+
MAVEN4_PATH="$(dirname "$(dirname "$MVN_PATH")")"
236+
else
237+
echo "ERROR: Maven not found in PATH"
238+
exit 1
239+
fi
240+
224241
# Convert Windows paths to Unix paths if on Windows
225242
if [[ "$RUNNER_OS" == "Windows" ]]; then
226243
JAVA11_PATH="$(cygpath -u "$JAVA11_PATH")"

0 commit comments

Comments
 (0)