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

Replace taskGraph.afterTask with an operation completion listener in Gradle 6.1+ #389

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

Vampire
Copy link
Contributor

@Vampire Vampire commented Feb 20, 2024

No description provided.

@yorlov
Copy link

yorlov commented Mar 26, 2024

Just to let you know, the plugin will not function on gradle 8.7 until this issue is rectified.

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Plugin 'net.researchgate.release': registration of listener on 'TaskExecutionGraph.afterTask' is unsupported
  See https://docs.gradle.org/8.6/userguide/configuration_cache.html#config_cache:requirements:build_listeners

@Vampire
Copy link
Contributor Author

Vampire commented Mar 27, 2024

You mean the plugin will not function with 8.x if you enable configuration cache, which is not different in 8.7 from earlier versions.

try {
createScmAdapter()
} catch (Exception ignored) {}
if (scmAdapter && extension.revertOnFail && project.file(extension.versionPropertyFile)?.exists()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (scmAdapter && extension.revertOnFail && project.file(extension.versionPropertyFile)?.exists()) {
if (scmAdapter && extension.revertOnFail.get() && project.file(extension.versionPropertyFile)?.exists()) {

Not sure what groovy does if we don't use the get() .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same it does currently, I just moved this existing code to a method.
But you are fully right of course, for Groovy it will just always be true as it is non-null.
This is already like that since switching to properties and not adapting this usage (and maybe others?)
One of the fun things you have because of using Groovy for the plugin. :-D

I now fixed it together with this PR.


abstract class ReleasePlugin extends PluginHelper implements Plugin<Project> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason for this change?
I see that you added

    @Inject
    abstract protected ObjectFactory getObjects();

    @Inject
    abstract protected ProviderFactory getProviders();

But I don't get the why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I use them at

objects.newInstance(BuildEventsListenerRegistryProvider)
and

Of course you can get those from project too, but that is bad / outdated practice and I didn't want to add to the existing ones but doing it right. :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see. Thanks for the explanation 👍

@Hillkorn Hillkorn merged commit 57651e2 into researchgate:main Jul 8, 2024
1 check passed
@Vampire Vampire deleted the afterTask-replacement branch July 8, 2024 13:58
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.

3 participants