Print in the console report showing amount of tasks used K2
^KT-57736 Fixed
This commit is contained in:
committed by
Space Team
parent
847544d99c
commit
982a4fbda0
+73
@@ -30,6 +30,7 @@ class TryK2IT : KGPBaseTest() {
|
|||||||
|
|
||||||
build("--dry-run") {
|
build("--dry-run") {
|
||||||
assertOutputContainsExactTimes(EXPERIMENTAL_TRY_K2_WARNING_MESSAGE, 1)
|
assertOutputContainsExactTimes(EXPERIMENTAL_TRY_K2_WARNING_MESSAGE, 1)
|
||||||
|
assertOutputContains("No Kotlin compilation tasks have run")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,6 +54,78 @@ class TryK2IT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("JVM: build report is not printed")
|
||||||
|
@JvmGradlePluginTests
|
||||||
|
@GradleTest
|
||||||
|
fun buildReportNotPrinted(gradleVersion: GradleVersion) {
|
||||||
|
project(
|
||||||
|
"incrementalMultiproject",
|
||||||
|
gradleVersion,
|
||||||
|
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.WARN)
|
||||||
|
) {
|
||||||
|
build("build") {
|
||||||
|
assertOutputDoesNotContain(
|
||||||
|
"##### 'kotlin.experimental.tryK2' results (Kotlin/Native not checked) #####"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("JVM: report is printed at the end of the build")
|
||||||
|
@JvmGradlePluginTests
|
||||||
|
@GradleTest
|
||||||
|
fun buildReport(gradleVersion: GradleVersion) {
|
||||||
|
project(
|
||||||
|
"incrementalMultiproject",
|
||||||
|
gradleVersion,
|
||||||
|
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.WARN)
|
||||||
|
) {
|
||||||
|
enableTryK2()
|
||||||
|
|
||||||
|
build("build") {
|
||||||
|
assertOutputContains(
|
||||||
|
"""
|
||||||
|
|##### 'kotlin.experimental.tryK2' results (Kotlin/Native not checked) #####
|
||||||
|
|:lib:compileKotlin: 2.0 language version
|
||||||
|
|:app:compileKotlin: 2.0 language version
|
||||||
|
|##### 100% (2/2) tasks have compiled with Kotlin 2 #####
|
||||||
|
""".trimMargin().normalizeLineEndings()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("JVM: report is printed at the end of the build in case of compilation error")
|
||||||
|
@JvmGradlePluginTests
|
||||||
|
@GradleTest
|
||||||
|
fun buildReportOnCompilationError(gradleVersion: GradleVersion) {
|
||||||
|
project(
|
||||||
|
"incrementalMultiproject",
|
||||||
|
gradleVersion,
|
||||||
|
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.WARN)
|
||||||
|
) {
|
||||||
|
enableTryK2()
|
||||||
|
|
||||||
|
subProject("app").kotlinSourcesDir().resolve("foo/AA.kt").appendText(
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|ZZZZ
|
||||||
|
""".trimMargin()
|
||||||
|
)
|
||||||
|
|
||||||
|
buildAndFail("build", forceOutput = true) {
|
||||||
|
assertOutputContains(
|
||||||
|
"""
|
||||||
|
|##### 'kotlin.experimental.tryK2' results (Kotlin/Native not checked) #####
|
||||||
|
|:lib:compileKotlin: 2.0 language version
|
||||||
|
|:app:compileKotlin: 2.0 language version
|
||||||
|
|##### 100% (2/2) tasks have compiled with Kotlin 2 #####
|
||||||
|
""".trimMargin().normalizeLineEndings()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@DisplayName("MPP: language version default is changed to 2.0")
|
@DisplayName("MPP: language version default is changed to 2.0")
|
||||||
@MppGradlePluginTests
|
@MppGradlePluginTests
|
||||||
@GradleTest
|
@GradleTest
|
||||||
|
|||||||
+4
-2
@@ -11,9 +11,11 @@ enum class BuildReportType : Serializable {
|
|||||||
FILE,
|
FILE,
|
||||||
HTTP,
|
HTTP,
|
||||||
BUILD_SCAN,
|
BUILD_SCAN,
|
||||||
SINGLE_FILE;
|
SINGLE_FILE,
|
||||||
|
TRY_K2_CONSOLE,
|
||||||
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID: Long = 0
|
const val serialVersionUID: Long = 1L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+31
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.build.report.statistics.BuildFinishStatisticsData
|
|||||||
import org.jetbrains.kotlin.build.report.statistics.CompileStatisticsData
|
import org.jetbrains.kotlin.build.report.statistics.CompileStatisticsData
|
||||||
import org.jetbrains.kotlin.build.report.statistics.BuildStartParameters
|
import org.jetbrains.kotlin.build.report.statistics.BuildStartParameters
|
||||||
import org.jetbrains.kotlin.build.report.statistics.StatTag
|
import org.jetbrains.kotlin.build.report.statistics.StatTag
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||||
import org.jetbrains.kotlin.gradle.report.data.BuildExecutionData
|
import org.jetbrains.kotlin.gradle.report.data.BuildExecutionData
|
||||||
import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord
|
import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.measureTimeMillisWithResult
|
import org.jetbrains.kotlin.utils.addToStdlib.measureTimeMillisWithResult
|
||||||
@@ -92,6 +93,10 @@ class BuildReportsService {
|
|||||||
MetricsWriter(singleOutputFile.absoluteFile).process(buildData, log)
|
MetricsWriter(singleOutputFile.absoluteFile).process(buildData, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportingSettings.experimentalTryK2ConsoleOutput) {
|
||||||
|
reportTryK2ToConsole(buildData)
|
||||||
|
}
|
||||||
|
|
||||||
//It's expected that bad internet connection can cause a significant delay for big project
|
//It's expected that bad internet connection can cause a significant delay for big project
|
||||||
executorService.shutdown()
|
executorService.shutdown()
|
||||||
}
|
}
|
||||||
@@ -227,6 +232,32 @@ class BuildReportsService {
|
|||||||
customValues++
|
customValues++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun reportTryK2ToConsole(
|
||||||
|
data: BuildExecutionData
|
||||||
|
) {
|
||||||
|
val tasksData = data.buildOperationRecord
|
||||||
|
.filterIsInstance<TaskRecord>()
|
||||||
|
.filter {
|
||||||
|
// Filtering by only KGP tasks and by those that actually do compilation
|
||||||
|
it.isFromKotlinPlugin && it.kotlinLanguageVersion != null
|
||||||
|
}
|
||||||
|
log.warn("##### 'kotlin.experimental.tryK2' results (Kotlin/Native not checked) #####")
|
||||||
|
if (tasksData.isEmpty()) {
|
||||||
|
log.warn("No Kotlin compilation tasks have run")
|
||||||
|
log.warn("#####")
|
||||||
|
} else {
|
||||||
|
val tasksCountWithKotlin2 = tasksData.count {
|
||||||
|
it.kotlinLanguageVersion != null && it.kotlinLanguageVersion >= KotlinVersion.KOTLIN_2_0
|
||||||
|
}
|
||||||
|
val taskWithK2Percent = (tasksCountWithKotlin2 * 100) / tasksData.count()
|
||||||
|
val statsData = tasksData.map { it.path to it.kotlinLanguageVersion?.version }
|
||||||
|
statsData.forEach { record ->
|
||||||
|
log.warn("${record.first}: ${record.second} language version")
|
||||||
|
}
|
||||||
|
log.warn("##### $taskWithK2Percent% ($tasksCountWithKotlin2/${tasksData.count()}) tasks have compiled with Kotlin 2 #####")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun readableString(data: CompileStatisticsData): List<String> {
|
private fun readableString(data: CompileStatisticsData): List<String> {
|
||||||
val readableString = StringBuilder()
|
val readableString = StringBuilder()
|
||||||
if (data.nonIncrementalAttributes.isEmpty()) {
|
if (data.nonIncrementalAttributes.isEmpty()) {
|
||||||
|
|||||||
+1
@@ -18,6 +18,7 @@ data class ReportingSettings(
|
|||||||
val httpReportSettings: HttpReportSettings? = null,
|
val httpReportSettings: HttpReportSettings? = null,
|
||||||
val buildScanReportSettings: BuildScanSettings? = null,
|
val buildScanReportSettings: BuildScanSettings? = null,
|
||||||
val singleOutputFile: File? = null,
|
val singleOutputFile: File? = null,
|
||||||
|
val experimentalTryK2ConsoleOutput: Boolean = false,
|
||||||
val includeCompilerArguments: Boolean = false,
|
val includeCompilerArguments: Boolean = false,
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+10
-4
@@ -20,10 +20,15 @@ private val availableMetrics = BuildTime.values().map { it.name } + BuildPerform
|
|||||||
|
|
||||||
internal fun reportingSettings(project: Project): ReportingSettings {
|
internal fun reportingSettings(project: Project): ReportingSettings {
|
||||||
val properties = PropertiesProvider(project)
|
val properties = PropertiesProvider(project)
|
||||||
val buildReportOutputTypes = properties.buildReportOutputs.map {
|
val experimentalTryK2Enabled = properties.kotlinExperimentalTryK2.get()
|
||||||
BuildReportType.values().firstOrNull { brt -> brt.name == it.trim().toUpperCaseAsciiOnly() }
|
val buildReportOutputTypes = properties.buildReportOutputs
|
||||||
?: throw IllegalStateException("Unknown output type: $it")
|
.map {
|
||||||
}.toMutableList() //temporary solution. support old property
|
BuildReportType.values().firstOrNull { brt -> brt.name == it.trim().toUpperCaseAsciiOnly() }
|
||||||
|
?: throw IllegalStateException("Unknown output type: $it")
|
||||||
|
}
|
||||||
|
.plus(if (experimentalTryK2Enabled) listOf(BuildReportType.TRY_K2_CONSOLE) else emptyList())
|
||||||
|
.toMutableList() //temporary solution. support old property
|
||||||
|
|
||||||
val buildReportMode =
|
val buildReportMode =
|
||||||
when {
|
when {
|
||||||
buildReportOutputTypes.isEmpty() -> BuildReportMode.NONE
|
buildReportOutputTypes.isEmpty() -> BuildReportMode.NONE
|
||||||
@@ -82,6 +87,7 @@ internal fun reportingSettings(project: Project): ReportingSettings {
|
|||||||
buildReportOutputs = buildReportOutputTypes,
|
buildReportOutputs = buildReportOutputTypes,
|
||||||
singleOutputFile = singleOutputFile ?: oldSingleBuildMetric,
|
singleOutputFile = singleOutputFile ?: oldSingleBuildMetric,
|
||||||
includeCompilerArguments = properties.buildReportIncludeCompilerArguments,
|
includeCompilerArguments = properties.buildReportIncludeCompilerArguments,
|
||||||
|
experimentalTryK2ConsoleOutput = experimentalTryK2Enabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user