mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Read run-plugins.yml once per run task
This commit is contained in:
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()
|
||||||
|
|||||||
Reference in new issue
Block a user