Last active
August 6, 2025 01:25
-
-
Save AlexV525/3420eb5a798ddb76833d05f430f4a475 to your computer and use it in GitHub Desktop.
Consist Flutter Android modules/libraries JVM targets (with KTS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allprojects { | |
repositories { | |
google() | |
mavenCentral() | |
} | |
} | |
val newBuildDir: Directory = | |
rootProject.layout.buildDirectory | |
.dir("../../build") | |
.get() | |
rootProject.layout.buildDirectory.value(newBuildDir) | |
private val javaVersion = JavaVersion.VERSION_17 | |
private val configureAndroidExtension: com.android.build.api.dsl.CommonExtension<*, *, *, *, *, *>.() -> Unit = { | |
compileOptions { | |
sourceCompatibility = javaVersion | |
targetCompatibility = javaVersion | |
} | |
buildFeatures { | |
buildConfig = true | |
} | |
} | |
subprojects { | |
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) | |
project.layout.buildDirectory.value(newSubprojectBuildDir) | |
afterEvaluate { | |
plugins.withId("org.gradle.java.base") { | |
extensions.configure<JavaPluginExtension> { | |
sourceCompatibility = javaVersion | |
targetCompatibility = javaVersion | |
toolchain { | |
languageVersion.set(JavaLanguageVersion.of(javaVersion.toString())) | |
} | |
} | |
} | |
plugins.withId("com.android.application") { | |
project.extensions.configure<com.android.build.api.dsl.ApplicationExtension> { | |
configureAndroidExtension() | |
} | |
} | |
plugins.withId("com.android.library") { | |
project.extensions.configure<com.android.build.api.dsl.LibraryExtension> { | |
configureAndroidExtension() | |
} | |
} | |
tasks.withType<JavaCompile>().configureEach { | |
sourceCompatibility = javaVersion.toString() | |
targetCompatibility = javaVersion.toString() | |
} | |
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach { | |
compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(javaVersion.toString())) | |
kotlinOptions.jvmTarget = javaVersion.toString() | |
} | |
} | |
} | |
subprojects { | |
project.evaluationDependsOn(":app") | |
} | |
tasks.register<Delete>("clean") { | |
delete(rootProject.layout.buildDirectory) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment