Removed deprecated versionCodeOverride and versionNameOverride uses from custom application

This commit is contained in:
MohitMaliFtechiz 2023-04-18 12:43:54 +05:30 committed by Kelson
parent fd26fd370b
commit defedb495a
2 changed files with 15 additions and 13 deletions

View File

@ -82,13 +82,13 @@ class Transaction(
FileContent("application/octet-stream", file)
).execute().prettyPrint()
fun attachExpansionTo(expansionCode: Int, versionCode: Int): ExpansionFile =
fun attachExpansionTo(versionCode: Int): ExpansionFile =
publisher.edits().expansionfiles().update(
packageName,
editId,
versionCode,
"main",
ExpansionFile().apply { referencesVersion = expansionCode }
ExpansionFile().apply { referencesVersion = versionCode }
).execute().prettyPrint()
fun uploadBundle(outputFile: File) {
@ -99,12 +99,12 @@ class Transaction(
).execute().prettyPrint()
}
fun addToTrackInDraft(apkVariants: List<VariantOutput>): Track =
fun addToTrackInDraft(versionCode: Int, versionName: String?): Track =
publisher.edits().tracks().update(packageName, editId, "alpha", Track().apply {
releases = listOf(TrackRelease().apply {
status = "draft"
name = apkVariants[0].versionName.toString()
versionCodes = apkVariants.map { it.versionCode.orNull?.toLong() ?: 0 }
name = versionName
versionCodes = listOf(versionCode.toLong())
})
track = "alpha"
}).execute().prettyPrint()

View File

@ -75,19 +75,20 @@ fun ProductFlavor.createPublishBundleWithExpansionTask(
println("packageName $packageName")
createPublisher(File(rootDir, "playstore.json"))
.transactionWithCommit(packageName) {
val versionCode = (7 * 1_000_000) + versionCode!!
val variants =
applicationVariants.releaseVariantsFor(this@createPublishBundleWithExpansionTask)
val generatedBundleFile =
File(
"$buildDir/outputs/bundle/${capitalizedName.toLowerCase()}Release" +
"/custom-/${capitalizedName.toLowerCase()}-/release.aab"
"$buildDir/outputs/bundle/${capitalizedName.toLowerCase()}" +
"Release/custom-${capitalizedName.toLowerCase()}-release.aab"
)
if (generatedBundleFile.exists()) {
uploadBundle(generatedBundleFile)
uploadExpansionTo(file, versionCode)
attachExpansionTo(versionCode, versionCode)
// addToTrackInDraft(versionCode)
uploadExpansionTo(file, variants[0].versionCode)
attachExpansionTo(variants[0].versionCode)
addToTrackInDraft(variants[0].versionCode, versionName)
} else {
throw FileNotFoundException("Unable to generate aab file")
throw FileNotFoundException("Unable to find generated aab file")
}
}
}
@ -96,7 +97,8 @@ fun ProductFlavor.createPublishBundleWithExpansionTask(
fun DomainObjectSet<ApplicationVariant>.releaseVariantsFor(productFlavor: ProductFlavor) =
find { it.name.equals("${productFlavor.name}Release", true) }!!
.outputs.filterIsInstance<ApkVariantOutput>().sortedBy { it.versionCodeOverride }
.outputs.filterIsInstance<ApkVariantOutput>()
.filter { it.baseName.contains("universal") }.sortedBy { it.versionCode }
afterEvaluate {
tasks.filter { it.name.contains("ReleaseBundleWithExpansionFile") }.forEach {