Add property validation for single file report
#KT-54335 Fixed #KT-54356 Fixed
This commit is contained in:
committed by
Space Team
parent
5e96bf0795
commit
512f7b3231
+28
-4
@@ -12,10 +12,7 @@ import org.jetbrains.kotlin.gradle.report.BuildReportType
|
|||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import java.io.ObjectInputStream
|
import java.io.ObjectInputStream
|
||||||
import kotlin.io.path.exists
|
import kotlin.io.path.*
|
||||||
import kotlin.io.path.listDirectoryEntries
|
|
||||||
import kotlin.io.path.name
|
|
||||||
import kotlin.io.path.notExists
|
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
@@ -97,6 +94,33 @@ class BuildReportsIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("validation")
|
||||||
|
@GradleTest
|
||||||
|
fun testSingleBuildMetricsFileValidation(gradleVersion: GradleVersion) {
|
||||||
|
project("simpleProject", gradleVersion) {
|
||||||
|
buildAndFail(
|
||||||
|
"compileKotlin", "-Pkotlin.build.report.output=SINGLE_FILE",
|
||||||
|
) {
|
||||||
|
assertOutputContains("Can't configure single file report: 'kotlin.build.report.single_file' property is mandatory")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("deprecated property")
|
||||||
|
@GradleTest
|
||||||
|
fun testDeprecatedAndNewSingleBuildMetricsFile(gradleVersion: GradleVersion) {
|
||||||
|
project("simpleProject", gradleVersion) {
|
||||||
|
val newMetricsPath = projectPath.resolve("metrics.bin")
|
||||||
|
val deprecatedMetricsPath = projectPath.resolve("deprecated_metrics.bin")
|
||||||
|
build(
|
||||||
|
"compileKotlin", "-Pkotlin.build.report.single_file=${newMetricsPath.pathString}",
|
||||||
|
"-Pkotlin.internal.single.build.metrics.file=${deprecatedMetricsPath.pathString}"
|
||||||
|
)
|
||||||
|
assertTrue { deprecatedMetricsPath.exists() }
|
||||||
|
assertTrue { newMetricsPath.notExists() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@DisplayName("smoke")
|
@DisplayName("smoke")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testSingleBuildMetricsFileSmoke(gradleVersion: GradleVersion) {
|
fun testSingleBuildMetricsFileSmoke(gradleVersion: GradleVersion) {
|
||||||
|
|||||||
+4
-4
@@ -59,7 +59,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
get() = this.property("kotlin.internal.single.build.metrics.file")?.let { File(it) }
|
get() = this.property("kotlin.internal.single.build.metrics.file")?.let { File(it) }
|
||||||
|
|
||||||
val buildReportSingleFile: File?
|
val buildReportSingleFile: File?
|
||||||
get() = this.property("kotlin.build.report.single_file")?.let { File(it) }
|
get() = this.property(PropertyNames.KOTLIN_BUILD_REPORT_SINGLE_FILE)?.let { File(it) }
|
||||||
|
|
||||||
@Deprecated(message = "Please use kotlin.build.report.output instead ")
|
@Deprecated(message = "Please use kotlin.build.report.output instead ")
|
||||||
val buildReportEnabled: Boolean
|
val buildReportEnabled: Boolean
|
||||||
@@ -86,10 +86,8 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
val buildReportFileOutputDir: File?
|
val buildReportFileOutputDir: File?
|
||||||
get() = this.property("kotlin.build.report.file.output_dir")?.let { File(it) }
|
get() = this.property("kotlin.build.report.file.output_dir")?.let { File(it) }
|
||||||
|
|
||||||
val buildReportHttpUrlProperty = "kotlin.build.report.http.url"
|
|
||||||
|
|
||||||
val buildReportHttpUrl: String?
|
val buildReportHttpUrl: String?
|
||||||
get() = this.property(buildReportHttpUrlProperty)
|
get() = this.property(PropertyNames.KOTLIN_BUILD_REPORT_HTTP_URL)
|
||||||
|
|
||||||
val buildReportHttpUser: String?
|
val buildReportHttpUser: String?
|
||||||
get() = this.property("kotlin.build.report.http.user")
|
get() = this.property("kotlin.build.report.http.user")
|
||||||
@@ -515,6 +513,8 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
const val KOTLIN_MPP_ENABLE_PLATFORM_INTEGER_COMMONIZATION = "kotlin.mpp.enablePlatformIntegerCommonization"
|
const val KOTLIN_MPP_ENABLE_PLATFORM_INTEGER_COMMONIZATION = "kotlin.mpp.enablePlatformIntegerCommonization"
|
||||||
const val KOTLIN_ABI_SNAPSHOT = "kotlin.incremental.classpath.snapshot.enabled"
|
const val KOTLIN_ABI_SNAPSHOT = "kotlin.incremental.classpath.snapshot.enabled"
|
||||||
const val KOTLIN_JS_KARMA_BROWSERS = "kotlin.js.browser.karma.browsers"
|
const val KOTLIN_JS_KARMA_BROWSERS = "kotlin.js.browser.karma.browsers"
|
||||||
|
const val KOTLIN_BUILD_REPORT_SINGLE_FILE = "kotlin.build.report.single_file"
|
||||||
|
const val KOTLIN_BUILD_REPORT_HTTP_URL = "kotlin.build.report.http.url"
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+9
-6
@@ -7,6 +7,8 @@ package org.jetbrains.kotlin.gradle.report
|
|||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_SINGLE_FILE
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_HTTP_URL
|
||||||
|
|
||||||
internal fun reportingSettings(rootProject: Project): ReportingSettings {
|
internal fun reportingSettings(rootProject: Project): ReportingSettings {
|
||||||
val properties = PropertiesProvider(rootProject)
|
val properties = PropertiesProvider(rootProject)
|
||||||
@@ -29,7 +31,7 @@ internal fun reportingSettings(rootProject: Project): ReportingSettings {
|
|||||||
|
|
||||||
val httpReportSettings = if (buildReportOutputTypes.contains(BuildReportType.HTTP)) {
|
val httpReportSettings = if (buildReportOutputTypes.contains(BuildReportType.HTTP)) {
|
||||||
val url = properties.buildReportHttpUrl
|
val url = properties.buildReportHttpUrl
|
||||||
?: throw IllegalStateException("Can't configure http report: '${properties.buildReportHttpUrlProperty}' property is mandatory")
|
?: throw IllegalStateException("Can't configure http report: '$KOTLIN_BUILD_REPORT_HTTP_URL' property is mandatory")
|
||||||
val password = properties.buildReportHttpPassword
|
val password = properties.buildReportHttpPassword
|
||||||
val user = properties.buildReportHttpUser
|
val user = properties.buildReportHttpUser
|
||||||
HttpReportSettings(url, password, user, properties.buildReportHttpVerboseEnvironment)
|
HttpReportSettings(url, password, user, properties.buildReportHttpVerboseEnvironment)
|
||||||
@@ -43,13 +45,14 @@ internal fun reportingSettings(rootProject: Project): ReportingSettings {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val singleOutputFile = if (buildReportOutputTypes.contains(BuildReportType.SINGLE_FILE)) {
|
||||||
|
properties.buildReportSingleFile
|
||||||
|
?: throw IllegalStateException("Can't configure single file report: '$KOTLIN_BUILD_REPORT_SINGLE_FILE' property is mandatory")
|
||||||
|
} else null
|
||||||
|
|
||||||
//temporary solution. support old property
|
//temporary solution. support old property
|
||||||
val oldSingleBuildMetric = properties.singleBuildMetricsFile?.also { buildReportOutputTypes.add(BuildReportType.SINGLE_FILE) }
|
val oldSingleBuildMetric = properties.singleBuildMetricsFile?.also { buildReportOutputTypes.add(BuildReportType.SINGLE_FILE) }
|
||||||
|
|
||||||
val singleOutputFile = if (buildReportOutputTypes.contains(BuildReportType.SINGLE_FILE)) {
|
|
||||||
properties.buildReportSingleFile ?: oldSingleBuildMetric
|
|
||||||
} else null
|
|
||||||
|
|
||||||
return ReportingSettings(
|
return ReportingSettings(
|
||||||
buildReportMode = buildReportMode,
|
buildReportMode = buildReportMode,
|
||||||
buildReportLabel = properties.buildReportLabel,
|
buildReportLabel = properties.buildReportLabel,
|
||||||
@@ -57,7 +60,7 @@ internal fun reportingSettings(rootProject: Project): ReportingSettings {
|
|||||||
httpReportSettings = httpReportSettings,
|
httpReportSettings = httpReportSettings,
|
||||||
buildScanReportSettings = buildScanSettings,
|
buildScanReportSettings = buildScanSettings,
|
||||||
buildReportOutputs = buildReportOutputTypes,
|
buildReportOutputs = buildReportOutputTypes,
|
||||||
singleOutputFile = singleOutputFile,
|
singleOutputFile = singleOutputFile ?: oldSingleBuildMetric,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user