Should I run <binary-compatibility-validator> agai...
# plugin-development
a
Should I run binary-compatibility-validator against the generated Kotlin DSL accessors for my plugin? It's often hard to know if when I make a change whether it will impact user's build scripts.
j
wouldn’t your tests fail?
a
First assume it's possible to generate an .api file for the accessors :)
j
I guess you can pass the
.gradle
relevant folders to the plugin
a
I think a quick way is to create a unit test that would use TestKit to set up a basic project, apply my plugin, then run
:kotlinDslAccessorsReport
, and dump the output into a file. Then I can run bcv against that file.
I could even run the test multiple times, 1. with no plugin applied, 2. without my plugin, but with any plugins my plugin reacts to, 3. and with my plugin plus the plugins my plugin reacts to. Then generate a diff of 3 - (2 + 1).
m
It's often hard to know if when I make a change whether it will impact user's build scripts.
For a Gradle plugin, I consider the extension to be the public API. You can make everything else internal
Java callers might still be able to call into your internal
Task
and
Plugin
implementation but you can move them to a
.internal
package to make this a bit more explicit
Or move them to a separate module that is an
implementation
dependency of your main module
a
I was thinking about the generated DSL accessors for tasks or Configurations, which can be based on a string
m
Right,
extensionName
is part of the public api too...
I tend to consider most configuration names internal. For this, just don't create them in
apply
and no generated accessor will be created
Or make them detached I guess
Not sure if detached configurations can contribute outgoingVariants though (but also outgoingVariants shouldn't has DSL accessors I think?)
Anyways, tldr; I found that having a mandatory top level block is very handy. Then only the name of your extension and maybe 1 or 2 configurations are public
Copy code
myextension {
  dostuff {}
}