Skip to content

Commit

Permalink
refactor(composer): Turn toPackageReferences() into an expression
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Jul 23, 2024
1 parent f467df7 commit 1df5d29
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions plugins/package-managers/composer/src/main/kotlin/Composer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ class Composer(
packageInfoForName: Map<String, PackageInfo>,
virtualPackages: Set<String>,
dependencyBranch: List<String> = emptyList()
): Set<PackageReference> {
val packageReferences = mutableSetOf<PackageReference>()

): Set<PackageReference> =
getScopeDependencies(scopeName).filterNot { packageName ->
packageName.isPlatformDependency() || packageName in virtualPackages // Virtual packages have no metadata.
}.forEach { packageName ->
}.mapNotNullTo(mutableSetOf()) { packageName ->
val childInfo = packageInfoForName[packageName]
?: throw IOException("Could not find package info for $packageName")

Expand All @@ -168,10 +166,10 @@ class Composer(
"dependency tree: ${dependencyBranch.joinToString(" -> ")}."
}

return@forEach
return@mapNotNullTo null
}

packageReferences += PackageReference(
PackageReference(
id = childInfo.toId(),
dependencies = childInfo.toPackageReferences(
SCOPE_NAME_REQUIRE,
Expand All @@ -182,9 +180,6 @@ class Composer(
)
}

return packageReferences
}

private fun parseProject(definitionFile: File, scopes: Set<Scope>): Project {
logger.info { "Parsing project metadata from '$definitionFile'..." }

Expand Down

0 comments on commit 1df5d29

Please sign in to comment.