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 3 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
internal class SimctlListData(
val devicetypes: List<DeviceTypeData>,
val devicetypes: List<DeviceTypeData> = emptyList(),
val runtimes: List<RuntimeData>,
val devices: Map<String, List<DeviceData>>,
val pairs: Map<String, WatchAndPhonePairData>,
val pairs: Map<String, WatchAndPhonePairData> = emptyMap(),
)
@Serializable
internal class DeviceTypeData(
val name: String,
val minRuntimeVersion: Long,
val bundlePath: String,
val maxRuntimeVersion: Long,
val identifier: String,
val productFamily: String
val name: String? = null,
val minRuntimeVersion: Long? = null,
val bundlePath: String? = null,
val maxRuntimeVersion: Long? = null,
val identifier: String? = null,
val productFamily: String? = null
)
@Serializable
internal class RuntimeData(
val name: String,
val bundlePath: String,
val buildversion: String,
val runtimeRoot: String,
val name: String? = null,
val bundlePath: String? = null,
val buildversion: String? = null,
val runtimeRoot: String? = null,
val identifier: String,
val version: String,
val isAvailable: Boolean,
val isAvailable: Boolean? = null,
val supportedDeviceTypes: List<SupportedDeviceTypeData>
)
@Serializable
internal class SupportedDeviceTypeData(
val bundlePath: String,
val name: String,
val bundlePath: String? = null,
val name: String? = null,
val identifier: String,
val productFamily: String
val productFamily: String? = null
)
@Serializable
internal class DeviceData(
val name: String,
val availabilityError: String? = null,
val dataPath: String,
val dataPathSize: Long,
val logPath: String,
val dataPath: String? = null,
val dataPathSize: Long? = null,
val logPath: String? = null,
val udid: String,
val isAvailable: Boolean,
val deviceTypeIdentifier: String,
val isAvailable: Boolean? = null,
val deviceTypeIdentifier: String? = null,
val state: String,
)
@ -65,13 +65,13 @@ internal val DeviceData.booted: Boolean
@Serializable
internal class WatchAndPhonePairData(
val watch: DeviceInPairData,
val phone: DeviceInPairData
val watch: DeviceInPairData? = null,
val phone: DeviceInPairData? = null
)
@Serializable
internal class DeviceInPairData(
val name: String,
val udid: String,
val state: String,
val name: String? = null,
val udid: String? = null,
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,
)
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") {
dependsOn(taskSimulatorDeleteUnavailable)
onlyIf { getSimctlListData().devices.map { it.value }.flatten().none { it.name == deviceName } }
doFirst {
val availableRuntimes = getSimctlListData().runtimes.filter { runtime ->
@ -49,10 +66,10 @@ fun Project.registerSimulatorTasks(
}
val taskBootSimulator = tasks.composeIosTask<AbstractComposeIosTask>("iosSimulatorBoot$id") {
dependsOn(taskCreateSimulator)
onlyIf {
getSimctlListData().devices.map { it.value }.flatten().any { it.name == deviceName && it.booted.not() }
}
dependsOn(taskCreateSimulator)
doLast {
val device = getSimctlListData().devices.map { it.value }.flatten().firstOrNull { it.name == deviceName }
?: error("device '$deviceName' not found")

Loading…
Cancel
Save