gmazzo/gradle-buildconfig-plugin

Generate `internal object` by default

JakeWharton opened this issue · 2 comments

I saw #27, but perhaps you would consider making the object have a visibility of internal. As of now, this plugin is hard/impossible to use in a library because it contributes to the public API surface. However, propagating build-time information into a library is a common need.

Thus, my thought is that by default the object could be declared internal by default with a Gradle extension property to change its visibility to public.

In general, public API should always be opt-in rather than opt-out. Kotlin got this wrong, but when you enable the explicit API mode they always force you to pick a visibility. The safest default is internal and then if someone wants to propagate this type into their public API for use in downstream modules they can either choose to make it public, or expose the values on their own types which forward to the BuildConfig.

Unfortunately, because it changes a default, this would probably necessitate a major version bump.

I found internalVisibility which is probably good enough.

I would consider switching the default long-term though.

Yes, please change the default and/or add an explicit public setting.

Also, putting internal on properties of an internal class is useless. In my non-generated code, I go with explicit public on members of internal classes just in case I ever decide to make the class public in the future.