Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prohibit BuildServiceProviders in configuration cache fingerprint#24099

Merged
bot-gradle merged 4 commits into
masterfrom
ml/22337/prohibit-providers-with-codec
Mar 3, 2023
Merged

Prohibit BuildServiceProviders in configuration cache fingerprint#24099
bot-gradle merged 4 commits into
masterfrom
ml/22337/prohibit-providers-with-codec

Conversation

@mlopatkin

Copy link
Copy Markdown
Member

Fixes #22337

@mlopatkin mlopatkin added this to the 8.1 RC1 milestone Mar 1, 2023
@mlopatkin mlopatkin requested a review from a team March 1, 2023 17:26
@mlopatkin mlopatkin requested a review from hythloda as a code owner March 1, 2023 17:26
@mlopatkin mlopatkin self-assigned this Mar 1, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 I think used at configuration time is too generic and it might become a source of confusion but I don't have a better suggestion right now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is possible to hit this without going through a ValueSource, but I might be missing something here, so I went with a generic term. "Fingerprinting" would be more precise, but we don't have it as a user-facing concept,AFAIK.

Custom ValueSource implementations may fail to serialize. Prior to this
commit, the failure was attributed to "Gradle runtime" which is
misleading. Now it is attributed to the build file or plugin that
produces the input.
The typical way to make something an input to the configuration is to
use the ValueSource, and then obtain its value at configuration time.
Gradle recomputes these ValueSources when checking if the configuration
cache is still valid. However, at this point not all build state is
restored, but only a subset of it. This subset is not enough to restore
BuildServices if these are used as ValueSource inputs.

Before Gradle was failing the build with rather cryptic "cannot find
project :" error, and only when running from the cache - the initial
storing build was fine, even with load-after-store.

With this commit, a special set of codecs is used to store the
fingerprinting data, in which the BuildServiceProviders are explicitly
not supported. This way we can detect the providers even in long mapping
chains.

We may revisit the decision and make it possible to use BuildServices in
the future, but it requires a large rewrite of the fingerprinting code.
This is unlikely to happen, as this thing is hard to get as
a configuration input anyway, so it is just-in-case.
@mlopatkin mlopatkin force-pushed the ml/22337/prohibit-providers-with-codec branch from 1aa8fb6 to ec99b69 Compare March 2, 2023 15:32
@mlopatkin mlopatkin requested a review from bamboo March 2, 2023 15:39
@mlopatkin

Copy link
Copy Markdown
Member Author

@bot-gradle test ACC

@bot-gradle

Copy link
Copy Markdown
Collaborator

I've triggered the following builds for you:

@bamboo bamboo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@mlopatkin

Copy link
Copy Markdown
Member Author

@bot-gradle test and merge

@gradle gradle deleted a comment from mlopatkin Mar 3, 2023
@bot-gradle

Copy link
Copy Markdown
Collaborator

I've triggered a build for you.

[[config_cache:not_yet_implemented:build_services_in_fingerprint]]
=== Using build services to invalidate the configuration cache

Currently, it is not possible to use a `BuildServiceProvider` or provider derived of it with `map` or `flatMap` as a parameter for the `ValueSource`, if the value of the `ValueSource` is accessed at configuration time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💄

Suggested change
Currently, it is not possible to use a `BuildServiceProvider` or provider derived of it with `map` or `flatMap` as a parameter for the `ValueSource`, if the value of the `ValueSource` is accessed at configuration time.
Currently, it is impossible to use a `BuildServiceProvider` or provider derived from it with `map` or `flatMap` as a parameter for the `ValueSource`, if the value of the `ValueSource` is accessed at configuration time.

=== Using build services to invalidate the configuration cache

Currently, it is not possible to use a `BuildServiceProvider` or provider derived of it with `map` or `flatMap` as a parameter for the `ValueSource`, if the value of the `ValueSource` is accessed at configuration time.
The same applies such `ValueSource` is obtained in a task that executes as part of configuration phase, for example tasks of the `buildSrc` build or included builds contributing plugins.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💄

Suggested change
The same applies such `ValueSource` is obtained in a task that executes as part of configuration phase, for example tasks of the `buildSrc` build or included builds contributing plugins.
The same applies such as `ValueSource` is obtained in a task that executes as part of the configuration phase, for example, tasks of the `buildSrc` build or included builds contributing plugins.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hythloda thank you for the review, I'll apply your suggestions in a follow-up PR.

Regarding this one, I missed a conjunction here, and intended to write "The same applies when such a ValueSource". Is it correct?

@bot-gradle bot-gradle merged commit 853747b into master Mar 3, 2023
@bot-gradle bot-gradle deleted the ml/22337/prohibit-providers-with-codec branch March 3, 2023 14:18
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 this pull request may close these issues.

Disallow BuildServices to be used as inputs to ValueSources obtained at configuration time

4 participants