From 68ab74248b711345bb382900c4ee0e4840bcf270 Mon Sep 17 00:00:00 2001 From: Bill McMath Date: Tue, 21 May 2019 11:25:20 +0100 Subject: [PATCH 1/2] Replacing leftShift method with doLast for Gradle 5 compatibility --- .../gradle/docker/DockerTestPlugin.groovy | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy b/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy index 546f379..be245cf 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") { + project.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") { + project.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") { + project.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") { + project.doLast { + useJUnit { + includeCategories 'io.advantageous.test.DockerTest' + } } } def dockerTest = project.tasks.getByName("dockerTest") From bc3bb0b3226d11e44802669070be451b980a7345 Mon Sep 17 00:00:00 2001 From: Bill McMath Date: Tue, 21 May 2019 12:02:36 +0100 Subject: [PATCH 2/2] Corrected location of call to doLast method --- .../io/advantageous/gradle/docker/DockerTestPlugin.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy b/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy index be245cf..dc28fff 100644 --- a/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy +++ b/src/main/groovy/io/advantageous/gradle/docker/DockerTestPlugin.groovy @@ -11,13 +11,13 @@ public class DockerTestPlugin implements Plugin { project.extensions.testDockerContainers = testDockerContainers project.task("showDockerContainers") { - project.doLast { + doLast { project.extensions.testDockerContainers.forEach { println it } } } project.task("startTestDocker", description: "Start up dependent docker containers for testing") { - project.doLast { + doLast { project.extensions.testDockerContainers.forEach { def result = DockerUtils.runCommand it.runCommand() if (result[0] != 0) throw new IllegalStateException(result[1].toString()) @@ -30,7 +30,7 @@ public class DockerTestPlugin implements Plugin { def startTestDocker = project.tasks.getByName("startTestDocker") project.task("stopTestDocker", description: "Stop docker containers used in tests") { - project.doLast { + doLast { project.extensions.testDockerContainers.forEach { def result = DockerUtils.stopContainer it.getContainerName() if (result[0] != 0) throw new IllegalStateException(result[1].toString()) @@ -42,7 +42,7 @@ public class DockerTestPlugin implements Plugin { def stopTestDocker = project.tasks.getByName("stopTestDocker") project.task("dockerTest", type: Test, description: "Run docker integration tests") { - project.doLast { + doLast { useJUnit { includeCategories 'io.advantageous.test.DockerTest' }