@@ -11,11 +11,13 @@ import org.jetbrains.kotlin.build.report.HttpReportSettings
11
11
import org.jetbrains.kotlin.build.report.metrics.GradleBuildPerformanceMetric
12
12
import org.jetbrains.kotlin.build.report.metrics.GradleBuildTime
13
13
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
14
+ import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_FILE_DIR
14
15
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_SINGLE_FILE
15
16
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_HTTP_URL
16
17
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_JSON_DIR
17
18
import org.jetbrains.kotlin.gradle.plugin.internal.isProjectIsolationEnabled
18
19
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly
20
+ import java.io.File
19
21
20
22
private val availableMetrics = GradleBuildTime .values().map { it.name } + GradleBuildPerformanceMetric .values().map { it.name }
21
23
@@ -36,7 +38,10 @@ internal fun reportingSettings(project: Project): ReportingSettings {
36
38
else -> BuildReportMode .VERBOSE
37
39
}
38
40
val fileReportSettings = if (buildReportOutputTypes.contains(BuildReportType .FILE )) {
39
- val buildReportDir = properties.buildReportFileOutputDir ? : (if (project.isProjectIsolationEnabled) {
41
+ val buildReportDir = properties.buildReportFileOutputDir?.let {
42
+ validateFileName(it, KOTLIN_BUILD_REPORT_FILE_DIR )
43
+ File (it)
44
+ } ? : (if (project.isProjectIsolationEnabled) {
40
45
// TODO: it's a workaround for KT-52963, should be reworked – KT-55763
41
46
project.rootDir.resolve(" build" )
42
47
} else {
@@ -75,13 +80,17 @@ internal fun reportingSettings(project: Project): ReportingSettings {
75
80
}
76
81
77
82
val singleOutputFile = if (buildReportOutputTypes.contains(BuildReportType .SINGLE_FILE )) {
78
- properties.buildReportSingleFile
79
- ? : throw IllegalStateException (" Can't configure single file report: '$KOTLIN_BUILD_REPORT_SINGLE_FILE ' property is mandatory" )
83
+ properties.buildReportSingleFile?.let {
84
+ validateFileName(it, KOTLIN_BUILD_REPORT_SINGLE_FILE )
85
+ File (it)
86
+ } ? : throw IllegalStateException (" Can't configure single file report: '$KOTLIN_BUILD_REPORT_SINGLE_FILE ' property is mandatory" )
80
87
} else null
81
88
82
89
val jsonReportDir = if (buildReportOutputTypes.contains(BuildReportType .JSON )) {
83
- properties.buildReportJsonDir
84
- ? : throw IllegalStateException (" Can't configure json report: '$KOTLIN_BUILD_REPORT_JSON_DIR ' property is mandatory" )
90
+ properties.buildReportJsonDir?.let {
91
+ validateFileName(it, KOTLIN_BUILD_REPORT_JSON_DIR )
92
+ File (it)
93
+ } ? : throw IllegalStateException (" Can't configure json report: '$KOTLIN_BUILD_REPORT_JSON_DIR ' property is mandatory" )
85
94
} else null
86
95
87
96
return ReportingSettings (
@@ -98,4 +107,11 @@ internal fun reportingSettings(project: Project): ReportingSettings {
98
107
)
99
108
}
100
109
110
+ private fun validateFileName (fileName : String , propertyName : String ) {
111
+ if (fileName.isBlank()) {
112
+ throw IllegalStateException (" The property '$propertyName ' must not be empty. Please provide a valid value." )
113
+ }
114
+ }
115
+
116
+
101
117
0 commit comments