It sounds more and more like adding .kt
plugins in your buildSrc
is just asking for trouble - you miss the magic you get with .kts
and you don’t get the benefits of being discovered and loaded through traditional means (like a maven repo).
I don’t think I can follow.
The only differences are the syntax.
The precompiled script plugins are basically just syntactic sugar over a normal binary plugin with the ID derived from package and filename.
But other than that, they should behave identical.
In the non-trivial build scripts this is drawn from, stuff does happen in the apply()
method, mostly creating extension objects and setting default values, but the plugins are largely a file that contains a bunch of task classes…
No, the plugin is not a file that contains task classes.
The plugin happens to be stored in the same source file as those task classes, but they are independent of them, at least technically.
Or rather not more dependent than any other class in the same project.
You can still apply the plugin by type or also id in the pre-compiled script plugin, just not within its plugins { ... }
block, but using the “traditional” apply(...)
, and thus not getting type-safe accessors.
Alternatively you could stuff those binary plugins in another project of the same build and add a dependency from the project with the precompiled script plugin onto the project with the binary plugin, because then chicken-and-egg is resolved as the project with the binary plugin is built first and can then be used in the plugins { ... }
block of the precompiled script plugin I think.
I wonder if we’d be better off extracting the task classes from the plugin,
Well, as I said, whether those task files are in the same source file as the plugin or in separate files is totally irrelevant, there is no technical difference besides the file-information in the stacktrace / classfile
and doing more plugin-y things there, like all the task definitions… probably wouldn’t need a separate convention plugin then…
Yeah, well, that you have to know.
Both can make sense, depends strongly on details and needs.
binary plugins are distributed as JARs
Well, the “binary plugins” term might also be used a bit inconsistently.
Actually after compiling a precompiled script plugin, it also is a binary plugin.
And a precompiled script plugin when compiled can as well be distributed as a JAR.
And both can also be used from an included build.
There is really not much difference except for the syntax you type.