mirror of
https://github.com/gmeligio/flutter-docker-image.git
synced 2026-05-24 12:30:34 +00:00
d95fb95a1e
* 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>
38 lines
1.3 KiB
Kotlin
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")
|
|
}
|
|
}
|