Files
flutter-docker-image/script/updateAndroidVersions.gradle.kts
T
verified-commit[bot] d95fb95a1e chore: update flutter dependencies in version.json for 3.29.0 (#289)
* chore: update flutter dependencies in version.json for 3.29.0

* build: install NDK and CMake

* docs: update docs

* ci: add ndk version

* ci: add cmake version

---------

Co-authored-by: verified-commit[bot] <180343340+verified-commit[bot]@users.noreply.github.com>
Co-authored-by: Eligio Mariño <22875166+gmeligio@users.noreply.github.com>
2025-02-16 18:38:20 +01:00

38 lines
1.3 KiB
Kotlin

// Snippet to include at the end of android/app/build.gradle.kts
tasks.register<DefaultTask>("updateAndroidVersions") {
doLast {
val jsonFile = File("../../config/version.json")
// Parse existing JSON file
val resultJsonMap = groovy.json.JsonSlurper().parseText(jsonFile.readText()) as MutableMap<String, Any>
// Get unique platform versions
val platformVersions = listOf(
flutter.targetSdkVersion,
flutter.compileSdkVersion
).distinct()
// Create new Android version data
val newJsonMap = mapOf(
"platforms" to platformVersions.map {
mapOf("version" to it)
},
"gradle" to mapOf("version" to gradle.gradleVersion),
"ndk" to mapOf("version" to flutter.ndkVersion)
)
// Merge new values into the existing JSON structure
(resultJsonMap["android"] as? MutableMap<String, Any>)?.putAll(newJsonMap)
// Format JSON with pretty printing
val jsonStr = groovy.json.JsonOutput.toJson(resultJsonMap)
val prettyStr = groovy.json.JsonOutput.prettyPrint(jsonStr)
println(prettyStr)
// Write updated JSON back to the file
jsonFile.writeText("$prettyStr\n")
}
}