diff --git a/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy b/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy index 546f379..dc28fff 100644 --- a/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy +++ b/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy @@ -10,34 +10,42 @@ public class DockerTestPlugin implements Plugin { def testDockerContainers = project.container(DockerContainer) project.extensions.testDockerContainers = testDockerContainers - project.task("showDockerContainers") << { - project.extensions.testDockerContainers.forEach { println it } + project.task("showDockerContainers") { + doLast { + project.extensions.testDockerContainers.forEach { println it } + } } - project.task("startTestDocker", description: "Start up dependent docker containers for testing") << { - project.extensions.testDockerContainers.forEach { - def result = DockerUtils.runCommand it.runCommand() - if (result[0] != 0) throw new IllegalStateException(result[1].toString()) - if (it.waitAfterRun > 0) { - sleep(it.waitAfterRun * 1_000) + project.task("startTestDocker", description: "Start up dependent docker containers for testing") { + doLast { + project.extensions.testDockerContainers.forEach { + def result = DockerUtils.runCommand it.runCommand() + if (result[0] != 0) throw new IllegalStateException(result[1].toString()) + if (it.waitAfterRun > 0) { + sleep(it.waitAfterRun * 1_000) + } } } } def startTestDocker = project.tasks.getByName("startTestDocker") - project.task("stopTestDocker", description: "Stop docker containers used in tests") << { - project.extensions.testDockerContainers.forEach { - def result = DockerUtils.stopContainer it.getContainerName() - if (result[0] != 0) throw new IllegalStateException(result[1].toString()) - result = DockerUtils.removeContainer it.getContainerName() - if (result[0] != 0) throw new IllegalStateException(result[1].toString()) + project.task("stopTestDocker", description: "Stop docker containers used in tests") { + doLast { + project.extensions.testDockerContainers.forEach { + def result = DockerUtils.stopContainer it.getContainerName() + if (result[0] != 0) throw new IllegalStateException(result[1].toString()) + result = DockerUtils.removeContainer it.getContainerName() + if (result[0] != 0) throw new IllegalStateException(result[1].toString()) + } } } def stopTestDocker = project.tasks.getByName("stopTestDocker") - project.task("dockerTest", type: Test, description: "Run docker integration tests") << { - useJUnit { - includeCategories 'io.advantageous.test.DockerTest' + project.task("dockerTest", type: Test, description: "Run docker integration tests") { + doLast { + useJUnit { + includeCategories 'io.advantageous.test.DockerTest' + } } } def dockerTest = project.tasks.getByName("dockerTest")