Skip to content

Commit 6a2656e

Browse files
jomen-adfaclaude
andauthored
ADFA-4762: Restore per-ABI assets zip generation for generate_assets workflow (#1573)
PR #1441 (ADFA-4423) removed createAssetsZip() while extracting the AI plugins, so assembleV8Assets/assembleV7Assets stopped producing app/build/outputs/assets/assets-<abi>.zip and the "Generate Assets Zips and Upload to Google Drive" workflow has failed at the Drive upload step ever since. Debug APKs still need these zips on-device (SplitAssetsInstaller). Restore a trimmed createAssetsZip(arch) - the original repackaging logic minus the llama.aar/D8 handling the installer no longer expects - and wire it back into assembleV8Assets/assembleV7Assets. Entry names match the installer contract in AssetsInstallationHelper.expectedEntries. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 7f1ffb3 commit 6a2656e

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

app/build.gradle.kts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import java.io.BufferedOutputStream
88
import java.io.ByteArrayInputStream
99
import java.io.ByteArrayOutputStream
1010
import java.io.Closeable
11+
import java.io.FileNotFoundException
1112
import java.io.FileOutputStream
1213
import java.io.InputStream
1314
import java.net.HttpURLConnection
@@ -411,18 +412,73 @@ tasks.register<Zip>("createPluginArtifactsZip") {
411412
destinationDirectory.set(rootProject.file("assets"))
412413
}
413414

415+
// Packages the on-device installer payload (assets-<arch>.zip) consumed by
416+
// SplitAssetsInstaller on debug builds. Entry names must match the installer
417+
// contract in AssetsInstallationHelper.expectedEntries.
418+
fun createAssetsZip(arch: String) {
419+
val outputDir =
420+
project.layout.buildDirectory
421+
.dir("outputs/assets")
422+
.get()
423+
.asFile
424+
if (!outputDir.exists()) {
425+
outputDir.mkdirs()
426+
}
427+
val zipFile = outputDir.resolve("assets-$arch.zip")
428+
429+
val sourceDir = project.rootDir.resolve("assets")
430+
val bootstrapName = "bootstrap-$arch.zip"
431+
val androidSdkName = "android-sdk-$arch.zip"
432+
ZipOutputStream(zipFile.outputStream()).use { zipOut ->
433+
arrayOf(
434+
androidSdkName,
435+
"localMvnRepository.zip",
436+
"gradle-8.14.3-bin.zip",
437+
"gradle-api-8.14.3.jar.zip",
438+
"documentation.db",
439+
bootstrapName,
440+
"plugin-artifacts.zip",
441+
"core.cgt",
442+
).forEach { fileName ->
443+
val filePath = sourceDir.resolve(fileName)
444+
if (!filePath.exists()) {
445+
throw FileNotFoundException(filePath.absolutePath)
446+
}
447+
448+
project.logger.lifecycle("Zipping $fileName from ${filePath.absolutePath}")
449+
val entryName =
450+
when (fileName) {
451+
bootstrapName -> "bootstrap.zip"
452+
androidSdkName -> "android-sdk.zip"
453+
else -> fileName
454+
}
455+
456+
zipOut.putNextEntry(ZipEntry(entryName))
457+
filePath.inputStream().use { input -> input.copyTo(zipOut) }
458+
zipOut.closeEntry()
459+
}
460+
}
461+
project.logger.lifecycle("Created ${zipFile.name} at ${zipFile.parentFile.absolutePath}")
462+
}
463+
414464
tasks.register("assembleV8Assets") {
415465
dependsOn("createPluginArtifactsZip")
416466
if (!isCiCd) {
417467
dependsOn("assetsDownloadDebug")
418468
}
469+
doLast {
470+
createAssetsZip("arm64-v8a")
471+
}
419472
}
420473

421474
tasks.register("assembleV7Assets") {
422475
dependsOn("createPluginArtifactsZip")
423476
if (!isCiCd) {
424477
dependsOn("assetsDownloadDebug")
425478
}
479+
doLast {
480+
createAssetsZip("armeabi-v7a")
481+
}
426482
}
427483

428484
tasks.register("assembleAssets") {

0 commit comments

Comments
 (0)