I am writing a game engine, and I have very big plugin infrastructure. Recently I moved to gradle for android builds and allowed plugins to have it’s custom engine.gradle
. In my main build script I have something like
fileTree(pluginsDir) {
include("**/script.gradle", "**/script.gradle.kts")
}.forEach {
try {
apply(from = it)
......
First of all it works great if plugin wants to inject something into andoird
or into dependencies
. That’s just amazing.
Some plugin developers, included me, realized that some android stuff are using their own gradle plugins. Like google services or OneSignal.
And here is the snug, because to apply the plugin, one would need to add it to buildscript{ classpath{} }
first, which I don’t see a way to do from anywhere but the root build.gradle
.
So, is there a way to somehow imperatively (as in opposite to declaratively) inject given dependency (say 'com.google.gms:google-services:4.3.3'
) into the class-path, and apply it to the project.
It probably won’t be anywhere near as pretty as regular apply plugin
, but anything? Like resolve plugin as a Class object and apply it to the project somehow? Any ideas?