compose-report-to-html icon indicating copy to clipboard operation
compose-report-to-html copied to clipboard

Gradle plugin does not work with Configuration Cache

Open jakoss opened this issue 2 years ago • 6 comments

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

jakoss avatar Feb 14 '23 11:02 jakoss

Fixed and released in v1.0.0-beta02

PatilShreyas avatar Feb 14 '23 14:02 PatilShreyas

@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)

jakoss avatar Feb 27 '23 11:02 jakoss

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!

PatilShreyas avatar Mar 07 '23 04:03 PatilShreyas

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

 ./gradlew :my_module:releaseComposeCompilerHtmlReport --rerun-tasks 

beigirad avatar Sep 18 '23 10:09 beigirad

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

aegis123 avatar Nov 23 '23 09:11 aegis123

When will it support Gradle configuration cache?

Kyant0 avatar Mar 26 '24 03:03 Kyant0

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

PatilShreyas avatar May 19 '24 09:05 PatilShreyas