FirebaseTestLab-Android
FirebaseTestLab-Android copied to clipboard
Plugin doesn't work with Kotlin gradle scripts
I've been generally unsuccessful configuring this plugin with kts
gradle scripts. I believe it's due to the use of a Closure instead of an Action in the devices
method on FirebaseTestLabPluginExtension
For the moment, I've forked the plugin locally to make the following change in FirebaseTestLabPluginExtension
:
fun devices(action: NamedDomainObjectContainer<Device>.() -> Unit) { devices.action() }
this lets me configure the plugin like this in my build.gradle.kts
file:
firebaseTestLab {
keyFile = file("asdfasdf.json")
googleProjectId = "asdfasdf"
devices {
register("pixel") {
deviceIds = listOf("sailfish")
androidApiLevels = listOf(25)
locales = listOf("en")
}
}
}
I haven't tested to see if this breaks compatibility with groovy gradle scripts, but I'm open to helping out to reach a compatible solution.
You can try your changes using Jitpack
buildscript {
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
classpath "com.github.zbynek:FirebaseTestLab-Android:patch-1-SNAPSHOT"
}
}
This fails for me with Groovy
Could not find method mainDevice() for arguments [app_common_3mq6icw2x9sq2qcpsy2elmlde$_run_closure4$_closure13$_closure14@4cd9d2a0] on extension 'firebaseTestLab' of type com.appunite.firebasetestlabplugin.FirebaseTestLabPluginExtension.
for configuration
devices {
mainDevice {
deviceIds = ["Pixel2"]
androidApiLevels = [28]
timeout = 1800
isUseOrchestrator = true
environmentVariables = ["clearPackageData=true"]
}
}
Solution
val deviceName = "nexusEmulator"
firebaseTestLab {
keyFile = File("$projectDir/my-app-key.json") // TODO HOWTO github action secret?!
googleProjectId = if (startParameter.toLowerCase().contains("acc")) { "android-mobile-app-acc" } else { "android-mobile-app-prod" }
createDevice(deviceName) {
com.appunite.firebasetestlabplugin.model.Device(deviceName).also {
deviceIds = listOf("hammerhead")
androidApiLevels = listOf(23)
locales = listOf("nl", "en")
}
}
}