Skip to content

Commit 833f1ca

Browse files
authored
chore(build): Enable and configure Compose Compiler reports (#4289)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
1 parent 9266caa commit 833f1ca

6 files changed

Lines changed: 52 additions & 27 deletions

File tree

build-logic/convention/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1919

2020
plugins {
2121
`kotlin-dsl`
22-
alias(libs.plugins.android.lint)
2322
alias(libs.plugins.spotless)
2423
alias(libs.plugins.detekt)
2524
}

build-logic/convention/src/main/kotlin/KmpLibraryComposeConventionPlugin.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ import org.gradle.kotlin.dsl.apply
2121
import org.gradle.kotlin.dsl.configure
2222
import org.jetbrains.compose.ComposeExtension
2323
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
24+
import org.meshtastic.buildlogic.configureComposeCompiler
2425
import org.meshtastic.buildlogic.libs
2526
import org.meshtastic.buildlogic.plugin
2627

2728
class KmpLibraryComposeConventionPlugin : Plugin<Project> {
2829
override fun apply(target: Project) {
2930
with(target) {
30-
apply(plugin = libs.plugin("compose-multiplatform").get().pluginId)
3131
apply(plugin = libs.plugin("compose-compiler").get().pluginId)
32+
apply(plugin = libs.plugin("compose-multiplatform").get().pluginId)
3233

3334
val compose = extensions.getByType(ComposeExtension::class.java)
3435
extensions.configure<KotlinMultiplatformExtension> {
@@ -38,6 +39,7 @@ class KmpLibraryComposeConventionPlugin : Plugin<Project> {
3839
api(compose.dependencies.components.resources)
3940
}
4041
}
42+
configureComposeCompiler()
4143
}
4244
}
4345
}

build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/AndroidCompose.kt

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ import com.android.build.api.dsl.ApplicationExtension
2121
import com.android.build.api.dsl.CommonExtension
2222
import com.android.build.api.dsl.LibraryExtension
2323
import org.gradle.api.Project
24-
import org.gradle.api.provider.Provider
25-
import org.gradle.kotlin.dsl.configure
2624
import org.gradle.kotlin.dsl.dependencies
27-
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
2825

2926
/**
3027
* Configure Compose-specific options
@@ -43,28 +40,9 @@ internal fun Project.configureAndroidCompose(
4340
"implementation"(libs.library("androidx-compose-runtime"))
4441
"runtimeOnly"(libs.library("androidx-compose-runtime-tracing"))
4542
"debugImplementation"(libs.library("androidx-compose-ui-tooling"))
46-
43+
4744
// Add Espresso explicitly to avoid version mismatch issues on newer Android versions
4845
"androidTestImplementation"(libs.library("androidx-test-espresso-core"))
4946
}
50-
51-
extensions.configure<ComposeCompilerGradlePluginExtension> {
52-
fun Provider<String>.onlyIfTrue() = flatMap { provider { it.takeIf(String::toBoolean) } }
53-
fun Provider<*>.relativeToRootProject(dir: String) = map {
54-
isolated.rootProject.projectDirectory
55-
.dir("build")
56-
.dir(projectDir.toRelativeString(rootDir))
57-
}.map { it.dir(dir) }
58-
59-
project.providers.gradleProperty("enableComposeCompilerMetrics").onlyIfTrue()
60-
.relativeToRootProject("compose-metrics")
61-
.let(metricsDestination::set)
62-
63-
project.providers.gradleProperty("enableComposeCompilerReports").onlyIfTrue()
64-
.relativeToRootProject("compose-reports")
65-
.let(reportsDestination::set)
66-
67-
stabilityConfigurationFiles
68-
.add(isolated.rootProject.projectDirectory.file("compose_compiler_config.conf"))
69-
}
47+
configureComposeCompiler()
7048
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2025 Meshtastic LLC
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.meshtastic.buildlogic
19+
20+
import org.gradle.api.Project
21+
import org.gradle.api.provider.Provider
22+
import org.gradle.kotlin.dsl.configure
23+
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
24+
25+
internal fun Project.configureComposeCompiler() {
26+
extensions.configure<ComposeCompilerGradlePluginExtension> {
27+
fun Provider<String>.onlyIfTrue() =
28+
flatMap { provider { it.takeIf(String::toBoolean) } }
29+
30+
fun Provider<*>.relativeToRootProject(dir: String) = map {
31+
isolated.rootProject.projectDirectory
32+
.dir("build")
33+
.dir(projectDir.toRelativeString(rootDir))
34+
}.map { it.dir(dir) }
35+
project.providers.gradleProperty("enableComposeCompilerMetrics").onlyIfTrue()
36+
.relativeToRootProject("compose-metrics").let(metricsDestination::set)
37+
project.providers.gradleProperty("enableComposeCompilerReports").onlyIfTrue()
38+
.relativeToRootProject("compose-reports").let(reportsDestination::set)
39+
stabilityConfigurationFiles.add(
40+
isolated.rootProject.projectDirectory.file("compose_compiler_config.conf"),
41+
)
42+
}
43+
}

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@ dependency.analysis.print.build.health=true
6363
ksp.incremental=true
6464
ksp.incremental.classpath=true
6565

66+
# Compose Compiler Reports
67+
enableComposeCompilerMetrics=true
68+
enableComposeCompilerReports=true
69+
6670
android.newDsl=false

gradle/gradle-daemon-jvm.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ff1d4fc92bcfc9d3
99
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/08ce182188ada0b93565cd9ca4a4ab32/redirect
1010
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3dc48436acf46a9c2958682158988183/redirect
1111
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d935bdb25150f4573137eb8176e8b4ec/redirect
12-
toolchainVendor=JETBRAINS
1312
toolchainVersion=21

0 commit comments

Comments
 (0)