Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle plugin does not work with Configuration Cache #28

Closed
jakoss opened this issue Feb 14, 2023 · 7 comments · Fixed by #107
Closed

Gradle plugin does not work with Configuration Cache #28

jakoss opened this issue Feb 14, 2023 · 7 comments · Fixed by #107
Labels
bug Something isn't working

Comments

@jakoss
Copy link

jakoss commented Feb 14, 2023

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 PatilShreyas added the bug Something isn't working label Feb 14, 2023
@PatilShreyas
Copy link
Owner

Fixed and released in v1.0.0-beta02

@jakoss
Copy link
Author

jakoss commented Feb 27, 2023

@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
Copy link
Owner

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 PatilShreyas reopened this Mar 7, 2023
@beigirad
Copy link

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

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

@aegis123
Copy link

aegis123 commented Nov 23, 2023

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
Copy link

Kyant0 commented Mar 26, 2024

When will it support Gradle configuration cache?

PatilShreyas added a commit that referenced this issue May 19, 2024
By taking projectDirectory as a task parameter removes dependency of project env when task is actually getting executed which can further support this plugin in project where configuration cache is enabled. See: #28 (comment)
@PatilShreyas
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants