From a9191c0ff09c0dea5d70f95e9b823b32ec52190b Mon Sep 17 00:00:00 2001 From: Jan Sykora Date: Thu, 19 Jul 2018 22:39:49 +0200 Subject: [PATCH] doc for exposing service info for nested configuration improved --- README.md | 7 +++++++ .../dockercompose/DockerExecutorTest.groovy | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 542c904..fa65601 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,13 @@ dockerCompose { * It's possible to use all the settings as in the main `dockerCompose` block. * Configuration of the nested settings defaults to the main `dockerCompose` settings. +When exposing service info from `myNestedComposeUp` task into your task you should use following syntax: +``` +test.doFirst { + dockerCompose.myNested.exposeAsEnvironment(test) +} +``` + It's also possible to use this simplified syntax: ```gradle dockerCompose { diff --git a/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy b/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy index be74079..eff4876 100644 --- a/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy +++ b/src/test/groovy/com/avast/gradle/dockercompose/DockerExecutorTest.groovy @@ -1,6 +1,5 @@ package com.avast.gradle.dockercompose -import spock.lang.Ignore import spock.lang.Specification class DockerExecutorTest extends Specification { @@ -41,4 +40,21 @@ class DockerExecutorTest extends Specification { f.project.tasks.composeDown.down() f.close() } + + def "expose service info from nested task"() { + def f = Fixture.withNginx() + f.project.plugins.apply 'java' + f.project.dockerCompose { + nested { } + } + when: + f.project.tasks.nestedComposeUp.up() + f.extension.nested.exposeAsSystemProperties(f.project.tasks.test) + then: + f.project.tasks.test.properties.systemProperties.containsKey('web.host') + f.project.tasks.test.properties.systemProperties.containsKey('web.tcp.80') + cleanup: + f.project.tasks.nestedComposeDown.down() + f.close() + } }