Skip to content

Commit 1372e23

Browse files
authored
fix: incompatibility with the configuration cache
1 parent 41c74b5 commit 1372e23

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.avast.gradle.dockercompose
22

33
import groovy.transform.CompileStatic
4+
import groovy.transform.PackageScope
45
import org.gradle.api.Project
56
import org.gradle.api.Task
67
import org.gradle.api.file.DirectoryProperty
@@ -226,6 +227,11 @@ abstract class ComposeSettings {
226227
}
227228

228229
void exposeAsEnvironment(ProcessForkOptions task) {
230+
exposeAsEnvironmentInternal(task, servicesInfos)
231+
}
232+
233+
@PackageScope
234+
void exposeAsEnvironmentInternal(ProcessForkOptions task, Map<String, ServiceInfo> servicesInfos) {
229235
servicesInfos.values().each { serviceInfo ->
230236
serviceInfo.containerInfos.each { instanceName, si ->
231237
if (instanceName.endsWith('_1') || instanceName.endsWith('-1')) {
@@ -237,6 +243,11 @@ abstract class ComposeSettings {
237243
}
238244

239245
void exposeAsSystemProperties(JavaForkOptions task) {
246+
exposeAsSystemPropertiesInternal(task, servicesInfos)
247+
}
248+
249+
@PackageScope
250+
void exposeAsSystemPropertiesInternal(JavaForkOptions task, Map<String, ServiceInfo> servicesInfos) {
240251
servicesInfos.values().each { serviceInfo ->
241252
serviceInfo.containerInfos.each { instanceName, si ->
242253
if(instanceName.endsWith('_1') || instanceName.endsWith('-1')) {

src/main/groovy/com/avast/gradle/dockercompose/TasksConfigurator.groovy

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,16 @@ class TasksConfigurator {
127127
} else {
128128
upTask.configure { it.shouldRunAfter getTaskDependencies(task) }
129129
}
130-
if (task instanceof ProcessForkOptions) task.doFirst { composeSettings.exposeAsEnvironment(task as ProcessForkOptions) }
131-
if (task instanceof JavaForkOptions) task.doFirst { composeSettings.exposeAsSystemProperties(task as JavaForkOptions) }
130+
131+
// composeSettings.tasksConfigurator is null when the doFirst actions run with the configuration cache enabled.
132+
def composeSettings = this.composeSettings
133+
def servicesInfos = upTask.map { it.servicesInfos }
134+
if (task instanceof ProcessForkOptions) task.doFirst {
135+
composeSettings.exposeAsEnvironmentInternal(task as ProcessForkOptions, servicesInfos.get())
136+
}
137+
if (task instanceof JavaForkOptions) task.doFirst {
138+
composeSettings.exposeAsSystemPropertiesInternal(task as JavaForkOptions, servicesInfos.get())
139+
}
132140
}
133141

134142
private Object getTaskDependencies(Task task) {

0 commit comments

Comments
 (0)