Alina Dolgikh [JB]
Vampire
02/21/2024, 4:47 PM...gradle.kts
files and are most often used to implement convention plugins, but you can as well develop and publish a "normal" plugin with them.
"Using included builds for build logic (e.g. buildSrc)" => buildSrc
is not an included build. It behaves in many regards very similar to an included build and more so since Gradle 8, but it still is not a real included build, but a special thing that is a bit different in some nuances to an included build.Alina Dolgikh [JB]
louiscad
02/21/2024, 5:26 PMCLOVIS
02/22/2024, 8:59 AMVampire
02/22/2024, 9:37 AMdependencies { ... }
block
And both provide the same conceptual solution to have a nested dependencies { ... }
block where you then can use the uniform implementation
, compileOnly
, and so on.
The main problem is, that KMP had this before and has a slightly different API in the details which is one of the major concerns I've seen with it, as you were not able to use platform(...)
or testFIxtures(...)
and so on.
The same was true for the test suites nested block, but there is was fixed in 7.6.
Imho the KMP plugin should migrate to the same API the test suites plugin is using, that would make them work the same and hopefully remove some of the confusion.mbonnin
02/22/2024, 9:38 AMdependencies {}
block.Vampire
02/22/2024, 9:40 AMdependencies { ... }
block.
You just have to get the configuration by name or use the string-y method call.
You are not forced to use the nested block.mbonnin
02/22/2024, 9:41 AMVampire
02/22/2024, 9:42 AMval jvmImplementation by configurations
dependencies {
jvmImplementation(...)
}
Vampire
02/22/2024, 9:42 AM"jvmImplementation"(...)
is just an alternative for the ones liking it ugly πmbonnin
02/22/2024, 9:44 AMby
delegation is still not very typesafe but yea personal preferencesCLOVIS
02/22/2024, 9:45 AMimplementation
with KMP and with Kotlin/JVM are in theory the same yet have different syntaxes.
And even then I'd argue it's a bad idea, if only because it goes against the standard of how everyone else is doing it.mbonnin
02/22/2024, 9:46 AMit goes against the standard of how everyone else is doing itwho is everyone? KSP and the java plugin?
mbonnin
02/22/2024, 9:46 AMCLOVIS
02/22/2024, 9:47 AMdependencies
block? I haven't seen one, except specifically for platform
declarationsVampire
02/22/2024, 9:48 AMVampire
02/22/2024, 9:48 AMCLOVIS
02/22/2024, 9:48 AMmbonnin
02/22/2024, 9:49 AMmbonnin
02/22/2024, 9:50 AMVampire
02/22/2024, 9:50 AMmbonnin
02/22/2024, 9:50 AMPlugin.apply
CLOVIS
02/22/2024, 9:50 AMimplementation
in the top-level block and in the commonMain.dependencies
is not the same, and doesn't have the same options
β’ Some source sets have additional options (npm
for JS), but you can't check that typesafely
β’ You can't add different options for a specific source set/platform (example)Vampire
02/22/2024, 9:51 AMYou can hide them if you create them outside ofWell, not hidden, just not having a generated accessor
mbonnin
02/22/2024, 9:52 AMproject.configurations.getByName("implementation")
and TBH I'm not a fan of thismbonnin
02/22/2024, 9:53 AMmbonnin
02/22/2024, 9:54 AMmbonnin
02/22/2024, 9:54 AMConfigurationContainer
for the foreseeable future)CLOVIS
02/22/2024, 9:55 AMNamed
means that essentially any Gradle domain object's assigned name is part of the public API, that's the main way they are accessedmbonnin
02/22/2024, 9:57 AMconfigurations.getByName("foo").somethingThatMutatesTheConfiguration()
doesn't mean you should.louiscad
02/22/2024, 9:57 AMmbonnin
02/22/2024, 9:59 AMConfigurations
. The plugin creating the Configuration
would get a mutable reference and can change it. Everywhere else, it's immutable.Vampire
02/22/2024, 10:03 AMmbonnin
02/22/2024, 10:03 AMmbonnin
02/22/2024, 10:03 AMCLOVIS
02/22/2024, 10:03 AMtapchicoma
02/22/2024, 12:12 PMtapchicoma
02/22/2024, 1:57 PM"Using the Gradle convention plugin" => This links to the section about precompiled script plugins. Besides that "the ... plugin" is not fully correct, convention plugins != precompiled script plugins.
Convention plugins are plugins that apply your conventions (own configuration, applied plugins, ...) but you can implement them in any way you like, with Java, Groovy, Kotlin (normal .kt plugins), any other JVM language, legacy script plugins, or also as precompiled script plugins.
Precompiled script plugins are the ones that are in ...gradle.kts files and are most often used to implement convention plugins, but you can as well develop and publish a "normal" plugin with them.While you are technically correct here, Gradle documentation itself does not mention what is the "convention plugin". The only place I found is this where only precompiled script plugin is used as an example. So for the average user which is not so familiar with Gradle "convention plugin" == "precompiled script plugin". Though we will update the question here to use "precompiled script plugins" as an example of convention plugins.
"Using included builds for build logic (e.g. buildSrc)" => buildSrc is not an included build. It behaves in many regards very similar to an included build and more so since Gradle 8, but it still is not a real included build, but a special thing that is a bit different in some nuances to an included build.Here you need to be a really advanced Gradle user to know such nuances. Even Gradle documentation itself says:
The directory buildSrc is treated as an included build.Here as well we will update the question. fyi @Oleg Nenashev regarding Gradle documentation
tapchicoma
02/22/2024, 3:20 PMVampire
02/22/2024, 4:54 PMGradle documentation itself does not mention what is the "convention plugin". The only place I found is this where only precompiled script plugin is used as an example.https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html#sec:convention_plugins defines:
We can write a plugin that encapsulates the build logic common to several subprojects in a project. This kind of plugin is called a convention plugin.While it is true, that also on that page only precompiled script plugins are used as example, but not as part of the definition. π
So for the average user which is not so familiar with Gradle "convention plugin" == "precompiled script plugin".Yes, doesn't make it more correct though. π
updated form should be already availableπ β€οΈ
pers
02/28/2024, 7:10 PM