Skip to content

Commit 120c99d

Browse files
nav-navSpace Team
authored and
Space Team
committed
Fix ClassCastException in JPS statistics ad update log messages
#KT-63594 Fixed
1 parent 68f2618 commit 120c99d

File tree

1 file changed

+26
-13
lines changed
  • libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics

1 file changed

+26
-13
lines changed

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/KotlinBuildStatHandler.kt

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,24 +145,16 @@ class KotlinBuildStatHandler {
145145
// log?
146146
}
147147
}
148-
val taskNames = project.tasks.names.toList()
149148

150149
configurationTimeMetrics.put(NumericalMetrics.NUMBER_OF_SUBPROJECTS, 1)
150+
151+
151152
configurationTimeMetrics.put(
152153
BooleanMetrics.KOTLIN_KTS_USED,
153154
project.buildscript.sourceFile?.name?.endsWith(".kts") ?: false
154155
)
155-
configurationTimeMetrics.put(NumericalMetrics.GRADLE_NUMBER_OF_TASKS, taskNames.size.toLong())
156-
configurationTimeMetrics.put(
157-
NumericalMetrics.GRADLE_NUMBER_OF_UNCONFIGURED_TASKS,
158-
taskNames.count { name ->
159-
try {
160-
project.tasks.named(name).javaClass.name.contains("TaskCreatingProvider")
161-
} catch (_: Exception) {
162-
true
163-
}
164-
}.toLong()
165-
)
156+
157+
addTaskMetrics(project, configurationTimeMetrics)
166158

167159
if (project.name == "buildSrc") {
168160
configurationTimeMetrics.put(NumericalMetrics.BUILD_SRC_COUNT, 1)
@@ -171,10 +163,31 @@ class KotlinBuildStatHandler {
171163
}
172164
}
173165
sessionLogger.report(NumericalMetrics.STATISTICS_VISIT_ALL_PROJECTS_OVERHEAD, statisticOverhead)
174-
175166
return configurationTimeMetrics
176167
}
177168

169+
private fun addTaskMetrics(
170+
project: Project,
171+
configurationTimeMetrics: MetricContainer,
172+
) {
173+
try {
174+
val taskNames = project.tasks.names.toList()
175+
configurationTimeMetrics.put(NumericalMetrics.GRADLE_NUMBER_OF_TASKS, taskNames.size.toLong())
176+
configurationTimeMetrics.put(
177+
NumericalMetrics.GRADLE_NUMBER_OF_UNCONFIGURED_TASKS,
178+
taskNames.count { name ->
179+
try {
180+
project.tasks.named(name).javaClass.name.contains("TaskCreatingProvider")
181+
} catch (_: Exception) {
182+
true
183+
}
184+
}.toLong()
185+
)
186+
} catch (e: Exception) {
187+
//ignore exceptions for KT-62131.
188+
}
189+
}
190+
178191
private fun collectAppliedPluginsStatistics(
179192
project: Project,
180193
configurationTimeMetrics: MetricContainer,

0 commit comments

Comments
 (0)