Mendable
Jetpack Compose compiler metrics의 지표를 HTML로 볼 수 있게 해주는 CLI 툴
root 프로젝트의 build.gradle
에 아래 내용을 추가해준다.
groovy 라면 아래와 같이 설정해준다.
subprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
// Trigger this with:
// ./gradlew assembleRelease -PenableMultiModuleComposeReports=true --rerun-tasks
if (project.findProperty("enableMultiModuleComposeReports") == "true") {
freeCompilerArgs += ["-P", "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + rootProject.buildDir.absolutePath + "/compose_metrics/"]
freeCompilerArgs += ["-P", "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + rootProject.buildDir.absolutePath + "/compose_metrics/"]
}
}
}
}
kts라면 아래와 같이 설정해준다.
allprojects {
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile::class.java).configureEach {
kotlinOptions {
// Trigger this with:
// ./gradlew assembleRelease -PenableMultiModuleComposeReports=true --rerun-tasks
if (project.findProperty("enableMultiModuleComposeReports") == "true") {
freeCompilerArgs += listOf("-P", "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + rootProject.buildDir.absolutePath + "/compose_metrics/")
freeCompilerArgs += listOf("-P", "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + rootProject.buildDir.absolutePath + "/compose_metrics/")
}
}
}
}
위 설정은 Compose compiler가 metrics를 생성하고, 생성된 metrics를 rootProject/build/compose_metrics/
에 저장하도록 한다.
터미널에서 아래의 gradle 명령어를 실행한다.
./gradlew assembleRelease -PenableMultiModuleComposeReports=true --rerun-tasks
compose_metrics
폴더가 생성되고 그 안에 컴파일된 파일들이 저장된다.
rootProject/build/compose_metrics
경로에 mendable.jar를 저장한다.
mendable.jar는 아래의 경로에서 다운로드 받을 수 있다.
Releases - jaysuryat/mendable
mendable.jar가 저장된 경로에서 아래의 gradle 명령어를 실행한다.
java -jar mendable.jar
정상적으로 실행이 완료되면, index.html
파일이 생성된다.
개인 프로젝트에 mendable을 실행해보니, 36% stable이라는 처참한 결과가 나왔다.
전체 결과 뿐만 아니라, 친절하게 어떤 부분이 stable하지 못한지 알려준다.
대체로 파라미터에 Context, List, data class를 전달하는 것이 stable하지 못하다고 나와있었다.
전부 개선을 완료하고 다시 mendable을 실행해보았더니, 아래와 같은 결과가 나왔다.
Compose를 Stable하게 작성하고 싶다면 도움이 많이 되는 것 같다.