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

Make plugin compatible with component metadata rules declared in settings.gradle #5

Closed
tbroyer opened this issue Apr 10, 2022 · 3 comments
Labels
a:bug Something isn't working
Milestone

Comments

@tbroyer
Copy link

tbroyer commented Apr 10, 2022

Similar to ljacomet/logging-capabilities#18 (which I merely copy/pasted here)

Currently, the plugin declares component metadata rules in the project, making it impossible to declare other rules in the settings.

I think the plugin should be split to have the component metadata rules in a settings plugin (actually, a plugin that could be applied either to a project or the settings, so projets that prefer project-level component metadata rules or have other plugins doing the same –or just because they want to leverage version catalogs and that cannot be done for settings plugins 🐔🥚– can continue using them).

Or maybe the plugin could detect if it's also been applied to the settings (not sure if it's possible though) so it can conditionally add the rules to the project?

Or maybe the plugin could detect when it's applied to the settings and automatically inject the capabilities resolution rules into all projects, so it could be applied to either (but not both), and wouldn't need to be split?

Or just make it applicable to either settings (without registering the capabilities resolution rules) and projects, and declare component metadata rules in both cases? but that would make it incompatible with rulesMode FAIL_ON_PROJECT_RULES, and would warn for any other rulesMode.

@jjohannes
Copy link
Member

Thank you for reporting this. I neglected the "component metadata rules in settings" for now, because I don't have much experience with it so far.

I like this idea:

a plugin that could be applied either to a project or the settings

So that users have the choice what fits best for their setup.

@jjohannes
Copy link
Member

Related note: If the rules are universal they should also apply for the dependencies of Gradle plugins. Or the dependencies users use in their own build logic.

Hence, the rules should also be applied to the plugin classpath:

buildscript {
    dependencies.components {
        ...
    }
}

This is only possible when this plugin is applied as a settings plugin.

@jjohannes jjohannes added the a:bug Something isn't working label Oct 27, 2022
@jjohannes jjohannes added this to the 1.0 milestone Oct 27, 2022
@jjohannes
Copy link
Member

In 1.0 it will be possible to apply the plugin in settings. The limitation will be that this only registers the rules but not the default resolution strategies, as these need to be explicitly defined on each configuration. But you can then resolve conflicts via resolutionStrategy.capabilitiesResolution { ... } in the places where needed.

jjohannes added a commit that referenced this issue Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants