|
|
|
@ -19,8 +19,8 @@ package com.google.samples.apps.nowinandroid
|
|
|
|
|
import com.android.build.api.dsl.CommonExtension
|
|
|
|
|
import org.gradle.api.Project
|
|
|
|
|
import org.gradle.api.artifacts.VersionCatalogsExtension
|
|
|
|
|
import org.gradle.kotlin.dsl.dependencies
|
|
|
|
|
import org.gradle.kotlin.dsl.getByType
|
|
|
|
|
import java.io.File
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configure Compose-specific options
|
|
|
|
@ -38,5 +38,33 @@ internal fun Project.configureAndroidCompose(
|
|
|
|
|
composeOptions {
|
|
|
|
|
kotlinCompilerExtensionVersion = libs.findVersion("androidxCompose").get().toString()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kotlinOptions {
|
|
|
|
|
freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun Project.buildComposeMetricsParameters(): List<String> {
|
|
|
|
|
val metricParameters = mutableListOf<String>()
|
|
|
|
|
val enableMetricsProvider = project.providers.gradleProperty("enableComposeCompilerMetrics")
|
|
|
|
|
val enableMetrics = (enableMetricsProvider.orNull == "true")
|
|
|
|
|
if (enableMetrics) {
|
|
|
|
|
val metricsFolder = File(project.buildDir, "compose-metrics")
|
|
|
|
|
metricParameters.add("-P")
|
|
|
|
|
metricParameters.add(
|
|
|
|
|
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + metricsFolder.absolutePath
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val enableReportsProvider = project.providers.gradleProperty("enableComposeCompilerReports")
|
|
|
|
|
val enableReports = (enableReportsProvider.orNull == "true")
|
|
|
|
|
if (enableReports) {
|
|
|
|
|
val reportsFolder = File(project.buildDir, "compose-reports")
|
|
|
|
|
metricParameters.add("-P")
|
|
|
|
|
metricParameters.add(
|
|
|
|
|
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder.absolutePath
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
return metricParameters.toList()
|
|
|
|
|
}
|
|
|
|
|