From e893565a91ffdced97b31967a37050ef20d762d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20August=C3=BDn?= Date: Mon, 2 May 2022 11:15:51 +0200 Subject: [PATCH] fix: task registering fixed --- .../dockercompose/TasksConfigurator.groovy | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/groovy/com/avast/gradle/dockercompose/TasksConfigurator.groovy b/src/main/groovy/com/avast/gradle/dockercompose/TasksConfigurator.groovy index e879aac..da5b6a2 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/TasksConfigurator.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/TasksConfigurator.groovy @@ -28,6 +28,18 @@ class TasksConfigurator { this.project = project Provider composeExecutor = ComposeExecutor.getInstance(project, composeSettings) Provider serviceInfoCache = ServiceInfoCache.getInstance(project, composeSettings.nestedName) + this.downTask = project.tasks.register(name ? "${name}ComposeDown".toString() : 'composeDown', ComposeDown) {task -> + configureDownForcedTask(task, composeExecutor, serviceInfoCache) + task.stopContainers.set(composeSettings.stopContainers) + } + this.downForcedTask = project.tasks.register(name ? "${name}ComposeDownForced".toString() : 'composeDownForced', ComposeDownForced) {task -> + configureDownForcedTask(task, composeExecutor, serviceInfoCache) + } + def downForcedOnFailureTask = project.tasks.register(name ? "${name}ComposeDownForcedOnFailure".toString() : 'composeDownForcedOnFailure', ComposeDownForced) {task -> + configureDownForcedTask(task, composeExecutor, serviceInfoCache) + task.onlyIf { task.serviceInfoCache.get().startupFailed } + } + this.downForcedOnFailureTask = downForcedOnFailureTask this.upTask = project.tasks.register(name ? "${name}ComposeUp".toString() : 'composeUp', ComposeUp) {task -> task.stopContainers.set(composeSettings.stopContainers) task.forceRecreate.set(composeSettings.forceRecreate) @@ -70,17 +82,6 @@ class TasksConfigurator { buildBeforePull ? [buildTask] : [] }) } - this.downTask = project.tasks.register(name ? "${name}ComposeDown".toString() : 'composeDown', ComposeDown) {task -> - configureDownForcedTask(task, composeExecutor, serviceInfoCache) - task.stopContainers.set(composeSettings.stopContainers) - } - this.downForcedTask = project.tasks.register(name ? "${name}ComposeDownForced".toString() : 'composeDownForced', ComposeDownForced) {task -> - configureDownForcedTask(task, composeExecutor, serviceInfoCache) - } - this.downForcedOnFailureTask = project.tasks.register(name ? "${name}ComposeDownForcedOnFailure".toString() : 'composeDownForcedOnFailure', ComposeDownForced) {task -> - configureDownForcedTask(task, composeExecutor, serviceInfoCache) - task.onlyIf { task.serviceInfoCache.get().startupFailed } - } this.logsTask = project.tasks.register(name ? "${name}ComposeLogs".toString() : 'composeLogs', ComposeLogs) {task -> task.containerLogToDir.set(composeSettings.containerLogToDir) task.composeExecutor.set(composeExecutor)