xenit-eu / alfresco-docker-gradle-plugin

A Gradle plugin to build Alfresco docker images with extensions
Apache License 2.0
10 stars 6 forks source link

Nested docker-compose configurations don't inherit composeFiles anymore #307

Open thijslemmens opened 1 year ago

vierbergenlars commented 1 year ago

Are you sure that this was ever supported?

The avast docker-compose plugin has this in their docs:

Configuration of the nested settings defaults to the main dockerCompose settings (declared before the nested settings), except following properties: projectName, startedServices, useComposeFiles, scale, captureContainersOutputToFile, captureContainersOutputToFiles, composeLogToFile, containerLogToDir, pushServices

And that statement is there since version 0.12.2 (the behavior even earlier)

thijslemmens commented 1 year ago

It used to work with +=, now with add it does not anymore. I'm not sure that it works with the vanilla dockerCompose plugin. It's in our backlog to check it out.

vierbergenlars commented 1 year ago

I tested with all plugin versions from 5.0.2 (the first version that introduced nested support) until 5.4.0 (the current latest version)

I could not find any version that actually appends additional items to the list of the composeFiles when creating a nested configuration.

By searching in all repositories, I can not find a single use of this behavior. However, I do see a pattern that can be mistaken for this behavior:

Test code ```java package eu.xenit.gradle.docker.compose; import static org.junit.Assert.assertEquals; import com.avast.gradle.dockercompose.ComposeSettings; import java.util.ArrayList; import java.util.List; import org.gradle.api.Project; import org.gradle.testfixtures.ProjectBuilder; import org.junit.Test; public class DockerComposeExtensionOverrideTest { @Test public void nestedContainsParentComposeFiles() { Project project = ProjectBuilder.builder().build(); project.getPluginManager().apply(DockerComposePlugin.class); project.getExtensions().configure(DockerComposeExtensionOverride.class, dockerCompose -> { dockerCompose.getUseComposeFiles().add("docker-compose-1.yml"); ((ComposeSettings)dockerCompose.methodMissing("sub", new Object[0])).getUseComposeFiles().add("docker-compose-2.yml"); }); List composeFiles = project.getExtensions().getByType(DockerComposeExtensionOverride.class).getUseComposeFiles(); List subComposeFiles = ((ComposeSettings)project.getExtensions().getByType(DockerComposeExtensionOverride.class).propertyMissing("sub")).getUseComposeFiles(); assertEquals(new ArrayList() {{ add("docker-compose.yml"); add("docker-compose-1.yml"); }}, composeFiles); assertEquals(new ArrayList() {{ add("docker-compose.yml"); add("docker-compose-1.yml"); add("docker-compose-2.yml"); }}, subComposeFiles); } } ```