From 9e3c680609b6cd51c732254e60db3d889bfa52e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20August=C3=BDn?= Date: Wed, 28 Jul 2021 00:16:38 +0200 Subject: [PATCH] chore: ProjectLayout used --- .../avast/gradle/dockercompose/ComposeExecutor.groovy | 11 ++++++----- .../avast/gradle/dockercompose/ComposeSettings.groovy | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy b/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy index 794c7e5f..20abf985 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/ComposeExecutor.groovy @@ -1,5 +1,6 @@ package com.avast.gradle.dockercompose +import org.gradle.api.file.ProjectLayout import org.gradle.api.internal.file.FileOperations import org.gradle.api.invocation.Gradle import org.gradle.api.logging.Logger @@ -15,7 +16,7 @@ import java.util.concurrent.Executors class ComposeExecutor { private final ComposeSettings settings - private final File projectDir + private final ProjectLayout layout private final ExecOperations exec private final FileOperations fileOps private final Gradle gradle @@ -23,9 +24,9 @@ class ComposeExecutor { private static final Logger logger = Logging.getLogger(ComposeExecutor.class); @Inject - ComposeExecutor(ComposeSettings settings, File projectDir, ExecOperations exec, FileOperations fileOps, Gradle gradle) { + ComposeExecutor(ComposeSettings settings, ProjectLayout layout, ExecOperations exec, FileOperations fileOps, Gradle gradle) { this.settings = settings - this.projectDir = projectDir + this.layout = layout this.exec = exec this.fileOps = fileOps this.gradle = gradle @@ -182,9 +183,9 @@ class ComposeExecutor { Iterable getStandardComposeFiles() { def res = [] - def f = findInParentDirectories('docker-compose.yml', projectDir) + def f = findInParentDirectories('docker-compose.yml', layout.projectDirectory.getAsFile()) if (f != null) res.add(f) - f = findInParentDirectories('docker-compose.override.yml', projectDir) + f = findInParentDirectories('docker-compose.override.yml', layout.projectDirectory.getAsFile()) if (f != null) res.add(f) res } diff --git a/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy b/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy index 22c29ef2..7505d89a 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy @@ -122,7 +122,7 @@ class ComposeSettings { pushTask = project.tasks.register(name ? "${name}ComposePush".toString() : 'composePush', ComposePush, { it.settings = this }) this.dockerExecutor = project.objects.newInstance(DockerExecutor, this) - this.composeExecutor = project.objects.newInstance(ComposeExecutor, this, project.projectDir) + this.composeExecutor = project.objects.newInstance(ComposeExecutor, this) this.serviceInfoCache = new ServiceInfoCache(this) this.containerLogToDir = project.buildDir.toPath().resolve('containers-logs').toFile()