@@ -29,10 +29,7 @@ import org.gradle.api.file.*
2929import org.gradle.api.plugins.BasePlugin
3030import org.gradle.api.provider.Property
3131import org.gradle.api.provider.Provider
32- import org.gradle.api.tasks.Input
33- import org.gradle.api.tasks.InputFile
34- import org.gradle.api.tasks.Internal
35- import org.gradle.api.tasks.TaskAction
32+ import org.gradle.api.tasks.*
3633import org.gradle.api.tasks.bundling.Zip
3734import org.gradle.process.ExecOperations
3835
@@ -70,9 +67,10 @@ abstract class BuildDockerImageTask extends DefaultTask {
7067 @Input DistroVersion distroVersion
7168 @Input String tiniVersion
7269
73- // We don't declare an output here, only an input. We dont want it to be cached.
74- // Multiple tasks share dir from parent with unique tarballs per distribution, so they are not "owned" by the task.
75- @Internal abstract DirectoryProperty getOutputDir ()
70+ // We don't declare an output here and multiple tasks share dir from parent with unique tarballs per
71+ // distribution, so the dirs are not "owned" by the task.
72+ @Internal abstract DirectoryProperty getDistributionDir ()
73+ @Internal final goVersions = project. goVersions as GoVersions
7674
7775 @Internal Closure templateHelper
7876 @Internal Closure verifyHelper
@@ -86,8 +84,6 @@ abstract class BuildDockerImageTask extends DefaultTask {
8684 private final boolean keepImages = project. hasProperty(' dockerBuildKeepImages' )
8785 private final String gitPush = project. findProperty(' dockerGitPush' )
8886
89- private final goVersions = project. goVersions as GoVersions
90-
9187 BuildDockerImageTask () {
9288 dependsOn ' :docker:initializeBuildx'
9389 group = BasePlugin . BUILD_GROUP
@@ -154,11 +150,11 @@ abstract class BuildDockerImageTask extends DefaultTask {
154150 logger. lifecycle(" Building ${ distro} image for ${ distro.supportedArchitectures} . (Current build architecture is ${ Architecture.current()} )." )
155151
156152 // build image
157- imageTarFile . parentFile. mkdirs()
153+ imageOciTarFile . parentFile. mkdirs()
158154 executeInGitRepo(" docker" , " buildx" , " build" ,
159155 " --pull" ,
160156 " --platform" , supportedPlatforms. join(" ," ),
161- " --output" , " type=oci,dest=${ imageTarFile } " ,
157+ " --output" , " type=oci,dest=${ imageOciTarFile } " ,
162158 " --progress=plain" ,
163159 " ." ,
164160 " --tag" , imageNameWithTag
@@ -266,9 +262,14 @@ abstract class BuildDockerImageTask extends DefaultTask {
266262 " v${ goVersions.fullVersion} "
267263 }
268264
265+ @OutputFile
266+ Provider<RegularFile > getImageOciTarOutput () {
267+ distributionDir. map { it. file(" gocd-${ imageType.get().name()} -${ dockerImageName} -v${ goVersions.fullVersion} .tar" ) }
268+ }
269+
269270 @Internal
270- File getImageTarFile () {
271- outputDir . get() . file( " gocd- ${ imageType.get().name() } - ${ dockerImageName } -v ${ goVersions.fullVersion } .tar " ). asFile
271+ File getImageOciTarFile () {
272+ imageOciTarOutput . get(). asFile
272273 }
273274
274275 void writeTemplateToFile (String templateFile , String outputFile ) {
0 commit comments