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

Allow applying plugins with matching versions #19015

Merged
merged 13 commits into from
Dec 15, 2021

Conversation

octylFractal
Copy link
Member

@octylFractal octylFractal commented Nov 16, 2021

This resolves a long-standing issue with applying a plugin in a
subproject when that same plugin is already applied in the parent project.
Prior to this commit, you would need to avoid specifying a version,
which only became a true hassle with the introduction of plugins in the
version catalog, as shown in #18236.

This commit does not attempt to resolve conflicting versions, or inspect
the classpath for a plugin version. It only records the data that Gradle
knows for sure, and uses that to slightly relax this check. It is
sufficient to allow the issue mentioned prior to be resolved.

Replaces #18728
Fixes #18236

If accepted, I'll do the following:

  • Update documention
  • Document the feature in release notes

This resolves a long-standing issue with applying a plugin in a
subproject when that same plugin is already applied in the root project.
Prior to this commit, you would need to avoid specifying a version,
which only became a true hassle with the introduction of plugins in the
version catalog, as shown in #18236.

This commit does not attempt to resolve conflicting versions, or inspect
the classpath for a plugin version. It only records the data that Gradle
knows for sure, and uses that to slightly relax this check. It is
sufficient to allow the issue mentioned prior to be resolved.
@octylFractal octylFractal added this to the 7.4 RC1 milestone Nov 16, 2021
@octylFractal octylFractal self-assigned this Nov 16, 2021
@asodja
Copy link
Member

asodja commented Nov 17, 2021

Awesome that you found a way to collect applied plugin versions! I just left a comment regarding having a direct dependency on plugins in ClassLoaderScope.

One question: Could we add also functionality to define "withoutVersion" plugins in the Version catalog?
I think it might come in handy in some cases, e.g. so you can generate type-safe accessors for precompiled scripts, or when the plugin is added to the classpath through methods where we cannot collect versions.

@octylFractal
Copy link
Member Author

octylFractal commented Nov 29, 2021

Currently failing due to classcycle, see internal Slack. Resolved.

@octylFractal
Copy link
Member Author

@ljacomet @big-guy this is almost ready to go, but do you know if we have anywhere in the documentation that references the restriction on versions that this PR weakens? I didn't see any, so I didn't change the documentation, but maybe it's in an unusual place.

Copy link
Member

@ljacomet ljacomet left a comment

Choose a reason for hiding this comment

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

One question about the added state and a minor release note comment.

For documentation, have a look at https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl. Maybe adding a note there makes sense and linking to that section from https://docs.gradle.org/current/userguide/platforms.html#sec:plugins would improve the situation.

@big-guy big-guy added the @core Issue owned by GBT Core label Dec 9, 2021
octylFractal and others added 2 commits December 13, 2021 08:10
So it doesn't introduce overhead when loading from the configuration cache.
Copy link
Member

@ljacomet ljacomet left a comment

Choose a reason for hiding this comment

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

LGTM!

@octylFractal
Copy link
Member Author

@asodja re:

One question: Could we add also functionality to define "withoutVersion" plugins in the Version catalog? I think it might come in handy in some cases, e.g. so you can generate type-safe accessors for precompiled scripts, or when the plugin is added to the classpath through methods where we cannot collect versions.

I did not tackle this in this PR, we have decided to save it for later. I filed #19302 to track this.

@gradle gradle deleted a comment from octylFractal Dec 14, 2021
@bot-gradle
Copy link
Collaborator

OK, I've already triggered a build for you.

@bot-gradle
Copy link
Collaborator

Pre-tested commit build failed.

@octylFractal
Copy link
Member Author

@bot-gradle test and merge

@gradle gradle deleted a comment from blindpirate Dec 15, 2021
@bot-gradle
Copy link
Collaborator

OK, I've already triggered a build for you.

@bot-gradle bot-gradle merged commit 49bd75f into master Dec 15, 2021
@blindpirate blindpirate deleted the ot/feature/plugin-block-conflict-resolution branch December 16, 2021 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version Catalogs: Omit version for plugins already on the classpath
6 participants