[build][build-tools] drop kotlinx.serialization
This commit is contained in:
@@ -11,11 +11,16 @@ plugins {
|
||||
// We explicitly configure versions of plugins in settings.gradle.kts.
|
||||
// due to https://github.com/gradle/gradle/issues/1697.
|
||||
id("kotlin")
|
||||
id("kotlinx-serialization")
|
||||
groovy
|
||||
`java-gradle-plugin`
|
||||
}
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("com.google.code.gson:gson:2.8.6")
|
||||
}
|
||||
}
|
||||
|
||||
val rootProperties = Properties().apply {
|
||||
rootDir.resolve("../gradle.properties").reader().use(::load)
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import groovy.lang.Closure
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonConfiguration
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.process.ExecResult
|
||||
@@ -320,6 +318,8 @@ private fun sshExecutor(project: Project): ExecutorService = object : ExecutorSe
|
||||
}
|
||||
}
|
||||
|
||||
internal data class DeviceTarget(@Expose val name: String, @Expose val udid: String, @Expose val state: String, @Expose val type: String)
|
||||
|
||||
private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
private val xcProject = Paths.get(project.testOutputRoot, "launcher")
|
||||
|
||||
@@ -421,12 +421,10 @@ private fun deviceLauncher(project: Project) = object : ExecutorService {
|
||||
}
|
||||
return out.toString().run {
|
||||
check(isNotEmpty())
|
||||
@Serializable
|
||||
data class DeviceTarget(val name: String, val udid: String, val state: String, val type: String)
|
||||
split("\n")
|
||||
.filter { it.isNotEmpty() }
|
||||
.map { Json(JsonConfiguration.Stable.copy(ignoreUnknownKeys = true))
|
||||
.parse(DeviceTarget.serializer(), it)
|
||||
.map {
|
||||
gson.fromJson(it, DeviceTarget::class.java)
|
||||
}
|
||||
.first {
|
||||
it.type == "device" && deviceName?.run { this == it.name } ?: true
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.parse
|
||||
import kotlinx.serialization.stringify
|
||||
|
||||
import com.google.gson.annotations.*
|
||||
import com.google.gson.*
|
||||
import com.google.gson.stream.JsonReader
|
||||
import java.io.File
|
||||
import java.io.FileReader
|
||||
import java.io.PrintWriter
|
||||
|
||||
|
||||
@Serializable
|
||||
data class ExternalTestReport(val statistics: Statistics, val groups: List<KonanTestGroupReport>)
|
||||
data class ExternalTestReport(@Expose val statistics: Statistics, @Expose val groups: List<KonanTestGroupReport>)
|
||||
|
||||
@ImplicitReflectionSerializer
|
||||
fun saveReport(reportFileName: String, statistics: Statistics, groups:List<KonanTestGroupReport>){
|
||||
File(reportFileName).apply {
|
||||
parentFile.mkdirs()
|
||||
PrintWriter(this).use {
|
||||
it.append(Json.stringify(ExternalTestReport(statistics, groups)))
|
||||
it.append(gson.toJson(ExternalTestReport(statistics, groups)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ImplicitReflectionSerializer
|
||||
fun loadReport(reportFileName: String) : ExternalTestReport = FileReader(reportFileName).use {
|
||||
return@use Json.parse<ExternalTestReport>(it.readText())
|
||||
}
|
||||
internal val gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()!!
|
||||
fun loadReport(reportFileName: String) : ExternalTestReport = JsonReader(FileReader(reportFileName)).use {
|
||||
gson.fromJson(it, ExternalTestReport::class.java)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.gradle.api.Project
|
||||
|
||||
enum class TestStatus {
|
||||
@@ -12,12 +12,11 @@ enum class TestStatus {
|
||||
SKIPPED
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Statistics(
|
||||
var passed: Int = 0,
|
||||
var failed: Int = 0,
|
||||
var error: Int = 0,
|
||||
var skipped: Int = 0) {
|
||||
@Expose var passed: Int = 0,
|
||||
@Expose var failed: Int = 0,
|
||||
@Expose var error: Int = 0,
|
||||
@Expose var skipped: Int = 0) {
|
||||
|
||||
|
||||
fun pass(count: Int = 1) { passed += count }
|
||||
@@ -41,14 +40,12 @@ val Statistics.total: Int
|
||||
|
||||
class TestFailedException(msg:String) : RuntimeException(msg)
|
||||
|
||||
@Serializable
|
||||
data class KonanTestGroupReport(val name: String, val suites: List<KonanTestSuiteReport>)
|
||||
|
||||
@Serializable
|
||||
data class KonanTestSuiteReport(val name: String, val tests: List<KonanTestCaseReport>)
|
||||
data class KonanTestGroupReport(@Expose val name: String, val suites: List<KonanTestSuiteReport>)
|
||||
|
||||
@Serializable
|
||||
data class KonanTestCaseReport(val name: String, val status: TestStatus, val comment: String? = null)
|
||||
data class KonanTestSuiteReport(@Expose val name: String, val tests: List<KonanTestCaseReport>)
|
||||
|
||||
data class KonanTestCaseReport(@Expose val name: String, @Expose val status: TestStatus, @Expose val comment: String? = null)
|
||||
|
||||
class KonanTestSuiteReportEnvironment(val name: String, val project: Project, val statistics: Statistics) {
|
||||
private val tc = if (Tc.enabled) TeamCityTestPrinter(project) else null
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
import kotlinx.serialization.json.Json
|
||||
import com.google.gson.*
|
||||
import com.google.gson.annotations.*
|
||||
|
||||
|
||||
@Serializable
|
||||
data class LlvmCovReportFunction(
|
||||
val name: String,
|
||||
val count: Int,
|
||||
@@ -13,7 +11,6 @@ data class LlvmCovReportFunction(
|
||||
val filenames: List<String>
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LlvmCovReportSummary(
|
||||
val lines: LlvmCovReportStatistics,
|
||||
val functions: LlvmCovReportStatistics,
|
||||
@@ -27,35 +24,30 @@ data class LlvmCovReportSummary(
|
||||
* It's a bit complicated since every segment
|
||||
* is encoded not as dictionary, but as array of ints and bools.
|
||||
*/
|
||||
@Serializable
|
||||
data class LlvmCovReportFile(
|
||||
val filename: String,
|
||||
val summary: LlvmCovReportSummary
|
||||
@Expose val filename: String,
|
||||
@Expose val summary: LlvmCovReportSummary
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LlvmCovReportStatistics(
|
||||
val count: Int,
|
||||
val covered: Int,
|
||||
val percent: Double
|
||||
@Expose val count: Int,
|
||||
@Expose val covered: Int,
|
||||
@Expose val percent: Double
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LlvmCovReportData(
|
||||
val files: List<LlvmCovReportFile>,
|
||||
val functions: List<LlvmCovReportFunction>,
|
||||
val totals: LlvmCovReportSummary
|
||||
@Expose val files: List<LlvmCovReportFile>,
|
||||
@Expose val functions: List<LlvmCovReportFunction>,
|
||||
@Expose val totals: LlvmCovReportSummary
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LlvmCovReport(
|
||||
val version: String,
|
||||
val type: String,
|
||||
val data: List<LlvmCovReportData>
|
||||
@Expose val version: String,
|
||||
@Expose val type: String,
|
||||
@Expose val data: List<LlvmCovReportData>
|
||||
)
|
||||
|
||||
fun parseLlvmCovReport(llvmCovReport: String): LlvmCovReport =
|
||||
Json.nonstrict.parse(LlvmCovReport.serializer(), llvmCovReport)
|
||||
fun parseLlvmCovReport(llvmCovReport: String): LlvmCovReport = gson.fromJson(llvmCovReport, LlvmCovReport::class.java)
|
||||
|
||||
val LlvmCovReport.isValid
|
||||
get() = type == "llvm.coverage.json.export"
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import com.ullink.slack.simpleslackapi.impl.SlackSessionFactory
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
@@ -64,7 +63,6 @@ open class Reporter : DefaultTask() {
|
||||
@Input
|
||||
lateinit var reportHome: String
|
||||
|
||||
@ImplicitReflectionSerializer
|
||||
@TaskAction
|
||||
fun report() {
|
||||
|
||||
@@ -74,12 +72,14 @@ open class Reporter : DefaultTask() {
|
||||
"${reportJson.statistics.report}\n ${reportEpilogue()}"
|
||||
|
||||
project.logger.info(report)
|
||||
sendTextToSlack(report)
|
||||
if (doSlackSending())
|
||||
sendTextToSlack(report)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun DefaultTask.doSlackSending() = !project.hasProperty("build.reporter.noSlack")
|
||||
|| !project.property("build.reporter.noSlack").toString().toBoolean()
|
||||
|
||||
open class NightlyReporter: DefaultTask() {
|
||||
@Input
|
||||
lateinit var externalMacosReport:String
|
||||
@@ -88,7 +88,6 @@ open class NightlyReporter: DefaultTask() {
|
||||
@Input
|
||||
lateinit var externalWindowsReport:String
|
||||
|
||||
@ImplicitReflectionSerializer
|
||||
@TaskAction
|
||||
fun report() {
|
||||
val externalMacosJsonReport = loadReport("${project.rootDir.absolutePath}/$externalMacosReport")
|
||||
@@ -104,6 +103,7 @@ open class NightlyReporter: DefaultTask() {
|
||||
appendln(reportEpilogue())
|
||||
}
|
||||
project.logger.info(report)
|
||||
sendTextToSlack(report)
|
||||
if (doSlackSending())
|
||||
sendTextToSlack(report)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonConfiguration
|
||||
import com.google.gson.annotations.Expose
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.Xcode
|
||||
import kotlin.math.min
|
||||
@@ -25,9 +23,7 @@ private fun compareStringsAsVersions(version1: String, version2: String): Int {
|
||||
/**
|
||||
* Returns parsed output of `xcrun simctl list runtimes -j`.
|
||||
*/
|
||||
private fun Xcode.getSimulatorRuntimeDescriptors(): List<SimulatorRuntimeDescriptor> =
|
||||
Json(JsonConfiguration.Stable.copy(ignoreUnknownKeys = true, useArrayPolymorphism = true))
|
||||
.parse(ListRuntimesReport.serializer(), this.simulatorRuntimes).runtimes
|
||||
private fun Xcode.getSimulatorRuntimeDescriptors(): List<SimulatorRuntimeDescriptor> = gson.fromJson(simulatorRuntimes, ListRuntimesReport::class.java).runtimes
|
||||
|
||||
/**
|
||||
* Returns first available simulator runtime for [target] with at least [osMinVersion] OS version.
|
||||
@@ -45,21 +41,19 @@ fun Xcode.getLatestSimulatorRuntimeFor(target: KonanTarget, osMinVersion: String
|
||||
}
|
||||
|
||||
// Result of `xcrun simctl list runtimes -j`.
|
||||
@Serializable
|
||||
data class ListRuntimesReport(
|
||||
val runtimes: List<SimulatorRuntimeDescriptor>
|
||||
@Expose val runtimes: List<SimulatorRuntimeDescriptor>
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SimulatorRuntimeDescriptor(
|
||||
val version: String,
|
||||
@Expose val version: String,
|
||||
// bundlePath field may not exist in the old Xcode (prior to 10.3).
|
||||
val bundlePath: String? = null,
|
||||
val isAvailable: Boolean? = null,
|
||||
val availability: String? = null,
|
||||
val name: String,
|
||||
val identifier: String,
|
||||
val buildversion: String
|
||||
@Expose val bundlePath: String? = null,
|
||||
@Expose val isAvailable: Boolean? = null,
|
||||
@Expose val availability: String? = null,
|
||||
@Expose val name: String,
|
||||
@Expose val identifier: String,
|
||||
@Expose val buildversion: String
|
||||
) {
|
||||
/**
|
||||
* Different Xcode/macOS combinations give different fields that checks
|
||||
|
||||
Reference in New Issue
Block a user