diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt index d10f1c25..7992c9dc 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt @@ -281,29 +281,14 @@ internal abstract class OciImageDefinitionImpl @Inject constructor( .map { it.build() } private fun createMetadataLayers(providerFactory: ProviderFactory): Provider> = - providerFactory.provider { + providerFactory.provider { layers.list }.flatMap { layers -> var listProvider = providerFactory.provider { listOf() } - for (layer in layers.list) { + for (layer in layers) { layer as Layer listProvider = listProvider.zip(layer.createMetadataLayer(providerFactory)) { list, e -> list + e } } listProvider - }.flatMap { it } - - private fun TaskContainer.createMetadataTask( - imageDefName: String, - platform: Platform?, - metadata: Provider, - projectLayout: ProjectLayout, - ) = register( - createOciMetadataClassifier(imageDefName).camelCase() + createPlatformPostfix(platform) - ) { - group = TASK_GROUP_NAME - description = "Assembles the metadata json file of the '$imageDefName' OCI image" + if (platform == null) "." else " for the platform $platform" - encodedMetadata.set(metadata.map { it.encodeToJsonString() }) - destinationDirectory.set(projectLayout.buildDirectory.dir("oci/images/$imageDefName")) - classifier.set(createOciMetadataClassifier(imageDefName) + createPlatformPostfix(platform)) - } + } final override fun parentImages(configuration: Action) = configuration.execute(parentImages) @@ -611,6 +596,19 @@ internal abstract class OciImageDefinitionImpl @Inject constructor( } } +private fun TaskContainer.createMetadataTask( + imageDefName: String, + platform: Platform?, + metadata: Provider, + projectLayout: ProjectLayout, +) = register(createOciMetadataClassifier(imageDefName).camelCase() + createPlatformPostfix(platform)) { + group = TASK_GROUP_NAME + description = "Assembles the metadata json file of the '$imageDefName' OCI image" + if (platform == null) "." else " for the platform $platform" + encodedMetadata.set(metadata.map { it.encodeToJsonString() }) + destinationDirectory.set(projectLayout.buildDirectory.dir("oci/images/$imageDefName")) + classifier.set(createOciMetadataClassifier(imageDefName) + createPlatformPostfix(platform)) +} + private fun TaskContainer.createLayerTask( imageDefName: String, layerName: String,