-
Notifications
You must be signed in to change notification settings - Fork 7
Make gradle-revapi configuration cache friendly
#13
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
base: main
Are you sure you want to change the base?
Conversation
gradle-revapi configuration cache friendly
| getProject().getObjects().property(Justification.class); | ||
|
|
||
| public RevapiAcceptBreakTask() { | ||
| getOutputs().upToDateWhen(_ignored -> false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to doNotTrackState in RevapiPlugin.java
| } | ||
|
|
||
| private GroupNameVersion oldGroupNameVersion() { | ||
| return getProject().getExtensions().getByType(RevapiExtension.class).oldGroupNameVersion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the use of getProject that was breaking configuration cache the rest of the changes are just about converting to an abstract class - can just remove this if we want a minimum PR
| analysisResultsFile.getAsFile().get()), | ||
| getAnalysisResultsFile().getAsFile().get()), | ||
| revapiIgnores(), | ||
| ConjureProjectFilters.forProject(getProject()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the use of getProject that was breaking configuration cache the rest of the changes are just about converting to an abstract class - can just remove this if we want a minimum PR
| private final Provider<GroupAndName> oldGroupAndName; | ||
|
|
||
| @Nested | ||
| protected abstract GitVersionUtils getGitVersionUtils(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made GitVersionUtils injectable as I think it is a bit cleaner but we could instead keep previousGitTags static and just pass in the dir and provider factory if we think that is tidier
| getProject() | ||
| .getTasks() | ||
| .withType(RevapiAcceptBreakTask.class) | ||
| .getByName(RevapiPlugin.ACCEPT_BREAK_TASK_NAME) | ||
| .getPath()); | ||
| templateData.put("acceptBreakTask", getAcceptAllBreaksTaskPath().get()); | ||
| templateData.put( | ||
| "acceptAllBreaksProjectTask", | ||
| getProject() | ||
| .getTasks() | ||
| .withType(RevapiAcceptAllBreaksTask.class) | ||
| .getByName(RevapiPlugin.ACCEPT_ALL_BREAKS_TASK_NAME) | ||
| .getPath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the bad use of getProject similarly the other changes are all about making it abstract can just do this bit if we prefer
| } | ||
|
|
||
| private GroupNameVersion oldGroupNameVersion() { | ||
| return getProject().getExtensions().getByType(RevapiExtension.class).oldGroupNameVersion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as previous this is the actual call to getProject that break configuration cache other changes are about making abstract
| import spock.util.environment.RestoreSystemProperties | ||
|
|
||
| class RevapiSpec extends IntegrationSpec { | ||
| class RevapiSpec extends ConfigurationCacheSpec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConfigurationCacheSpec is built on IntegrationTestKitSpec so runTask now returns a BuildResult most of the changes here are focused on converting to using BuildResult
|
|
||
| def setup() { | ||
| git = new Git(projectDir) | ||
| System.setProperty("ignoreDeprecations", "true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to build.gradle
| assert buildResult.task(':revapi').outcome == TaskOutcome.SKIPPED | ||
| } | ||
|
|
||
| def 'when the previous git tag has failed to publish, it will look back up to a further git tag'() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails on main not sure if it should be @Ignore?
Before this PR
gradle-revapihad a range of issues making it not configuration cache friendly:project.execto runGitcommandsTask.projectwithinConjureProjectFilters,RevapiAcceptBreakTask,RevapiAnalyzeTask,RevapiReportTaskandRevapiVersionOverrideTaskAfter this PR
Converted
GitVersionUtilsto a manage type so it can be injected via@Nestedand switched to the configuration cache friendlyProviderFactory.execConverted
ConjureProjectFilters,RevapiAcceptBreakTask,RevapiAnalyzeTask,RevapiReportTaskandRevapiVersionOverrideTaskto abstract classes and removed theTask.projectcalls by passing in the needed fields as inputsAdded the
gradle-plugin-testingplugin and usedConfigurationCacheSpecto allowRevapiSpecto test configuration cache issues==COMMIT_MSG==
Make
gradle-revapiconfiguration cache friendly==COMMIT_MSG==
Possible downsides?