From 0c5e04a72dca54c50df13147f7049679177b7ebf Mon Sep 17 00:00:00 2001 From: Pavlo Stavytskyi Date: Sun, 29 Oct 2023 16:26:13 -0700 Subject: [PATCH] improved package descriptor api --- .../io/morfly/airin/PackageComponent.kt | 2 +- .../io/morfly/airin/PackageDescriptor.kt | 25 +++++++++---------- .../io/morfly/airin/SharedPropertiesHolder.kt | 7 ------ .../kotlin/io/morfly/airin/GradleProject.kt | 7 +----- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageComponent.kt b/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageComponent.kt index aab5fd9c..8849adb9 100644 --- a/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageComponent.kt +++ b/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageComponent.kt @@ -25,7 +25,7 @@ abstract class PackageComponent

: Component

(), Propert .map { it.invoke(packageDescriptor) } .toList() - packageDescriptor.applyDependencies(packageDescriptor.transformDependencies(features)) + packageDescriptor.dependencies = packageDescriptor.transformDependencies(features) allMavenArtifacts += packageDescriptor.dependencies.values.flatten() .filterIsInstance() diff --git a/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageDescriptor.kt b/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageDescriptor.kt index 77e466ff..62e0354f 100644 --- a/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageDescriptor.kt +++ b/airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageDescriptor.kt @@ -2,29 +2,28 @@ package io.morfly.airin import io.morfly.airin.label.Label -interface PackageDescriptor : PropertiesHolder { +abstract class PackageDescriptor : PropertiesHolder { - val name: String + abstract val name: String - val isRoot: Boolean + abstract val isRoot: Boolean - val label: Label + abstract val label: Label - val dirPath: String + abstract val dirPath: String - val ignored: Boolean + abstract val ignored: Boolean - val packageComponentId: String? + abstract val packageComponentId: String? - val featureComponentIds: Set + abstract val featureComponentIds: Set - val originalDependencies: Map> + abstract val originalDependencies: Map> - val dependencies: Map> + abstract var dependencies: Map> + internal set - val subpackages: List - - fun applyDependencies(dependencies: Map>) + abstract val subpackages: List } fun PackageDescriptor.transformDependencies(features: List): Map> { diff --git a/airin-core/src/jvmMain/kotlin/io/morfly/airin/SharedPropertiesHolder.kt b/airin-core/src/jvmMain/kotlin/io/morfly/airin/SharedPropertiesHolder.kt index b7fa5ba7..9ccdcbd1 100644 --- a/airin-core/src/jvmMain/kotlin/io/morfly/airin/SharedPropertiesHolder.kt +++ b/airin-core/src/jvmMain/kotlin/io/morfly/airin/SharedPropertiesHolder.kt @@ -6,10 +6,3 @@ interface SharedPropertiesHolder { val sharedPropertiesAvailable: Boolean } - -//@Suppress("UNCHECKED_CAST") -//val MutableMap.allMavenArtifacts: MutableSet -// get() { -// val artifacts = getOrPut("allMavenArtifacts") { mutableSetOf() } -// return artifacts as MutableSet -// } diff --git a/airin-gradle-plugin/src/main/kotlin/io/morfly/airin/GradleProject.kt b/airin-gradle-plugin/src/main/kotlin/io/morfly/airin/GradleProject.kt index 389d8197..08c5049f 100644 --- a/airin-gradle-plugin/src/main/kotlin/io/morfly/airin/GradleProject.kt +++ b/airin-gradle-plugin/src/main/kotlin/io/morfly/airin/GradleProject.kt @@ -9,7 +9,7 @@ data class GradleProject( override val label: GradleLabel, override val dirPath: String, override val isRoot: Boolean, -) : PackageDescriptor, Serializable { +) : PackageDescriptor(), Serializable { override val ignored: Boolean get() = packageComponentId == null @@ -24,14 +24,9 @@ data class GradleProject( internal set override lateinit var dependencies: Map> - internal set override lateinit var subpackages: List internal set override val properties = mutableMapOf() - - override fun applyDependencies(dependencies: Map>) { - this.dependencies = dependencies - } }