Skip to content

Commit b161474

Browse files
feat(android): mirror React Native SDK Kotlin 2.0 detection
- Read kotlinVersion from rootProject.ext with fallback - Check kotlinMajor version to conditionally load compose plugin - Matches stripe-react-native implementation exactly - Fixes Kotlin 2.0 compose compiler requirement
1 parent 15915bc commit b161474

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

packages/stripe_android/android/build.gradle

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ group 'com.flutter.stripe'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.9.0'
5+
def kotlin_version = rootProject.ext.has('kotlinVersion')
6+
? rootProject.ext.get('kotlinVersion')
7+
: '1.9.0'
8+
9+
ext.kotlin_version = kotlin_version
610
ext.stripe_version = '21.26.+'
711
ext.compose_version = '1.5.1'
812

13+
def kotlinMajor = kotlin_version.tokenize('\\.')[0].toInteger()
14+
915
repositories {
1016
google()
1117
mavenCentral()
@@ -14,6 +20,10 @@ buildscript {
1420
dependencies {
1521
classpath 'com.android.tools.build:gradle:8.1.3'
1622
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
23+
// only use compose-compiler plugin when Kotlin >= 2.0
24+
if (kotlinMajor >= 2) {
25+
classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlin_version"
26+
}
1727
}
1828
}
1929

@@ -24,8 +34,17 @@ rootProject.allprojects {
2434
}
2535
}
2636

37+
def kotlin_version = rootProject.ext.has('kotlinVersion')
38+
? rootProject.ext.get('kotlinVersion')
39+
: '1.9.0'
40+
def kotlinMajor = kotlin_version.tokenize('\\.')[0].toInteger()
41+
2742
apply plugin: 'com.android.library'
2843
apply plugin: 'kotlin-android'
44+
// Only apply compose plugin if Kotlin >= 2.0
45+
if (kotlinMajor >= 2) {
46+
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
47+
}
2948

3049
android {
3150
namespace 'com.flutter.stripe'

0 commit comments

Comments
 (0)