Visitar URL original
refactor(core,android): migrate native implementation to Kotlin (#18570) · firebase/flutterfire@7a0f585 · GitHub
Skip to content

Commit 7a0f585

Browse files
authored
refactor(core,android): migrate native implementation to Kotlin (#18570)
* refactor(core,apple): migrate iOS/macOS plugin implementation to Swift Switch firebase_core from Pigeon objcOut to swiftOut and implement the HostApi in Swift. Custom auth domains now live on FLTFirebasePlugin so firebase_auth does not depend on the Core plugin class. * refactor(core,android): migrate native implementation to Kotlin Switch firebase_core from Pigeon javaOut to kotlinOut and implement the HostApi in Kotlin. Custom auth domains now live on FlutterFirebasePlugin so firebase_auth does not depend on the Core plugin class. * style(core,android): format Kotlin sources with ktfmt
1 parent 47334ec commit 7a0f585

8 files changed

Lines changed: 894 additions & 1387 deletions

File tree

‎packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import io.flutter.plugin.common.EventChannel;
3232
import io.flutter.plugin.common.EventChannel.StreamHandler;
3333
import io.flutter.plugin.common.MethodChannel;
34-
import io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin;
3534
import io.flutter.plugins.firebase.core.FlutterFirebasePlugin;
3635
import java.util.HashMap;
3736
import java.util.List;
@@ -137,7 +136,7 @@ static FirebaseAuth getAuthFromPigeon(
137136
if (pigeonApp.getTenantId() != null) {
138137
auth.setTenantId(pigeonApp.getTenantId());
139138
}
140-
String customDomain = FlutterFirebaseCorePlugin.customAuthDomain.get(pigeonApp.getAppName());
139+
String customDomain = FlutterFirebasePlugin.customAuthDomain.get(pigeonApp.getAppName());
141140
if (customDomain != null) {
142141
auth.setCustomAuthDomain(customDomain);
143142
}

‎packages/firebase_core/firebase_core/android/build.gradle‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ buildscript {
1111
}
1212
}
1313

14+
rootProject.allprojects {
15+
repositories {
16+
google()
17+
mavenCentral()
18+
}
19+
}
20+
21+
// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false.
22+
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
23+
def builtInKotlin = providers.gradleProperty("android.builtInKotlin")
24+
.map { it.toBoolean() }
25+
.orElse(agpMajor >= 9)
26+
.get()
27+
if (agpMajor < 9 || !builtInKotlin) {
28+
apply plugin: 'kotlin-android'
29+
}
30+
1431
def getRootProjectExtOrDefaultProperty(name) {
1532
if (!rootProject.ext.has("FlutterFire")) return project.properties[name]
1633
if (!rootProject.ext.get("FlutterFire")[name]) return project.properties[name]
@@ -36,6 +53,10 @@ android {
3653
targetCompatibility project.ext.javaVersion
3754
}
3855

56+
sourceSets {
57+
main.java.srcDirs += "src/main/kotlin"
58+
}
59+
3960
buildFeatures {
4061
buildConfig true
4162
}
@@ -52,4 +73,12 @@ android {
5273
}
5374
}
5475

76+
plugins.withId("org.jetbrains.kotlin.android") {
77+
kotlin {
78+
compilerOptions {
79+
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString())
80+
}
81+
}
82+
}
83+
5584
apply from: file("./user-agent.gradle")

‎packages/firebase_core/firebase_core/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.java‎

Lines changed: 0 additions & 303 deletions
This file was deleted.

‎packages/firebase_core/firebase_core/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebasePlugin.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import androidx.annotation.Keep;
77
import com.google.android.gms.tasks.Task;
88
import com.google.firebase.FirebaseApp;
9+
import java.util.HashMap;
910
import java.util.Map;
1011
import java.util.concurrent.ExecutorService;
1112
import java.util.concurrent.Executors;
@@ -15,6 +16,12 @@ public interface FlutterFirebasePlugin {
1516
// A shared ExecutorService used by all FlutterFire Plugins for their GMS Tasks.
1617
ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
1718

19+
/**
20+
* Custom auth domains keyed by Dart Firebase app name, set from {@code
21+
* FirebaseOptions.authDomain} during initializeApp. Read by firebase_auth.
22+
*/
23+
Map<String, String> customAuthDomain = new HashMap<>();
24+
1825
/**
1926
* FlutterFire plugins implementing FlutterFirebasePlugin must provide this method to provide it's
2027
* constants that are initialized during FirebaseCore.initializeApp in Dart.

0 commit comments

Comments
 (0)