Radosław Panuszewski
08/17/2024, 6:01 PMplugins {
application // by name
java // by name
id("java") // by id - recommended
id("org.jetbrains.kotlin.jvm") version "1.9.0" // by id - recommended
}
Why is the non-typesafe plugin application id("java")
recommended over the typesafe accessor java
? For me, the typesafe one is both easier to read and easier to write (thanks to IDE autocompletion) + there is no way to make a typo. I tend to use typesafe accessors wherever possible in my buildscripts and I don't see any reason to prefer the non-typesafe plugin application 🤔Philip W
08/17/2024, 7:42 PMLennart Jörelid
09/10/2024, 9:41 AMplugins {
companyStandardJvmProject
}
or
plugins {
java
}
Lennart Jörelid
09/10/2024, 9:41 AMVampire
09/10/2024, 9:51 AMVampire
09/10/2024, 9:52 AMLennart Jörelid
09/10/2024, 10:01 AMThe task of a DSL is not to be high-performant.
The task of a DSL is to be user-friendly.That sounds like a rather oddly crafted DSL. Of course it should be user-friendly - otherwise a DSL would not be needed at all. The Gradle engineers control the DSL, the compilation result for it and the execution environment wherein it runs. Why should a DSL's compilation result be anything less than optimal performance?
Vampire
09/10/2024, 10:16 AMLennart Jörelid
09/10/2024, 10:52 AMid("foobar")
must be compiled and executed.
2. The extension function foobar
must also be compiled and executed.
An example of a simple DSL construct which would yield
plugins {
foobar
}
… to do exactly the same thing as the id("foobar")
call, compilation-wise and in other ways, would be:
val PluginDependenciesSpec.foobar: PluginDependencySpec
get() = id("foobar")
Lennart Jörelid
09/10/2024, 10:53 AMVampire
09/10/2024, 10:54 AMLennart Jörelid
09/10/2024, 10:55 AMVampire
09/10/2024, 10:55 AMVampire
09/10/2024, 10:55 AMVampire
09/10/2024, 10:55 AMVampire
09/10/2024, 10:56 AMplugins { ... }
blockVampire
09/10/2024, 10:56 AMLennart Jörelid
09/10/2024, 10:57 AMVampire
09/10/2024, 10:57 AMVampire
09/10/2024, 10:57 AMplugins
block on its ownVampire
09/10/2024, 10:58 AMVampire
09/10/2024, 10:58 AMVampire
09/10/2024, 10:58 AMLennart Jörelid
09/10/2024, 10:59 AMLennart Jörelid
09/10/2024, 10:59 AMLennart Jörelid
09/10/2024, 11:00 AMPhilip W
09/10/2024, 11:04 AMLennart Jörelid
09/10/2024, 11:06 AMPhilip W
09/10/2024, 11:08 AMVampire
09/10/2024, 11:11 AMSo … that text parser needs to invoke Gradle interfaces implemented in JAR:s, right?No, it just needs to parse that block and that's it.
Vampire
09/10/2024, 11:13 AMplugins { ... }
block to find out which type-safe accessors to generate for the remaining build script.
For this It transplants the plugins { ... }
block to a dummy project, executes it and then investigates which things the plugins applied in that block added to generate type-safe accessors for exactly those things that are really available.
For that step, you can save the Kotlin compilation and execution time by simply using the string-parser to get the plugins to apply and apply them within the JVM or whatever.Vampire
09/10/2024, 11:14 AMplugins { ... }
block does not use something that parser cannot handle.