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
375 stars 9 forks source link

Support KMP & Jetbrains compose multiplatform #110

Closed mr3y-the-programmer closed 1 month ago

mr3y-the-programmer commented 2 months ago

this PR expands the gradle plugin's support to make it work with compose multiplatform (at the very least android and jvm desktop targets should be supported now).

There are some breaking changes though, As usages of java File API in the core module have been migrated to okio, and java File API is exposed from some APIs' public surface, Therefore, those are affected by this change.

mr3y-the-programmer commented 2 months ago

~~I'm having some issues testing those changes locally by publishing the gradle plugin to mavenLocal() repository. Here is what I've tried so far:~~ - run .\gradlew publishToMavenLocal task - add mavenLocal() repository to pluginManagement {} block in settings.gradle.kts - add some sample multiplatform project with the following configuration in its build.gradle.kts file:

plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose") version libs.versions.compose.get()
    id("dev.shreyaspatil.compose-compiler-report-generator") version "1.3.1"
}

kotlin {
    jvm()
}

but I'm getting errors like these and I'm not sure how to deal with them:

An exception occurred applying plugin request [id: 'dev.shreyaspatil.compose-compiler-report-generator', version: '1.3.1']
> Failed to apply plugin 'dev.shreyaspatil.compose-compiler-report-generator'.
   > Could not create plugin of type 'ReportGenPlugin'.
      > Could not generate a decorated class for type ReportGenPlugin.
         > com/android/build/api/variant/AndroidComponentsExtension

maybe you can help me with this, as I'm not very familiar with testing gradle plugins locally?

mr3y-the-programmer commented 2 months ago

UPDATE: I managed to get samples working and test the plugin locally. I found a small issue which is about registering gradle tasks for jvm & multiplatform at the right time when their target info is made available(we're doing it correctly for android modules using onVariants{} callback), Currently tasks are registered way earlier than that, and as a result, a runtime exception is thrown while applying the plugin in a project. I'm still working on it.

mr3y-the-programmer commented 2 months ago

Found no issues so far after fixing those timing bugs.

I'm also thinking about pushing samples(multiplatform, android & desktop) to the repo to make it easier to test any changes right now or in the future & provide a rapid feedback loop but I'll probably do it in another PR to make changes easier to review and to keep this PR focused on one single topic, WDYT?

PatilShreyas commented 2 months ago

@mr3y-the-programmer That's great. I've not yet looked into the PR changes. Let me get back to you after taking a look. I won't be able to spend much time here, so please expect a delay

mr3y-the-programmer commented 2 months ago

Did the required modifications based on the recent comments, take your time and see if you've any other questions

mr3y-the-programmer commented 1 month ago

made the required changes and tested the plugin locally, I saw no regressions 🥳

PatilShreyas commented 1 month ago

made the required changes and tested the plugin locally, I saw no regressions 🥳

Cool, now change looks good @mr3y-the-programmer. Thanks for contributing and it's definitely gonna help multi-platform devs. Kudos 🎉

I'll merge it in a separate branch and will do some cleanup, doc update and will plan release in few days.