Hello everyone; In my `settings.gradle.kts` I hav...
# community-support
a
Hello everyone; In my
settings.gradle.kts
I have a lot of `include()`'s. I was thinking of extracting all those includes out, in extension functions. e.g.:
Copy code
include("demo-1")
include("demo-2")
include("demo-3")
include("feature-a")
include("feature-b")
Could I somehow create an extension function, outside this file, and include all those in there, afterwards only calling
Copy code
includeDemoModules()
includeFeatureModules()
?
v
• You can use a legacy script plugin, but as the name suggests you shouldn't, the have quite some quirks and edge-cases • You can write a settings plugin in an included build that you then can use there • You can put the information in something like a CSV or YAML or whatever you prefer and process that information in the settings script if the main goal is not nicety of the setting script but keeping the information outside • ...
a
But aren't the plugins found in the included-build evaluated & executed after the settings script ?
v
Plugins are executed when you apply them
a
So an extension function wouldn't work ? Having an extension on the
Settings
object i mean
v
Sure you can, if you bring it to the classpath. You can have it in an included build and either apply a plugin from that build (can be a no-op plugin, just to bring it on the classpath), or a manual setting script dependency to bring it to the classpath.
a
bringing it to the classpaht means adding it to the
settings.gradle.kts
file using
apply(from="path....")
?
v
If you use "apply from" you use a legacy script plugin, see above
And even if you would ignore the warning from above, you cannot write an extension function in a legacy script plugin and use it where you applied it.
a
Can you pinpoint me to the new way of adding to the classpath ? I'm not aware of any other method
v
Imagine the contents of a script as being the body of the
apply
method of the plugin class
> Can you pinpoint me to the new way of adding to the classpath ? > I'm not aware of any other method I already did
Besides that it is not in any way "new"
Actually, I'm not sure right now whether the manual settings script classpath adding will work with an included build. But if not, you can still use the other option of a no-op plugin which is prettier anyway that I mentioned above.
a
I think the no-op is the only solution here; I've tried the others ones and did not work
But thanks for your help! It's greatly valued
👌 1