Gradle configuration cache compatibility - #88
Open
ScoreUnder wants to merge 38 commits into
Open
Conversation
There's no way for gradle to know if it's "stale" or not, so this makes that explicit, and makes it always run when requested.
- Use lazy accessors and file collections where possible - Avoid eagerly resolving files at configuration time - Wire property over from extension to task
This means we don't accidentally make a property which captures it in a lambda.
- Lazily access them where possible - Wire them through from extension to task - Remove now-unused Util file resolution methods - Change missing file error to display all missing files
replaceAll is the regex one; replace still replaces all occurrences
Expanded out into a form which takes the information it needs without relying on Project.
Now that it's being used quite explicitly as a task input, probably best to be on guard for that.
Both encourage practices that are incompatible with configuration caching.
Author
|
Ideas for further work that I thought of while touching this code:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've tried to be conservative with the API breakage. I honestly doubt it will break any real users' code but it's still technically breaking in a few places:
NamedAdditionalFileis gone, equivalent isTypedFileCollectiongetNamedAdditionalFilesAsListis gone tooNamedDependencyContainerand inner classes (takes a different container type)ModrinthExtension(doesn't take a Project, not because it's especially problematic in and of itself but because I wanted to make sure people avoid accidentally capturing it in a lambda when adding new properties)TemporaryCreateVersion(doesn't take a Project)TaskModrinthSyncBodyis newly abstract, so can no longer be instantiated directly withnewThe standard usage of the DSL itself has not changed.
The central idea of this PR is to tear apart
ModrinthExtensionfrom its tasks. They live in separate worlds now. Once a task is realised, it should never refer to the project or theModrinthExtension. Therefore, we need to wire over the properties that each task uses, and we need to move the loader and game version auto-detection to the configuration phase rather than the task execution phase.Related inclusions, poke me if I need to remove them:
DependencySerializable. I don't think it's actually needed, but it's more technically correct for how we use it in tasks nowreplaceAll→replacefor newline conversion as the latter is faster and still replaces all occurrences@Nullablewith Jetbrains@Nullable(we had both in the code)I've only really tried it on the demo projects and on my personal project, so it might need more extensive testing if anyone's able to do that, but otherwise it seems to respect the configuration cache properly.
Fixes #66
Fixes #69
Fixes #75
See also #76
Will conflict with #84, #85