From f48270d33d14013ca31a0049086fa0f82812851a Mon Sep 17 00:00:00 2001 From: Ayk Borstelmann Date: Fri, 11 Nov 2022 16:07:47 +0100 Subject: [PATCH] fix: Make default project name lowercase, fixes #378 --- .../dockercompose/ComposeSettings.groovy | 5 +++- .../DockerComposePluginTest.groovy | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy b/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy index dfd5d8ed..5b6ca272 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy @@ -101,7 +101,10 @@ abstract class ComposeSettings { else { return "${safeProjectNamePrefix}_${nestedName}" } - }) + }).map{ String projectName -> + // docker-compose project names must be lowercase + projectName.toLowerCase() + } useComposeFiles.empty() startedServices.empty() diff --git a/src/test/groovy/com/avast/gradle/dockercompose/DockerComposePluginTest.groovy b/src/test/groovy/com/avast/gradle/dockercompose/DockerComposePluginTest.groovy index b0174c88..d9d9c424 100644 --- a/src/test/groovy/com/avast/gradle/dockercompose/DockerComposePluginTest.groovy +++ b/src/test/groovy/com/avast/gradle/dockercompose/DockerComposePluginTest.groovy @@ -81,6 +81,32 @@ class DockerComposePluginTest extends Specification { up.composeExecutor.get().parameters.useComposeFiles.get() == ['test.yml'] } + def "project name should always be lowercase"() { + def project = ProjectBuilder.builder().build() + when: + project.plugins.apply 'docker-compose' + project.dockerCompose { + nestedUppercaseTask { + useComposeFiles = ['docker-compose.yml'] + } + nestedUppercaseProjectName { + projectNamePrefix = "UPPERCASE" + } + nestedUppercaseProjectNamePrefix { + projectNamePrefix = "UPPERCASE" + } + } + + then: + + ['nestedUppercaseTask', 'nestedUppercaseProjectName'].forEach{ String config -> + def projectName = project.dockerCompose."$config".projectName.get() + assert projectName.toLowerCase() == projectName + } + + + } + def "is possible to access servicesInfos of nested setting"() { def project = ProjectBuilder.builder().build() when: