@@ -152,13 +152,13 @@ quickstart_configs.each { taskName, config ->
152
152
153
153
// Register all quickstart tasks
154
154
quickstart_configs. each { taskName, config ->
155
- tasks. register(" ${ taskName} BuildImages " )
155
+ tasks. register(" ${ taskName} PrepareAll " )
156
156
}
157
157
158
158
quickstart_configs. each { taskName, config ->
159
159
if (config. modules) {
160
- tasks. getByName(" ${ taskName} BuildImages " ). dependsOn(
161
- config. modules. collect { it + " : ${ config.isDebug ? 'dockerTagDebug' : 'dockerTag' } " }
160
+ tasks. getByName(" ${ taskName} PrepareAll " ). dependsOn(
161
+ config. modules. collect { it + ' :dockerPrepare ' }
162
162
)
163
163
}
164
164
}
@@ -187,13 +187,38 @@ tasks.withType(ComposeUp).configureEach {
187
187
}
188
188
189
189
task debugReload (type : Exec ) {
190
- // TODO: Make these a set of tasks that depend on its dependency, making it a no-op if its dependency is up-to-date
191
- def cmd = [ ' docker compose -p datahub --profile debug ' ] + [ ' -f ' , compose_base] + [
192
- ' restart ' ,
193
- ' datahub-gms-debug' ,
194
- ' system-update-debug' ,
195
- ' frontend-debug'
190
+ // TODO: Generate *reloadTasks for all quickStart configs. Need to move the moduleToContainer to ext and define mappings for all containers.
191
+ // Map of module paths to their corresponding container names
192
+ def moduleToContainer = [
193
+ ' :metadata-service:war ' : ' datahub-gms-debug' ,
194
+ ' :datahub-upgrade ' : ' system-update-debug' ,
195
+ ' :datahub-frontend ' : ' frontend-debug'
196
196
]
197
- commandLine ' bash' , ' -c' , cmd. join(" " )
198
- dependsOn project. tasks. named(" quickstartDebugBuildImages" )
197
+
198
+ doFirst {
199
+ // Get all tasks that were executed as part of this build
200
+ def executedTasks = project. gradle. taskGraph. allTasks. findAll { it. state. executed }
201
+
202
+ // Find which modules actually had work done
203
+ def containersToRestart = []
204
+ moduleToContainer. each { modulePath , containerName ->
205
+ def moduleProject = project. project(modulePath)
206
+ def dockerPrepareTask = moduleProject. tasks. findByName(' dockerPrepare' )
207
+
208
+ if (dockerPrepareTask && executedTasks. contains(dockerPrepareTask) && ! dockerPrepareTask. state. upToDate) {
209
+ containersToRestart << containerName
210
+ }
211
+ }
212
+
213
+ // Only restart containers that had their modules rebuilt
214
+ if (containersToRestart) {
215
+ def cmd = [' docker compose -p datahub --profile debug' ] + [' -f' , compose_base] + [' restart' ] + containersToRestart
216
+ commandLine ' bash' , ' -c' , cmd. join(" " )
217
+ } else {
218
+ // If no containers need restart, make this a no-op
219
+ commandLine ' bash' , ' -c' , ' echo "No containers need restarting - all modules are up to date"'
220
+ }
221
+ }
222
+
223
+ dependsOn tasks. named(" quickstartDebugPrepareAll" )
199
224
}
0 commit comments