Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions packages/desktop_drop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.8.4

* [Android] Conditionally apply Kotlin Gradle Plugin based on `android.builtInKotlin` property — applies KGP on AGP 8 and AGP 9 with `builtInKotlin=false`, skips KGP on AGP 9 with `builtInKotlin=true`

## 0.8.3

* [Android] Fix Kotlin configuration for AGP 8 and AGP 9 hosts [#498](https://github.com/MixinNetwork/flutter-plugins/pull/498)
Expand Down
39 changes: 22 additions & 17 deletions packages/desktop_drop/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,23 @@ buildscript {

apply plugin: 'com.android.library'

// AGP 9 has built-in Kotlin; applying KGP there fails.
// Hosts on AGP < 9 don't provide Kotlin for this plugin, so we apply it.
// Each AGP uses a different DSL for jvmTarget.
// Apply KGP only when AGP does not provide built-in Kotlin.
// AGP <9 never has built-in Kotlin -> apply KGP.
// AGP 9+ defaults to built-in Kotlin unless property is explicitly false.
def agpMajor = 0
try {
agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
} catch (ignored) {
agpMajor = 0
}
if (agpMajor < 9) {

def builtInKotlin = agpMajor >= 9
if (project.hasProperty('android.builtInKotlin')) {
builtInKotlin = project.property('android.builtInKotlin').toString().toBoolean()
}

if (!builtInKotlin) {
apply plugin: 'kotlin-android'
android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
} else {
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}
}

rootProject.allprojects {
Expand Down Expand Up @@ -67,8 +62,18 @@ android {
defaultConfig {
minSdkVersion 16
}

if (!builtInKotlin) {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
if (builtInKotlin) {
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}
}
2 changes: 1 addition & 1 deletion packages/desktop_drop/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: desktop_drop
resolution: workspace
description: A plugin which allows user dragging files to your flutter desktop applications.
version: 0.8.3
version: 0.8.4
homepage: https://github.com/MixinNetwork/flutter-plugins/tree/main/packages/desktop_drop

environment:
Expand Down
Loading