Darkhax / CurseForgeGradle

A Gradle plugin for uploading files to CurseForge.
GNU Lesser General Public License v2.1
28 stars 7 forks source link

Add support for lazy configuration and config-cache #26

Closed marchermans closed 3 months ago

marchermans commented 3 months ago

This PR adds support for the configuration cache when publishing.

When the plugins task is currently used in a build that has the configuration cache enabled then the following error gets thrown: https://gist.github.com/marchermans/f4c08fefb1f38ab7efcdfee69384ce2b, as the error states this is because the task implementation does two things: 1) The version detector holds a reference to the project in a field 2) The task action calls for the project during execution, which is not supported when the configuration cache is used, because project configuration has not necessarily run.

To prevent these problems the VersionDetector now uses a lazy approach the detect the relevant version numbers (using Providers, or withId) to make sure it does not need to store a project for later configuration.

Secondly we now inject the ObjectFactory into the Task via @Inject and inject it directly into the GameVersions object, additionally we also pre-calculate the project displayname, which is during project evaluation already read-only, and as such can be trivially retrieved during task construction.

marchermans commented 3 months ago

This implements the same goals as #23, but without breaking changes.

Darkhax commented 3 months ago

This looks good to me, you're right that some of the code is weird but I think it's fine given the context. Has @pupnewfster had a chance to review this? I want to make sure that this fully meets her requirements as well.

pupnewfster commented 3 months ago

Assuming it does support the config cache, it should fully meet my requirements. I trust that orion knows a lot more than me about how to beat gradle into submission (which is likely how he was able to figure out how to get the version detecter working with it)