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

[Configuration cache] Using plugin in a Java project with configuration cache enabled gives unexpected warning #419

Closed
jjohannes opened this issue Jul 8, 2020 · 1 comment · Fixed by #448

Comments

@jjohannes
Copy link

This is a follow up issue to #408

If you apply the latest version of the protobuf plugin to a pure Java project like this (latest Gradle 6.6 nightly):

plugins {
  id 'java-library'
  id 'com.google.protobuf' version '0.8.13-SNAPSHOT'
}

And use the configurations cache

./gradlew assemble --configuration-cache

You'll get the following configuration cache warning:

value provider(?) failed to unpack provider
  fieldvariantName of com.google.protobuf.gradle.GenerateProtoTask
    task:Server-Protocol-Buffer:generateProto of type com.google.protobuf.gradle.GenerateProtoTask
      java.lang.IllegalStateException: variant should not be used in a Java project

This is because Gradle tries to read the variantName field which is backed by the variant property. The getter of that property then throws the "variant should not be used in a Java project" error.

I think this can be fixed by making variantName transient similar to how it was done for the backing variant field in #408. //cc @gavra0

@voidzcy
Copy link
Collaborator

voidzcy commented Jul 17, 2020

Are you interested in creating a PR for the fix?

@voidzcy voidzcy changed the title Using plugin in a Java project with configuration cache enabled gives unexpected warning [Configuration cache] Using plugin in a Java project with configuration cache enabled gives unexpected warning Oct 21, 2020
gavra0 added a commit to gavra0/protobuf-gradle-plugin that referenced this issue Nov 16, 2020
When configuration caching is enabled, all task
properties will be serialized, causing variantName
to be queried even for Java-only projects which throws
runtime exception. This PR completely removes that property
as it is required only during task configuration.

Fixes google#419.
gavra0 added a commit to gavra0/protobuf-gradle-plugin that referenced this issue Nov 16, 2020
When configuration caching is enabled, all task
properties will be serialized, causing variantName
to be queried even for Java-only projects which throws
runtime exception. This PR completely removes that property
as it is required only during task configuration.

Fixes google#419.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants