Skip to content

Commit cf3a3fc

Browse files
authored
Fix stage task detection to work regardless of description presence (#177)
1 parent e478030 commit cf3a3fc

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-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+
- Fix `stage` task detection to work regardless of whether task has a description. ([#177](https://github.com/heroku/heroku-buildpack-gradle/pull/177))
912

1013
## [v47] - 2025-09-16
1114

bin/compile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ echo "${detected_app_framework}" >"${BUILD_DIR}/.heroku/gradle_buildpack_detecte
199199
# Determine the Gradle task to execute
200200
if [ -z "${GRADLE_TASK:-}" ]; then
201201
# If a stage task is available, use it instead of trying to guess the task to run
202-
if (cd "${BUILD_DIR}" && ./gradlew tasks --all 2>/dev/null | grep -q "^stage "); then
202+
if (cd "${BUILD_DIR}" && ./gradlew tasks --all 2>/dev/null | grep -qE "^stage($| )"); then
203203
GRADLE_TASK="stage"
204204
else
205205
case "${detected_app_framework}" in

test/spec/misc_spec.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,41 @@
196196
)
197197
end
198198
end
199+
200+
it 'uses stage task (with description) when available' do
201+
app = Hatchet::Runner.new('spring-3-gradle-8-groovy')
202+
app.before_deploy do
203+
stage_task = <<~GROOVY
204+
task stage {
205+
description = 'Custom stage task for deployment'
206+
dependsOn build
207+
}
208+
GROOVY
209+
210+
File.write('build.gradle', "#{File.read('build.gradle')}\n#{stage_task}")
211+
end
212+
213+
app.deploy do
214+
expect(app).to be_deployed
215+
expect(clean_output(app.output)).to include('$ ./gradlew stage')
216+
end
217+
end
218+
219+
it 'uses stage task (without description) when available' do
220+
app = Hatchet::Runner.new('spring-3-gradle-8-groovy')
221+
app.before_deploy do
222+
stage_task = <<~GROOVY
223+
task stage {
224+
dependsOn build
225+
}
226+
GROOVY
227+
228+
File.write('build.gradle', "#{File.read('build.gradle')}\n#{stage_task}")
229+
end
230+
231+
app.deploy do
232+
expect(app).to be_deployed
233+
expect(clean_output(app.output)).to include('$ ./gradlew stage')
234+
end
235+
end
199236
end

0 commit comments

Comments
 (0)