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

Deprecate Convention concept #3425

Closed
bmuschko opened this issue Nov 8, 2017 · 12 comments
Closed

Deprecate Convention concept #3425

bmuschko opened this issue Nov 8, 2017 · 12 comments
Assignees
Labels
@core Issue owned by GBT Core in:configuration-model lazy api, domain object container
Milestone

Comments

@bmuschko
Copy link
Contributor

bmuschko commented Nov 8, 2017

Expected Behavior

The Convention concept should be deprecated for removal. A deprecation message is rendered when accessing the Convention through the Project API.

There's a usability issue here. Builds that use plugins configuring Gradle core plugins through Convention would always render the deprecation warning. Users and plugin authors cannot fix this by switching to a different API. Potentially this situation could be mitigated by implementing #3332. Alternatively, we should probably not render a deprecation warning at all.

Current Behavior

Conventions are used by Gradle core plugins. Users (more specifically plugin authors) have to use a cumbersome API to access convention values. For example:

JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
SourceSet main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);

Context

Convention is a legacy concept and has been effectively been replaced by extensions. Some Gradle core plugins still use this concept and should be migrated to extensions in the long run. Convention should be deprecated.

@bmuschko bmuschko added a:chore Minor issue without significant impact from:member in:core DO NOT USE labels Nov 8, 2017
@bmuschko
Copy link
Contributor Author

bmuschko commented Nov 9, 2017

@oehme Any idea on how to tackle the deprecation message issue described above? I don't actually expect a lot of users to create their own Convention. Maybe we can just not add a deprecation warning via the logger but instead just add a deprecation annotation to Project.getConvention().

@adammurdoch
Copy link
Member

We shouldn't do something ad hoc here for deprecation warnings. We should do whatever we do everywhere else (and make that "whatever" better).

@oehme
Copy link
Contributor

oehme commented Nov 10, 2017

We shouldn't be deprecating as long as they are the only way to do certain things, like defining custom source set types. Once that is done, we deprecate like everything else.

@JLLeitschuh
Copy link
Contributor

The Kotlin plugin defines a custom Configuration as well.

@grv87
Copy link
Contributor

grv87 commented Jul 31, 2018

I use Convention in my internal plugin, it provides nice DSL like

publicReleases = false
license = 'Apache-2.0'
tags = ['super', 'cool', 'project']

Replacing convention with extension I would have to use extra block in each build script, which is not nice.
I could use Groovy's metaClass as a replacement, but it would complicate setting up this new DSL.
So, if this is open for discussion, I would vote against removing Convention.

@oehme
Copy link
Contributor

oehme commented Aug 1, 2018

The point is exactly to have an extra block to reduce the clutter on the Project API. It makes it much clearer what you are configuring. Please never use Groovy metaclass, as that makes your plugin unusable from Kotlin.

@stale
Copy link

stale bot commented Jul 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Jul 13, 2020
@eskatos
Copy link
Member

eskatos commented Jul 15, 2020

I think we still want to do that

@JLLeitschuh JLLeitschuh removed the stale label Jul 15, 2020
@jjohannes jjohannes added the @core Issue owned by GBT Core label Mar 22, 2021
@jjohannes jjohannes added this to the 7.1 RC1 milestone Mar 22, 2021
@jjohannes jjohannes added in:configuration-model lazy api, domain object container and removed a:chore Minor issue without significant impact from:member in:core DO NOT USE labels Mar 23, 2021
@big-guy
Copy link
Member

big-guy commented Apr 1, 2021

@eskatos is this something that would be helpful with configuration caching?

@eskatos
Copy link
Member

eskatos commented Apr 1, 2021

@big-guy Not really. It is mostly helpful because extensions are a better replacement and for good Kotlin DSL support.

@donat donat self-assigned this Apr 19, 2021
@donat
Copy link
Member

donat commented Apr 19, 2021

We have the following conventions in the codebase:

  • ApplicationPluginConvention
  • JavaPluginConvention
  • BasePluginConvention
  • ProjectReportsPluginConvention
  • WarPluginConvention
  • AntlrSourceVirtualDirectory
  • ScalaSourceSet

Before we can deprecate the concept of conventions we need to make sure that properties stored in a convention are also available as an extension.

TODOs:

@ljacomet
Copy link
Member

🎉 This is in for Gradle 7.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@core Issue owned by GBT Core in:configuration-model lazy api, domain object container
Projects
None yet
Development

No branches or pull requests

10 participants