80
80
preserveVolumes : true
81
81
]
82
82
]
83
+
84
+ moduleToContainer = [
85
+ ' :metadata-service:war' : ' datahub-gms-debug' ,
86
+ ' :datahub-upgrade' : ' system-update-debug' ,
87
+ ' :datahub-frontend' : ' frontend-debug' ,
88
+ ' :metadata-jobs:mce-consumer-job' : ' datahub-mce-consumer-job-debug' ,
89
+ ' :metadata-jobs:mae-consumer-job' : ' datahub-mae-consumer-job-debug' ,
90
+ ' :docker:datahub-ingestion' : ' datahub-ingestion-debug' ,
91
+ ' :docker:mysql-setup' : ' datahub-mysql-setup-debug' ,
92
+ ' :docker:kafka-setup' : ' datahub-kafka-setup-debug' ,
93
+ ' :docker:elasticsearch-setup' : ' datahub-elasticsearch-setup-debug' ,
94
+ ' :docker:postgres-setup' : ' datahub-postgres-setup-debug' ,
95
+ ' :docker:kafka-setup' : ' datahub-kafka-setup-debug' ,
96
+ ' :docker:elasticsearch-setup' : ' datahub-elasticsearch-setup-debug' ,
97
+ ' :docker:postgres-setup' : ' datahub-postgres-setup-debug' ,
98
+ ]
83
99
}
84
100
85
101
// Register all quickstart tasks
@@ -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 = ' quickstartart'
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
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