forked from eatvio/eatvio_app
99 lines
3.3 KiB
Groovy
99 lines
3.3 KiB
Groovy
buildscript {
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
maven {
|
|
url = 'https://repo.huaweicloud.com/repository/maven/'
|
|
content { includeGroupByRegex 'com\\.huawei.*' }
|
|
}
|
|
gradlePluginPortal()
|
|
}
|
|
dependencies {
|
|
classpath 'com.android.tools.build:gradle:9.3.1'
|
|
classpath 'com.huawei.agconnect:agcp:1.9.1.301'
|
|
}
|
|
}
|
|
|
|
allprojects {
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
maven {
|
|
url = 'https://repo.huaweicloud.com/repository/maven/'
|
|
content { includeGroupByRegex 'com\\.huawei.*' }
|
|
}
|
|
}
|
|
}
|
|
|
|
rootProject.buildDir = "../build"
|
|
subprojects {
|
|
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
|
}
|
|
subprojects {
|
|
project.evaluationDependsOn(":app")
|
|
}
|
|
|
|
// Temporary safeguard: set missing namespaces for Android library modules based on their manifest package
|
|
subprojects { Project subproject ->
|
|
subproject.pluginManager.withPlugin('com.android.library') {
|
|
def androidExt = subproject.extensions.findByName('android')
|
|
if (androidExt != null) {
|
|
def hasNamespaceProp = androidExt.hasProperty('namespace')
|
|
def currentNamespace = hasNamespaceProp ? androidExt.namespace : null
|
|
if (hasNamespaceProp && !currentNamespace) {
|
|
def manifestFile = file("${subproject.projectDir}/src/main/AndroidManifest.xml")
|
|
if (manifestFile.exists()) {
|
|
try {
|
|
def manifest = new groovy.xml.XmlSlurper().parse(manifestFile)
|
|
def manifestPackage = manifest.@package?.text()
|
|
if (manifestPackage) {
|
|
androidExt.namespace = manifestPackage
|
|
subproject.logger.lifecycle("[namespace-fix] Set namespace for ${subproject.path} to '${manifestPackage}' from AndroidManifest.xml")
|
|
}
|
|
} catch (Throwable t) {
|
|
subproject.logger.warn("[namespace-fix] Failed to read manifest for ${subproject.path}: ${t.message}")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// AGP 9 lint crashes in CommentDetector with NoSuchMethodError List.removeLast()
|
|
// (image_picker_android:lintVitalAnalyzeRelease). That check is fatal for release.
|
|
subprojects { Project subproject ->
|
|
subproject.tasks.configureEach { task ->
|
|
if (task.name.startsWith("lintVital")) {
|
|
task.enabled = false
|
|
}
|
|
}
|
|
}
|
|
|
|
// AGP 9 enforces AAR metadata: plugins that still declare compileSdk 31 fail the build.
|
|
subprojects { Project subproject ->
|
|
def bumpCompileSdk = {
|
|
if (!subproject.plugins.hasPlugin('com.android.library')) {
|
|
return
|
|
}
|
|
def androidExt = subproject.extensions.findByName('android')
|
|
if (androidExt == null) {
|
|
return
|
|
}
|
|
try {
|
|
androidExt.compileSdk = 36
|
|
} catch (Throwable t) {
|
|
subproject.logger.warn("[compileSdk-fix] Failed for ${subproject.path}: ${t.message}")
|
|
}
|
|
}
|
|
// evaluationDependsOn(":app") can leave some projects already evaluated.
|
|
if (subproject.state.executed) {
|
|
bumpCompileSdk()
|
|
} else {
|
|
subproject.afterEvaluate { bumpCompileSdk() }
|
|
}
|
|
}
|
|
|
|
tasks.register("clean", Delete) {
|
|
delete rootProject.buildDir
|
|
}
|