PatilShreyas / compose-report-to-html

A utility (Gradle Plugin + CLI) to convert Jetpack Compose compiler metrics and reports to beautified HTML page.
https://patilshreyas.github.io/compose-report-to-html/
MIT License
389 stars 9 forks source link

Gradle plugin doesn't work with Compose Multiplatform 1.5.0-beta02 #73

Closed StefanOltmann closed 2 months ago

StefanOltmann commented 1 year ago

I tried to apply it to Compose Multiplatform 1.5.0-beta02 and got this:

An exception occurred applying plugin request [id: 'org.jetbrains.compose', version: '1.5.0-beta02']
> Failed to apply plugin 'org.jetbrains.compose'.
   > Shared build service 'org.jetbrains.compose.ComposeMultiplatformBuildService' has unexpected type: org.jetbrains.compose.ComposeMultiplatformBuildService$Inject
StefanOltmann commented 1 year ago

Okay, downgrading to 1.4.3 it doesn't work with Multiplatform at all. If I specify it in my android module, this does not help, too.

Please make it compatible with Multiplatform

PatilShreyas commented 1 year ago

Thanks for reporting. Will definitely add a support will update here

PatilShreyas commented 1 year ago

Actually currently it's android specific only

mikolajefento commented 1 year ago

For now You can use the CLI version. To make compose compiler metrics work with compose multiplatform you need to add something like this to your root build.gradle.kts file:

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/")
            }
        }
    }
}

Then you can use CLI version pointing input path to "<YOUR_PROJECT_PATH>\build\compose_metrics

StefanOltmann commented 1 year ago

Thank you! That worked, I got my report. Awesome!

So it looks like Compose Multiplatform support out of the box shouldn't be too far away. :)

PatilShreyas commented 1 year ago

@mikolajefento thanks for the quick remedy.

@StefanOltmann yep, it's just that we'll need to create a plugin variant for multiplatform and I guess we'll be able to do it.

mr3y-the-programmer commented 3 months ago

Hi @PatilShreyas I've initial implementation here #110 that addresses this issue and can make the plugin work with compose multiplatform, I need to do some more testing. but take a look at the PR and spot any potential issues or something that can be improved, I'm waiting for your review

PatilShreyas commented 2 months ago

Fixed and released in v1.4.0. Thanks @mr3y-the-programmer for the contribution