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