@@ -215,24 +215,47 @@ jobs:
215215 - name : Verify Maven installation
216216 run : ./mvnw --version
217217
218+ - name : Set build configuration
219+ run : |
220+ # Determine if docs profile should be included based on JDK configuration
221+ # Logic: Include docs if (has-jdk8=true AND java-version=8) OR (has-jdk8=false AND java-version=17)
222+ BUILD_WITH_DOCS=false
223+
224+ if [[ ("${{ matrix.has-jdk8 }}" == "true" && "${{ matrix.java-version }}" == "8") ]] || [[ ("${{ matrix.has-jdk8 }}" == "false" && "${{ matrix.java-version }}" == "17") ]]; then
225+ BUILD_WITH_DOCS=true
226+ echo "Docs profile will be included in this build"
227+ else
228+ echo "Docs profile will NOT be included in this build"
229+ fi
230+
231+ echo "BUILD_WITH_DOCS=$BUILD_WITH_DOCS" >> $GITHUB_ENV
232+ echo "Build configuration: BUILD_WITH_DOCS=$BUILD_WITH_DOCS"
233+
218234 - name : Build and deploy
219235 run : |
236+ # Write build command to temporary script file
220237 if [[ -n "${{ inputs.custom_build_command }}" ]]; then
221- # Write custom command to a script file to support multi-line commands
222- cat > /tmp/custom- build.sh << CUSTOM_BUILD_EOF
238+ # Custom build command provided by caller
239+ cat > /tmp/build-deploy .sh << ' CUSTOM_BUILD_EOF'
223240 ${{ inputs.custom_build_command }}
224241 CUSTOM_BUILD_EOF
225- chmod +x /tmp/custom-build.sh
226- bash /tmp/custom-build.sh
227242 else
228- # If branch config contains JDK 8, use docs profile with JDK 8
229- # Otherwise, use docs profile with JDK 17
230- if [[ ("${{ matrix.has-jdk8 }}" == "true" && "${{ matrix.java-version }}" == "8") ]] || [[ ("${{ matrix.has-jdk8 }}" == "false" && "${{ matrix.java-version }}" == "17") ]]; then
231- echo "Building with docs profile, and deploying docs"
232- ./mvnw clean deploy -Pdocs,deploy,spring -B -U
233- else
234- echo "Will not add docs profile, docs will not be deployed"
235- ./mvnw clean deploy -Pdeploy,spring -B -U
236- fi
243+ # Default Maven build command with conditional docs profile
244+ cat > /tmp/build-deploy.sh << 'DEFAULT_BUILD_EOF'
245+ #!/bin/bash
246+ set -e
247+
248+ # BUILD_WITH_DOCS is set by the "Set build configuration" step
249+ if [[ "$BUILD_WITH_DOCS" == "true" ]]; then
250+ echo "Building with docs profile, and deploying docs"
251+ ./mvnw clean deploy -Pdocs,deploy,spring -B -U
252+ else
253+ echo "Will not add docs profile, docs will not be deployed"
254+ ./mvnw clean deploy -Pdeploy,spring -B -U
255+ fi
256+ DEFAULT_BUILD_EOF
237257 fi
238258
259+ chmod +x /tmp/build-deploy.sh
260+ bash /tmp/build-deploy.sh
261+
0 commit comments