Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions image_editor_common/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,24 @@ rootProject.allprojects {
}
}

def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
// AGP 9 enables built-in Kotlin and no longer allows library subprojects to apply
// the Kotlin Gradle Plugin (KGP). Apply KGP ourselves whenever built-in Kotlin is
// not in effect; the pluginManager form keeps Flutter's static KGP detection from
// flagging this plugin. See
// https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors
//
// Built-in Kotlin only exists on AGP 9+. There it is on by default and can be
// opted out of with `android.builtInKotlin=false`; on AGP 8 the property has no
// effect. An explicit `false` must be honoured, so the property is checked for
// presence rather than truthiness (Groovy's `?:` would treat `false` as absent).
def builtInKotlinProperty = project.findProperty('android.builtInKotlin')
def builtInKotlinEnabled = agpMajor >= 9 &&
(builtInKotlinProperty == null || builtInKotlinProperty.toString().toBoolean())
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
if (!builtInKotlinEnabled) {
pluginManager.apply('kotlin-android')
}

android {
if (project.hasProperty('compileSdk')) {
Expand All @@ -40,8 +56,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
if (!builtInKotlinEnabled) {
kotlinOptions {
jvmTarget = '1.8'
}
}

defaultConfig {
Expand All @@ -57,3 +75,11 @@ dependencies {
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation 'com.jaredrummler:truetypeparser-light:1.0.0'
}

if (builtInKotlinEnabled) {
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}
}