fix: Do not set CompatiblePackage.versions if @CompatiblePackage.versions is empty

This commit is contained in:
oSumAtrIX
2023-09-13 02:13:30 +02:00
parent 72c9eb2129
commit 6b1e0a1656
3 changed files with 28 additions and 4 deletions

View File

@@ -81,14 +81,14 @@ class PatchProcessor(
dependencies?.map { dependency -> dependency.toClassName() },
compatiblePackages?.map {
val packageName = it.property("name")
val packageVersions = (it.property("versions") as List<String>)
.joinToString(", ") { version -> "\"$version\"" }
val packageVersions = (it.property("versions") as List<String>).ifEmpty { null }
?.joinToString(", ") { version -> "\"$version\"" }
CodeBlock.of(
"%T(%S, setOf(%L))",
"%T(%S, %L)",
app.revanced.patcher.patch.Patch.CompatiblePackage::class,
packageName,
packageVersions
packageVersions?.let { "setOf($packageVersions)" },
)
},
use,