@@ -80,11 +80,25 @@ ext {
80
80
preserveVolumes : true
81
81
]
82
82
]
83
+
84
+ // only for debug variants of quickstart to enable <variant>Reload tasks.
85
+ // The actual service name needs the profile to be appended, <container-name>-<profile>
86
+ moduleToContainer = [
87
+ ' :metadata-service:war' : ' datahub-gms' ,
88
+ ' :datahub-frontend' : ' frontend' ,
89
+ ' :datahub-upgrade' : ' system-update' ,
90
+ ' :metadata-jobs:mce-consumer-job' : ' datahub-mce-consumer' ,
91
+ ' :metadata-jobs:mae-consumer-job' : ' datahub-mae-consumer' ,
92
+
93
+ ]
83
94
}
84
95
85
96
// Register all quickstart tasks
86
97
quickstart_configs. each { taskName, config ->
87
- tasks. register(taskName)
98
+ tasks. register(taskName) {
99
+ group = ' quickstart'
100
+ }
101
+
88
102
}
89
103
90
104
// Dynamically create all quickstart tasks and configurations
@@ -169,6 +183,7 @@ tasks.register('minDockerCompose2.20', Exec) {
169
183
}
170
184
171
185
tasks. register(' quickstartNuke' ) {
186
+ group = ' quickstart'
172
187
doFirst {
173
188
quickstart_configs. each { taskName , config ->
174
189
dockerCompose. " ${ taskName} " . removeVolumes = ! config. preserveVolumes
@@ -178,6 +193,7 @@ tasks.register('quickstartNuke') {
178
193
}
179
194
180
195
tasks. register(' quickstartDown' ) {
196
+ group = ' quickstart'
181
197
finalizedBy(tasks. withType(ComposeDownForced ))
182
198
}
183
199
@@ -186,39 +202,36 @@ tasks.withType(ComposeUp).configureEach {
186
202
dependsOn tasks. named(" minDockerCompose2.20" )
187
203
}
188
204
189
- task debugReload (type : Exec ) {
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
- ]
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
205
+ // Register all quickstart Reload tasks. For quickstartDebug, the reload task is DebugReload. (Taskname without quickstart prefix)
206
+ quickstart_configs. each { taskName, config ->
207
+ if (config. isDebug) {
208
+ def reloadTaskName = taskName. replaceFirst(/ ^quickstart/ , " " )
209
+ tasks. register(" ${ reloadTaskName} Reload" , Exec ) {
210
+ dependsOn tasks. named(" ${ taskName} PrepareAll" )
211
+ group = ' quickstart'
212
+ description = " Build and reload only changed containers for the ${ taskName} task"
213
+ doFirst {
214
+ def executedTasks = project. gradle. taskGraph. allTasks. findAll { it. state. executed }
215
+ def containersToRestart = []
216
+
217
+ moduleToContainer. each { modulePath , containerName ->
218
+ def moduleProject = project. project(modulePath)
219
+ def dockerPrepareTask = moduleProject. tasks. findByName(' dockerPrepare' )
220
+
221
+ if (dockerPrepareTask && executedTasks. contains(dockerPrepareTask) && ! dockerPrepareTask. state. upToDate) {
222
+ containersToRestart << " ${ containerName} -${ config.profile} "
223
+ }
224
+ }
225
+
226
+ // Only restart containers that had their modules rebuilt
227
+ if (containersToRestart) {
228
+ def cmd = [" docker compose -p datahub --profile ${ config.profile} " ] + [' -f' , compose_base] + [' restart' ] + containersToRestart
229
+ commandLine ' bash' , ' -c' , cmd. join(" " )
230
+ } else {
231
+ // If no containers need restart, make this a no-op
232
+ commandLine ' bash' , ' -c' , ' echo "No containers need restarting - all modules are up to date"'
233
+ }
210
234
}
211
235
}
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
236
}
222
-
223
- dependsOn tasks. named(" quickstartDebugPrepareAll" )
224
- }
237
+ }
0 commit comments