Slackbot
07/01/2023, 1:11 AMVampire
07/01/2023, 10:41 AMplugins { ... } block, applies it to a separate dummy project, then investigates which extensions were added by the plugins and generates type-safe accessors for them.
But this is only done for build scripts, not for settings scripts. Probably because it would need precious build time and is rather seldomly necessary.
So from an init script alone the way with the extensions is probably the best you can achieve. Otherwise your would need something that is added to the classpath that then provides the accessors pre-created, or maybe a holder class for the constants and just the builder class is added as extension, so that you just need one accessor or once the manual looking into the extensions.Gábor Török
07/02/2023, 4:27 AMlib, that way it would be there for all the scripts no matter what.
the question is: to minimize boilerplate required in the project, there a way to add our package with the custom constants (maybe even custom logic) to the list of packages that are [imported by default for scripts](https://docs.gradle.org/current/userguide/writing_build_scripts.html#script-default-imports) when a build is using our custom distribution?Vampire
07/02/2023, 11:55 AMGábor Török
07/04/2023, 9:19 PMorg.gradle.api package, (because that's supposed to be imported by default... )
first i added this jar to the custom gradle distribution zip's lib folder and the lib/plugins folder, but build scripts does not seem to be picking up stuff from either...
then i tried by adding the class files into the distribution by adding them to the lib/gradle-kotlin-dsl jar - now the build scripts saw the object i added - but i still had to manually import it:
this fails:
println(MyDumbObject.someProperty)
this succeeds:
import org.gradle.api.MyDumbObject
println(MyDumbObject.someProperty)
not sure why.
also any extension properties or functions are just not picked up...
I am pretty sure i am missing something - but don't know what. there doesn't seem to be any guides online on how to add classes to a custom gradle distribution - only init scripts and properties...