sbt / sbt-osgi

sbt plugin for creating OSGi bundles
Apache License 2.0
47 stars 43 forks source link

Initialize Plugin introduced keys to zero like values in globalSettings #121

Closed mdedetrich closed 7 months ago

mdedetrich commented 7 months ago

Keys that are created/introduced by a plugin (i.e. OsgiKeys) should have their default values set in globalSettings with a zero like value otherwise it can cause issues with other sbt plugins/IDE's/editors.

eed3si9n commented 7 months ago

There's sbt plugin best practice called Provide default values in globalSettings, which states

If the default value of your settings or task does not transitively depend on a project-level settings (such as baseDirectory, compile, etc), define it in globalSettings.

What I should've added there is that such settings or tasks should not be specified in projectSettings. If you're eventually going to define the keys at project-level, then I don't know if makes much difference in defining a globally scoped one. For example,

requireCapability := Osgi.requireCapabilityTask(),

Given that Osgi.requireCapabilityTask() doesn't depend on any other settings, it would be most flexible if that definition remained at the global level, and unspecified anywhere else. That way the build user can override it either at ThisBuild level or at subproject level.

mdedetrich commented 7 months ago

What I should've added there is that such settings or tasks should not be specified in projectSettings. If you're eventually going to define the keys at project-level, then I don't know if makes much difference in defining a globally scoped one. For example,

Yup these nuances/peculiarities I think I understand by now, I just made a mistake and didn't realize that Osgi.requireCapabilityTask() didn't depend on any other setting/task.

@eed3si9n I have just updated the PR with this fix (I also made Osgi.requireCapabilityTask a lazy val since it was a zero arg def before), let me know if I missed anything else.