Skip to content

Commit 3ec1a08

Browse files
authored
Guard against missing gradlew during daemon cleanup (#172)
1 parent 1e6d8e0 commit 3ec1a08

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Guard against missing gradlew during daemon cleanup to prevent "No such file or directory" errors. ([#172](https://github.com/heroku/heroku-buildpack-gradle/pull/172))
912

1013
## [v45] - 2025-09-12
1114

bin/compile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,22 @@ if ! (cd "${BUILD_DIR}" && ./gradlew ${GRADLE_TASK}) 2>&1 | tee "${gradle_output
295295
fi
296296

297297
output::step "Stopping Gradle daemon"
298-
(cd "${BUILD_DIR}" && ./gradlew -q --stop) | output::indent
298+
if [[ -f "${BUILD_DIR}/gradlew" ]]; then
299+
(cd "${BUILD_DIR}" && ./gradlew -q --stop) | output::indent
300+
else
301+
output::warning <<-EOF
302+
Warning: Gradle wrapper (gradlew) not found during daemon cleanup.
303+
304+
The gradlew script was present at the beginning of the build but was removed
305+
during the build process. This is unexpected behavior.
306+
307+
While this did not fail your current build, we strongly recommend fixing the
308+
issue to prevent unexpected behavior in future builds. Check your Gradle tasks or
309+
build scripts to see if they're removing the Gradle wrapper from your project directory.
310+
EOF
311+
312+
metrics::set_raw "gradle_daemon_cleanup_gradlew_missing" "true"
313+
fi
299314

300315
# https://github.com/heroku/heroku-buildpack-gradle/issues/49
301316
rm -rf "${CACHE_DIR}/.gradle/nodejs"

0 commit comments

Comments
 (0)