Read run-plugins.yml once per run task

This commit is contained in:
Jason Penilla committed 2023-11-11 13:23:36 -07:00
1 parent 3b8bec57f6
commit 38e850cb76
1 file changed
+9 -7
@@ -6,20 +6,24 @@ import xyz.jpenilla.runtask.task.RunWithPlugins
val ext = extensions.create("configurablePlugins", ConfigurablePluginsExt::class.java) val ext = extensions.create("configurablePlugins", ConfigurablePluginsExt::class.java)
afterEvaluate { afterEvaluate {
ext.gradleDependencyBased.get().forEach { entry -> val configs = ext.gradleDependencyBased.get().map { entry ->
val c = configurations.register(entry.name + "Plugin") { val c = configurations.register(entry.name + "Plugin") {
isTransitive = false isTransitive = false
} }
dependencies { dependencies {
c.name(entry.dep) { entry.op?.execute(this) } c.name(entry.dep) { entry.op?.execute(this) }
} }
tasks.withType(RunWithPlugins::class).configureEach { entry to c
val cfg = readConfig() }
tasks.withType(RunWithPlugins::class).configureEach {
val cfg = readConfig()
configs.forEach { (entry, configuration) ->
val enabled = cfg.taskOverrides[name]?.get(entry.name) val enabled = cfg.taskOverrides[name]?.get(entry.name)
?: cfg.defaults[entry.name] ?: cfg.defaults[entry.name]
?: false ?: false
if (enabled) { if (enabled) {
pluginJars.from(c) pluginJars.from(configuration)
} }
} }
} }
@@ -39,9 +43,7 @@ fun readConfig(): Config {
.file(file("run-plugins.yml")) .file(file("run-plugins.yml"))
.nodeStyle(NodeStyle.BLOCK) .nodeStyle(NodeStyle.BLOCK)
.defaultOptions { .defaultOptions {
it.header(""" it.header("Enable and disable optional plugins for run tasks in this project")
Enable and disable optional plugins for run tasks in this project
""".trimIndent())
} }
.build() .build()
val n = loader.load() val n = loader.load()