Skip to content

Commit

Permalink
Merge pull request #417 from skydoves/plugin/stability-path
Browse files Browse the repository at this point in the history
Configure Compose stability path files
  • Loading branch information
skydoves authored Jan 25, 2024
2 parents 4abe91a + 40677ba commit ca0759d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal fun Project.configureAndroidCompose(
}

kotlinOptions {
freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
freeCompilerArgs += buildComposeMetricsParameters() + configureComposeStabilityPath()
}

packaging {
Expand All @@ -63,23 +63,35 @@ internal fun Project.configureAndroidCompose(
private fun Project.buildComposeMetricsParameters(): List<String> {
val metricParameters = mutableListOf<String>()
val enableMetricsProvider = project.providers.gradleProperty("enableComposeCompilerMetrics")
val relativePath = projectDir.relativeTo(rootDir)
val buildDir = layout.buildDirectory.get().asFile
val enableMetrics = (enableMetricsProvider.orNull == "true")
if (enableMetrics) {
val metricsFolder = File(project.buildDir, "compose-metrics")
val metricsFolder = buildDir.resolve("compose-metrics").resolve(relativePath)
metricParameters.add("-P")
metricParameters.add(
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${metricsFolder.absolutePath}/compose_metrics"
"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")
val reportsFolder = buildDir.resolve("compose-reports").resolve(relativePath)
metricParameters.add("-P")
metricParameters.add(
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${reportsFolder.absolutePath}/compose_metrics"
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder.absolutePath
)
}
return metricParameters.toList()
}

private fun Project.configureComposeStabilityPath(): List<String> {
val metricParameters = mutableListOf<String>()
val stabilityConfigurationFile = rootDir.resolve("compose_compiler_config.conf")
metricParameters.add("-P")
metricParameters.add(
"plugin:androidx.compose.compiler.plugins.kotlin:stabilityConfigurationPath=" + stabilityConfigurationFile.absolutePath
)
return metricParameters.toList()
}
2 changes: 2 additions & 0 deletions compose_compiler_config.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kotlin.collections.List
coil.request.ImageRequest

0 comments on commit ca0759d

Please sign in to comment.