Skip to content

Commit

Permalink
Configure compose options for compose modules
Browse files Browse the repository at this point in the history
Include the compose compiler and allow for passing a flag to enable
compose compiler reports.
  • Loading branch information
ahmedre committed Jun 2, 2024
1 parent c1a6dd6 commit 51312eb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.project
.settings
.kotlin
bin
gen
out
Expand Down
1 change: 1 addition & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ group = "com.quran.labs.androidquran.buildlogic"
dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.compose.compiler.gradlePlugin)
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@ package com.quran.labs.androidquran.buildutil

import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

fun CommonExtension<*, *, *, *, *, *>.applyComposeCommon(project: Project) {
buildFeatures.compose = true

project.withLibraries { libs ->
project.pluginManager.apply(libs.plugins.compose.compiler.get().pluginId)
}

project.extensions.configure<ComposeCompilerGradlePluginExtension> {
// https://issuetracker.google.com/issues/338842143
includeSourceInformation.set(true)
if (project.findProperty("composeCompilerReports") == "true") {
reportsDestination.set(project.layout.buildDirectory.get().asFile.resolve("compose_compiler"))
metricsDestination.set(project.layout.buildDirectory.get().asFile.resolve("compose_compiler"))
}
}

project.tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
freeCompilerArgs.addAll(
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-t
# build-logic
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
compose-compiler-gradlePlugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down

0 comments on commit 51312eb

Please sign in to comment.