This message was deleted.
# community-support
s
This message was deleted.
šŸ‘ 1
j
buildSrc generates accessors so you don't have to remember the ID
b
What accessors? For extensions? e.g. like applying
id(kotlin("jvm"))
gives you
kotlin {}
accessor?
g
Well, Gradle also generate accessors for plugins from included build or normal binary plugins, like
kotlin { ... }
you mentioned. IIRC they are generated based on registering extension no matter how exactly plugin in written. Also for
org.example.my-plugin.gradle.kts
in either
buildSrc
or included build gradle would generate accessor so you can apply it using `plugins { org.example.\`my-plugin\` }` in
build.gradle.kts
as well as via
plugins { id("org.example.my-plugin") }
. I avoid using former variant (using accessors) since IDEA has bad habit to either insert imports for generated accessors or just break a build at inconvenient time. Term convention plugin is a bit a confusing one since some call precompiled script plugins that. As I understand plugin should be called convention plugin if it configures some defaults/conventions for your build. For example apply
java-library
plugin, configure target java version, configure publication etc. And it can be written as plain java/groovy/kotlin binary plugin or kotlin/groovy precompiled script plugin.
Sorry, slack formatting doesn't allow escaping backtick symbol in inline code. Example for plugin id accessor should be following:
Copy code
plugin { org.example.`my-plugin` }
b
Yeah, my question is basically putting
my.plugin.gradle.kts
in either
buildSrc
or included build from
my-convention-plugins-module
Mainly from performance perspective. e.g. is one of them cached better than the other in some way?
j
If the file is named
some-plugin.gradle.kts
, you can apply it via
Copy code
plugins {
    `some-plugin` // same as id("some-plugin")
}
@tony has a nice article about it
b
Didn't know that, but I'm not really concerned about those kind of accessors all that much.
j
I can't find it, hope he can share it here soon
v
Also forĀ 
org.example.my-plugin.gradle.kts
Ā in eitherĀ 
buildSrc
Ā or included build gradle would generate accessor so you can apply it usingĀ `plugins { org.example.\`my-plugin\` }` inĀ 
build.gradle.kts
Ā as well as viaĀ 
plugins { id("org.example.my-plugin") }
.
That's exactly not true. That's one of the differences of
buildSrc
vs. included build. With
buildSrc
you get the accessors for doing `plugins { org.example.
my-plugin
}`, with included builds you don't. The other slight differences are usually more on the positive side.
buildSrc
is always executed before your build whether you use something or not, its tests task is also always exectued (except if it is up-to-date of course), and the whole result is prepended to all build scripts of the main build. The included build is only executed if actually used. It is only added to the build script class paths where it actually is used and only the necessary work (no tests) is done to get the jar you need at that situation. If you want the tests to be executed, you can wire them to your main builds
check
task for example.
Sorry, slack formatting doesn't allow escaping backtick symbol in inline code.
It allows, with trick 17. Make an inline code word so that Slack already has the inline code formatting, then paste in the backtick.
šŸ‘ 1
g
Included build is better in terms of performance, it would only build required jars instead of also running tests (even with up-to-date checks it takes some time). Also you could use included build from several build but
buildSrc
could be used only from one build
@Vampire, my bad. I quite remember gradle generated plugin accessors for included builds too but since I don't use them.. Mainly because of IntelliJ and stacking convention plugins (I have something like
java-common-conventions
, than
java-library-conventions
that use it etc), so I prefer simple
id("java-common-conventions")
syntax. As for the trick it may work from slack on android, never tried. Usually has opposite problem with ending inline code span)