Files

54 lines
1.9 KiB
Kotlin
Raw Permalink Normal View History

allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
// Force plugin subprojects onto a modern compileSdk/minSdk.
// Several pinned pub plugins are stuck on ancient values -- bg_launcher 0.1.0 is
// compileSdk 31 / minSdk 16, flutter_overlay_window 0.5.0 is compileSdk 34 -- and the
// AndroidX artifacts they now resolve to refuse to be consumed by them.
// The fix belongs HERE, not in ~/.pub-cache: that cache is shared between users,
// unversioned, and invisible to git, so an edit there silently poisons every build on
// the machine and is wiped by the next `pub get`.
// Reflection is used because AGP's types are not on the root build script classpath.
// NOTE: must be registered BEFORE evaluationDependsOn(":app") below, which evaluates
// subprojects eagerly -- after it, afterEvaluate throws.
subprojects {
afterEvaluate {
val androidExt = extensions.findByName("android") ?: return@afterEvaluate
runCatching {
androidExt.javaClass
.getMethod("setCompileSdkVersion", Int::class.javaPrimitiveType)
.invoke(androidExt, 36)
}
runCatching {
val defaultConfig = androidExt.javaClass
.getMethod("getDefaultConfig")
.invoke(androidExt)
defaultConfig.javaClass
.getMethod("setMinSdkVersion", Int::class.javaPrimitiveType)
.invoke(defaultConfig, 24)
}
}
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}