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

Gradle plugin does not work with Configuration Cache #28

Closed jakoss closed 3 months ago

jakoss commented 1 year ago

When trying to run the plugins tasks with configuration cache enabled i get this error:

Configuration cache state could not be cached: field `overrideFieldAccessor` of `java.lang.reflect.Field` bean found in field `overrideField` of `com.google.gson.internal.reflect.UnsafeReflectionAccessor` bean found in field `accessor` of `com.google.gson.internal.ConstructorConstructor` bean found in field `constructorConstructor` of `com.google.gson.Gson` bean found in field `mGson` of `com.android.build.gradle.internal.errors.MessageReceiverImpl` bean found in field `messageReceiverImpl` of `com.android.build.gradle.internal.errors.SyncIssueReporterImpl` bean found in field `issueReporter` of `com.android.build.gradle.internal.errors.DeprecationReporterImpl` bean found in field `deprecationReporter` of `com.android.build.gradle.internal.services.ProjectServices` bean found in field `projectServices` of `com.android.build.gradle.internal.tasks.factory.BootClasspathConfigImpl` bean found in field `value` of `kotlin.InitializedLazyImpl` bean found in field `bootClasspathConfig$delegate` of `com.android.build.gradle.internal.plugins.LibraryPlugin` bean found in field `this$0` of `com.android.build.gradle.internal.plugins.BasePlugin$dslServices$2$1` bean found in field `versionedSdkLoaderServiceProvider` of `com.android.build.gradle.internal.services.DslServicesImpl` bean found in field `dslServices` of `com.android.build.gradle.internal.dsl.CmakeOptions$AgpDecorated` bean found in field `__cmake` of `com.android.build.gradle.internal.dsl.ExternalNativeBuild$AgpDecorated` bean found in field `__externalNativeBuild` of `com.android.build.gradle.internal.dsl.LibraryExtensionImpl$AgpDecorated` bean found in field `dslExtension` of `com.android.build.gradle.internal.VariantManager` bean found in field `this$0` of `com.android.build.gradle.internal.VariantManager$createVariant$variantDslInfoBuilder$1` bean found in field `manifestParsingAllowed` of `com.android.build.gradle.internal.manifest.LazyManifestParser` bean found in field `dataProvider` of `com.android.build.gradle.internal.core.dsl.impl.LibraryVariantDslInfoImpl` bean found in field `dslInfo` of `com.android.build.api.component.impl.ConsumableCreationConfigImpl` bean found in field `value` of `kotlin.InitializedLazyImpl` bean found in field `delegate$delegate` of `com.android.build.api.variant.impl.LibraryVariantImpl` bean found in field `$variant` of `dev.shreyaspatil.composeCompilerMetricsGenerator.plugin.task.ComposeCompilerReportGenerateTaskKt$createComposeCompilerReportGenTaskForVariant$1` bean found in field `this$0` of `dev.shreyaspatil.composeCompilerMetricsGenerator.plugin.task.ComposeCompilerReportGenerateTaskKt$createComposeCompilerReportGenTaskForVariant$1$1` bean found in field `action` of `org.gradle.api.internal.AbstractTask$TaskActionWrapper` bean found in field `actions` of task `:core:ui:releaseComposeCompilerHtmlReport` of type `org.gradle.api.tasks.GradleBuild`: error writing value of type 'jdk.internal.reflect.UnsafeBooleanFieldAccessorImpl'
> Unable to make field protected final java.lang.reflect.Field jdk.internal.reflect.UnsafeFieldAccessorImpl.field accessible: module java.base does not "opens jdk.internal.reflect" to unnamed module @23a452a5
PatilShreyas commented 1 year ago

Fixed and released in v1.0.0-beta02

jakoss commented 1 year ago

@PatilShreyas This still seems to be an issue, but another one. On this branch i have configuration cache enabled: https://github.com/jakoss/AndroidArchitectureTemplate/blob/feature/compose-compiler-html-reports/gradle.properties

When i try to run ./gradlew :features:longaction:impl:releaseComposeCompilerHtmlReport it failes with message

Execution failed for task ':features:longaction:impl:releaseComposeCompilerHtmlReport'.
> Extension of type 'ComposeCompilerReportExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension]

When i disable configuration cache it works correctly (and the result is awesome)

PatilShreyas commented 1 year ago

Okay @jakoss. I guess when configuration cache is enabled, that tasks for generating reports are not maybe registered (because they're only registered after evaluating android build variants). But will definitely look into this. Thanks!

beigirad commented 11 months ago

I faced this issue and added --rerun-tasks argument until this issue solve.

 ./gradlew :my_module:releaseComposeCompilerHtmlReport --rerun-tasks 
aegis123 commented 9 months ago

I get the following error when I try to run the report task. The report gets generated but the build still fails.

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

1 problem was found reusing the configuration cache.
- Task `:app:FlavorNameComposeCompilerHtmlReport` of type `dev.shreyaspatil.composeCompilerMetricsGenerator.plugin.task.ComposeCompilerReportGenerateTask`: invocation of 'Task.project' at execution time is unsupported.
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution

See the complete report at file:///path/to/android/app/project/build/reports/configuration-cache/2v3qhuqw2flxdav2m5nx91uwg/1i6e9akx8fv7z68no5ctlacd3/configuration-cache-report.html
> Invocation of 'Task.project' by task ':app:FlavorNameComposeCompilerHtmlReport' at execution time is unsupported.

Think the fix should be removing the reference to project.layout and use some other accessor to get a correct location to get the report folder.

ComposeCompilerMetricsProvider.kt:80

use_project_during_execution

Kyant0 commented 5 months ago

When will it support Gradle configuration cache?

PatilShreyas commented 3 months ago

Released in v1.3.1 🚀. Try it out and let me know if it works or not.