Skip to content

Commit

Permalink
improved package descriptor api
Browse files Browse the repository at this point in the history
  • Loading branch information
Morfly committed Oct 29, 2023
1 parent 251ce10 commit 0c5e04a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class PackageComponent<P : PackageDescriptor> : Component<P>(), Propert
.map { it.invoke(packageDescriptor) }
.toList()

packageDescriptor.applyDependencies(packageDescriptor.transformDependencies(features))
packageDescriptor.dependencies = packageDescriptor.transformDependencies(features)
allMavenArtifacts += packageDescriptor.dependencies.values.flatten()
.filterIsInstance<MavenCoordinates>()

Expand Down
25 changes: 12 additions & 13 deletions airin-core/src/jvmMain/kotlin/io/morfly/airin/PackageDescriptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>
abstract val featureComponentIds: Set<String>

val originalDependencies: Map<ConfigurationName, List<Label>>
abstract val originalDependencies: Map<ConfigurationName, List<Label>>

val dependencies: Map<ConfigurationName, Set<Label>>
abstract var dependencies: Map<ConfigurationName, Set<Label>>
internal set

val subpackages: List<PackageDescriptor>

fun applyDependencies(dependencies: Map<ConfigurationName, Set<Label>>)
abstract val subpackages: List<PackageDescriptor>
}

fun PackageDescriptor.transformDependencies(features: List<FeatureContext>): Map<ConfigurationName, Set<Label>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@ interface SharedPropertiesHolder {

val sharedPropertiesAvailable: Boolean
}

//@Suppress("UNCHECKED_CAST")
//val MutableMap<String, Any?>.allMavenArtifacts: MutableSet<MavenCoordinates>
// get() {
// val artifacts = getOrPut("allMavenArtifacts") { mutableSetOf<MavenCoordinates>() }
// return artifacts as MutableSet<MavenCoordinates>
// }
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,14 +24,9 @@ data class GradleProject(
internal set

override lateinit var dependencies: Map<ConfigurationName, Set<Label>>
internal set

override lateinit var subpackages: List<GradleProject>
internal set

override val properties = mutableMapOf<String, Any?>()

override fun applyDependencies(dependencies: Map<ConfigurationName, Set<Label>>) {
this.dependencies = dependencies
}
}

0 comments on commit 0c5e04a

Please sign in to comment.