Browse Source

Fix issue 2114. Gradle plugin with xcode 13.4. Add default null values for unused json params. (#2131)

pull/2140/head v1.2.0-alpha01-dev724
dima.avdeev 2 years ago committed by GitHub
parent
commit
586ec43100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 52
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlListData.kt
  2. 19
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt

52
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlListData.kt

@ -11,52 +11,52 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
internal class SimctlListData( internal class SimctlListData(
val devicetypes: List<DeviceTypeData>, val devicetypes: List<DeviceTypeData> = emptyList(),
val runtimes: List<RuntimeData>, val runtimes: List<RuntimeData>,
val devices: Map<String, List<DeviceData>>, val devices: Map<String, List<DeviceData>>,
val pairs: Map<String, WatchAndPhonePairData>, val pairs: Map<String, WatchAndPhonePairData> = emptyMap(),
) )
@Serializable @Serializable
internal class DeviceTypeData( internal class DeviceTypeData(
val name: String, val name: String? = null,
val minRuntimeVersion: Long, val minRuntimeVersion: Long? = null,
val bundlePath: String, val bundlePath: String? = null,
val maxRuntimeVersion: Long, val maxRuntimeVersion: Long? = null,
val identifier: String, val identifier: String? = null,
val productFamily: String val productFamily: String? = null
) )
@Serializable @Serializable
internal class RuntimeData( internal class RuntimeData(
val name: String, val name: String? = null,
val bundlePath: String, val bundlePath: String? = null,
val buildversion: String, val buildversion: String? = null,
val runtimeRoot: String, val runtimeRoot: String? = null,
val identifier: String, val identifier: String,
val version: String, val version: String,
val isAvailable: Boolean, val isAvailable: Boolean? = null,
val supportedDeviceTypes: List<SupportedDeviceTypeData> val supportedDeviceTypes: List<SupportedDeviceTypeData>
) )
@Serializable @Serializable
internal class SupportedDeviceTypeData( internal class SupportedDeviceTypeData(
val bundlePath: String, val bundlePath: String? = null,
val name: String, val name: String? = null,
val identifier: String, val identifier: String,
val productFamily: String val productFamily: String? = null
) )
@Serializable @Serializable
internal class DeviceData( internal class DeviceData(
val name: String, val name: String,
val availabilityError: String? = null, val availabilityError: String? = null,
val dataPath: String, val dataPath: String? = null,
val dataPathSize: Long, val dataPathSize: Long? = null,
val logPath: String, val logPath: String? = null,
val udid: String, val udid: String,
val isAvailable: Boolean, val isAvailable: Boolean? = null,
val deviceTypeIdentifier: String, val deviceTypeIdentifier: String? = null,
val state: String, val state: String,
) )
@ -65,13 +65,13 @@ internal val DeviceData.booted: Boolean
@Serializable @Serializable
internal class WatchAndPhonePairData( internal class WatchAndPhonePairData(
val watch: DeviceInPairData, val watch: DeviceInPairData? = null,
val phone: DeviceInPairData val phone: DeviceInPairData? = null
) )
@Serializable @Serializable
internal class DeviceInPairData( internal class DeviceInPairData(
val name: String, val name: String? = null,
val udid: String, val udid: String? = null,
val state: String, val state: String? = null,
) )

19
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt

@ -34,7 +34,24 @@ fun Project.registerSimulatorTasks(
taskInstallXcodeGen = taskInstallXcodeGen, taskInstallXcodeGen = taskInstallXcodeGen,
) )
val taskSimulatorDeleteUnavailable = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorDeleteUnavailable$id") {
val condition = { device: DeviceData -> device.name == deviceName && device.state.contains("unavailable") }
onlyIf {
getSimctlListData().devices.map { it.value }.flatten().any(condition)
}
doLast {
val device = getSimctlListData().devices.map { it.value }.flatten().first(condition)
runExternalTool(
MacUtils.xcrun,
listOf("simctl", "delete", device.udid)
)
}
}
val taskCreateSimulator = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorCreate$id") { val taskCreateSimulator = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorCreate$id") {
dependsOn(taskSimulatorDeleteUnavailable)
onlyIf { getSimctlListData().devices.map { it.value }.flatten().none { it.name == deviceName } } onlyIf { getSimctlListData().devices.map { it.value }.flatten().none { it.name == deviceName } }
doFirst { doFirst {
val availableRuntimes = getSimctlListData().runtimes.filter { runtime -> val availableRuntimes = getSimctlListData().runtimes.filter { runtime ->
@ -49,10 +66,10 @@ fun Project.registerSimulatorTasks(
} }
val taskBootSimulator = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorBoot$id") { val taskBootSimulator = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorBoot$id") {
dependsOn(taskCreateSimulator)
onlyIf { onlyIf {
getSimctlListData().devices.map { it.value }.flatten().any { it.name == deviceName && it.booted.not() } getSimctlListData().devices.map { it.value }.flatten().any { it.name == deviceName && it.booted.not() }
} }
dependsOn(taskCreateSimulator)
doLast { doLast {
val device = getSimctlListData().devices.map { it.value }.flatten().firstOrNull { it.name == deviceName } val device = getSimctlListData().devices.map { it.value }.flatten().firstOrNull { it.name == deviceName }
?: error("device '$deviceName' not found") ?: error("device '$deviceName' not found")

Loading…
Cancel
Save