diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesTask.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesTask.kt index 2b7a0057..d1478899 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesTask.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesTask.kt @@ -13,21 +13,6 @@ import java.io.File /** * @author Silvio Giebl */ -data class OciImageInput( - @get:Input val platform: Platform, - @get:Nested val variants: List, - @get:Input val referenceSpecs: Set, -) { - init { - require(variants.isNotEmpty()) { "variants must not be empty" } - } -} - -data class OciVariantInput( - @get:InputFile @get:PathSensitive(PathSensitivity.NONE) val metadataFile: File, - @get:InputFiles @get:PathSensitive(PathSensitivity.NONE) val layerFiles: List, -) - class OciMultiPlatformImage( val index: OciData, val platformToImage: Map, @@ -57,7 +42,22 @@ class OciLayer( abstract class OciImagesTask : DefaultTask() { @get:Nested - val images = project.objects.setProperty() + val images = project.objects.setProperty() + + data class ImageInput( + @get:Input val platform: Platform, + @get:Nested val variants: List, + @get:Input val referenceSpecs: Set, + ) { + init { + require(variants.isNotEmpty()) { "variants must not be empty" } + } + } + + data class VariantInput( + @get:InputFile @get:PathSensitive(PathSensitivity.NONE) val metadataFile: File, + @get:InputFiles @get:PathSensitive(PathSensitivity.NONE) val layerFiles: List, + ) init { @Suppress("LeakingThis") @@ -69,7 +69,7 @@ abstract class OciImagesTask : DefaultTask() { @TaskAction protected fun run() { - val imageInputs: Set = images.get() + val imageInputs: Set = images.get() val imageAndReferencesPairs = createImageAndReferencesPairs(imageInputs) val multiPlatformImageAndReferencesPairs = createMultiPlatformImageAndReferencesPairs(imageAndReferencesPairs) val images = imageAndReferencesPairs.map { it.first } @@ -84,9 +84,9 @@ abstract class OciImagesTask : DefaultTask() { ) private fun createImageAndReferencesPairs( - imageInputs: Iterable, + imageInputs: Iterable, ): List>> { - val variantInputToVariant = HashMap() + val variantInputToVariant = HashMap() return imageInputs.map { imageInput -> val variants = imageInput.variants.map { variantInput -> variantInputToVariant.getOrPut(variantInput) { variantInput.toVariant() } @@ -105,7 +105,7 @@ abstract class OciImagesTask : DefaultTask() { } } - private fun OciVariantInput.toVariant(): OciVariant { + private fun VariantInput.toVariant(): OciVariant { val metadata = metadataFile.readText().decodeAsJsonToOciMetadata() val layerFiles = layerFiles val layers = ArrayList(layerFiles.size) diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/resolution/OciImageInputResolution.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/resolution/OciImageInputResolution.kt index a544d002..8e66df9d 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/resolution/OciImageInputResolution.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/resolution/OciImageInputResolution.kt @@ -1,7 +1,6 @@ package io.github.sgtsilvio.gradle.oci.internal.resolution -import io.github.sgtsilvio.gradle.oci.OciImageInput -import io.github.sgtsilvio.gradle.oci.OciVariantInput +import io.github.sgtsilvio.gradle.oci.OciImagesTask import io.github.sgtsilvio.gradle.oci.internal.gradle.ArtifactViewVariantFilter import org.gradle.api.artifacts.ResolvableDependencies import org.gradle.api.artifacts.component.ComponentIdentifier @@ -10,7 +9,7 @@ import org.gradle.api.attributes.AttributeContainer import org.gradle.api.capabilities.Capability import org.gradle.api.provider.Provider -internal fun ResolvableDependencies.resolveOciImageInputs(): Provider> { +internal fun ResolvableDependencies.resolveOciImageInputs(): Provider> { val rootComponentProvider = resolutionResult.rootComponent val imageSpecsProvider = rootComponentProvider.map(::resolveOciImageSpecs) val artifactResultsProvider = artifactView { @@ -28,9 +27,9 @@ internal fun ResolvableDependencies.resolveOciImageInputs(): Provider val imageSpecs = imageSpecsProvider.get() val variantDescriptorToInput = artifactResults.groupBy({ it.variant.toDescriptor() }) { it.file } - .mapValues { (_, files) -> OciVariantInput(files.first(), files.drop(1)) } + .mapValues { (_, files) -> OciImagesTask.VariantInput(files.first(), files.drop(1)) } val imageInputs = imageSpecs.map { imageSpec -> - OciImageInput( + OciImagesTask.ImageInput( imageSpec.platform, imageSpec.variants.mapNotNull { variant -> variantDescriptorToInput[variant.toDescriptor()] }, imageSpec.referenceSpecs,