Slackbot
02/10/2022, 4:24 PMDallas G
02/10/2022, 4:24 PMclass SeatGeekPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
val arch2 = extensions.create("arch2", Arch2PluginExtension::class.java)
afterEvaluate {
if (arch2.isConfigured) {
val moduleSetup = archetypeConfigToModuleSetup(target, arch2.archetypeConfig)
moduleSetup.plugins.forEach { plugin ->
println("Plugin: $plugin")
when (plugin) {
is Plugin.Class -> project.plugins.apply(plugin.clazz)
is Plugin.Id -> project.plugins.apply(plugin.id)
}
}
moduleSetup.dependencies.forEach { dep ->
when (dep) {
is Dependency.Maven -> target.dependencies.add(dep.configuration.asGradleConfigurationString(), dep.coordinates)
is Dependency.Module -> target.dependencies.module("${dep.configuration.asGradleConfigurationString()} ${dep.path}")
}
}
}
}
}
...
}
Vampire
02/10/2022, 4:34 PMplugins
block.
But you explicitly delay most of the work to later, after the build script was evalutated using afterEvaluate
which is almost never a good idea to use.Dallas G
02/10/2022, 4:45 PMDallas G
02/10/2022, 4:48 PMVampire
02/10/2022, 5:07 PMafterEvalutate
, as the apply
is of course before the extension.
When the plugin is applied it adds the extension, so it cannot be configured before the plugin is applied.
I'm not sure how you mean it exactly, but I guess yes, having a method in view
instead of a property and reacting to the method call.Dallas G
02/10/2022, 5:52 PM