[Gradle] Avoid accessing PropertiesProvider via rootProject
This way in the default setup, there are no reported problems with project isolation #KT-55164 Fixed #KT-52963 Fixed #KT-52625 In Progress
This commit is contained in:
committed by
Space Team
parent
61cac14ed7
commit
d7b446d20f
+2
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.build.report.metrics.BuildTime
|
||||
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults
|
||||
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
||||
import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord
|
||||
import org.jetbrains.kotlin.gradle.utils.isProjectIsolationEnabled
|
||||
import org.jetbrains.kotlin.statistics.metrics.NumericalMetrics
|
||||
import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -134,7 +135,7 @@ abstract class BuildMetricsService : BuildService<BuildServiceParameters.None>,
|
||||
}
|
||||
|
||||
//do not need to collect metrics if there aren't consumers for this data
|
||||
val reportingSettings = reportingSettings(project.rootProject)
|
||||
val reportingSettings = reportingSettings(project)
|
||||
if (reportingSettings.buildReportOutputs.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
+1
-1
@@ -305,7 +305,7 @@ abstract class BuildReportsService : BuildService<BuildReportsService.Parameters
|
||||
val serviceClass = BuildReportsService::class.java
|
||||
val serviceName = "${serviceClass.name}_${serviceClass.classLoader.hashCode()}"
|
||||
|
||||
val reportingSettings = reportingSettings(project.rootProject)
|
||||
val reportingSettings = reportingSettings(project)
|
||||
if (reportingSettings.buildReportOutputs.isEmpty()) {
|
||||
return null //no need to collect data
|
||||
}
|
||||
|
||||
+10
-3
@@ -9,10 +9,12 @@ import org.gradle.api.Project
|
||||
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
|
||||
import org.jetbrains.kotlin.gradle.utils.isProjectIsolationEnabled
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly
|
||||
import java.io.File
|
||||
|
||||
internal fun reportingSettings(rootProject: Project): ReportingSettings {
|
||||
val properties = PropertiesProvider(rootProject)
|
||||
internal fun reportingSettings(project: Project): ReportingSettings {
|
||||
val properties = PropertiesProvider(project)
|
||||
val buildReportOutputTypes = properties.buildReportOutputs.map {
|
||||
BuildReportType.values().firstOrNull { brt -> brt.name == it.trim().toUpperCaseAsciiOnly() }
|
||||
?: throw IllegalStateException("Unknown output type: $it")
|
||||
@@ -23,7 +25,12 @@ internal fun reportingSettings(rootProject: Project): ReportingSettings {
|
||||
else -> BuildReportMode.VERBOSE
|
||||
}
|
||||
val fileReportSettings = if (buildReportOutputTypes.contains(BuildReportType.FILE)) {
|
||||
val buildReportDir = properties.buildReportFileOutputDir ?: rootProject.buildDir.resolve("reports/kotlin-build")
|
||||
val buildReportDir = properties.buildReportFileOutputDir ?: (if (isProjectIsolationEnabled(project.gradle)) {
|
||||
// TODO: it's a workaround for KT-52963, should be reworked – KT-55763
|
||||
project.rootDir.resolve("build")
|
||||
} else {
|
||||
project.rootProject.buildDir
|
||||
}).resolve("reports/kotlin-build")
|
||||
val includeMetricsInReport = properties.buildReportMetrics || buildReportMode == BuildReportMode.VERBOSE
|
||||
FileReportSettings(buildReportDir = buildReportDir, includeMetricsInReport = includeMetricsInReport)
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -34,14 +34,14 @@ internal const val COMMON_MAIN_ELEMENTS_CONFIGURATION_NAME = "commonMainMetadata
|
||||
internal const val ALL_COMPILE_METADATA_CONFIGURATION_NAME = "allSourceSetsCompileDependenciesMetadata"
|
||||
|
||||
internal val Project.isKotlinGranularMetadataEnabled: Boolean
|
||||
get() = project.pm20ExtensionOrNull != null || with(PropertiesProvider(rootProject)) {
|
||||
get() = project.pm20ExtensionOrNull != null || with(PropertiesProvider(this)) {
|
||||
mppHierarchicalStructureByDefault || // then we want to use KLIB granular compilation & artifacts even if it's just commonMain
|
||||
hierarchicalStructureSupport ||
|
||||
enableGranularSourceSetsMetadata == true
|
||||
}
|
||||
|
||||
internal val Project.shouldCompileIntermediateSourceSetsToMetadata: Boolean
|
||||
get() = project.pm20ExtensionOrNull != null || with(PropertiesProvider(rootProject)) {
|
||||
get() = project.pm20ExtensionOrNull != null || with(PropertiesProvider(this)) {
|
||||
when {
|
||||
!hierarchicalStructureSupport && mppHierarchicalStructureByDefault -> false
|
||||
else -> true
|
||||
|
||||
Reference in New Issue
Block a user