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

Gradle configuration cache compatibility #346

Open
Vampire opened this issue Dec 11, 2020 · 6 comments
Open

Gradle configuration cache compatibility #346

Vampire opened this issue Dec 11, 2020 · 6 comments

Comments

@Vampire
Copy link
Contributor

Vampire commented Dec 11, 2020

The current version is not compatible with the new Gradle configuration cache as it for example modifies the version property at task execution time.

@Vampire
Copy link
Contributor Author

Vampire commented Feb 17, 2022

Any plans to update this?
The configuration cache is a really great feature even in its current state, but it cannot be used at all with this plugin applied due to the usage of taskGraph.afterTask which is forbidden.
If it were just tasks that are non-conforming, these could now be marked as incompatible with the configuration cache, but this listener usage is not fixable by downstream code. :-(

@Hillkorn
Copy link
Collaborator

Hillkorn commented May 31, 2022

Do I see it right that the alternative would be to use https://docs.gradle.org/6.9.2/javadoc/org/gradle/build/event/BuildEventsListenerRegistry.html which enforces the minimum required version to be 6.1 .
Otherwise we could add the cleanup in a separate task if we can get the state there somehow.

@Vampire
Copy link
Contributor Author

Vampire commented May 31, 2022

For the afterTask issue, yes, a build service registered as operation completion listener is usally the way to go.
Modifying the version at task execution time is a different problem.

@Vampire
Copy link
Contributor Author

Vampire commented Jul 5, 2023

Any news?
Now that the configuration cache is promoted to stable with Gradle 8.1, it would really be nice if it could be used.
Due to the afterTask usage a build using this plugin cannot use the configuration cache at all, except with dirty hacks like not applying the plugin if CC is enabled and requiring to disable the CC to release.

jonnybot0 added a commit to jonnybot0/gradle-release that referenced this issue Oct 16, 2023
@jonnybot0
Copy link

jonnybot0 commented Oct 16, 2023

I tried messing around with this in my fork. See main...jonnybot0:gradle-release:main. Main problem I'm running up against now is that I'm getting this error when running the tests:

org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin class 'net.researchgate.release.ReleasePlugin'.
//...
	at net.researchgate.release.SvnAdapterTests.setup(SvnAdapterTests.groovy:23)
Caused by: org.gradle.internal.service.ServiceCreationException: Cannot create service of type DefaultBuildEventsListenerRegistry using DefaultBuildEventsListenerRegistry constructor as required service of type BuildEventListenerFactory for parameter #1 is not available.

On researching that, it looks like this problem was fixed in Gradle 7.6 (I think). See
gradle/gradle#16774
gradle/gradle#21135

As such, fixing this would likely entail upgrading Gradle in the plugin.

There may be other workarounds, but a Gradle update seems the most straightforward. If the maintainers are open to that, I might be able to scare up a PR in that direction. I'd like some pointers on whether it should go all the way to, say, Gradle 8.0 or what, since I imagine breaking backwards compatibility would be a major release.

@tnielens
Copy link

tnielens commented May 8, 2024

@Hillkorn any interest in fixing this issue? @jonnybot0 seems on the right track with his CleanupBuildService. I'd be happy to help out. In my projects at work, the configuration cache works greatly and gradle-release is the last plugin not supporting it. We use this workaround:

// The gradle-release plugin runs gradle subprocesses. Checking only "release" isn't sufficient.
// https://github.com/researchgate/gradle-release/blob/main/src/main/groovy/net/researchgate/release/ReleasePlugin.groovy#L57
if (!gradle.startParameter.taskNames.toSet().intersect(["release", "runBuildTasks", "afterReleaseBuild"]).empty) {
    apply plugin: "net.researchgate.release"
    ...
}

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

No branches or pull requests

4 participants