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