aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main/kotlin/neubs/buildflags.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-01-26 12:35:17 +0100
committernea <nea@nea.moe>2023-01-26 12:35:17 +0100
commite29354f810f69a509fba8e6c2ac58d1ce65c5483 (patch)
tree887c7eb64f54e98c41543c0f0613151f7715ed09 /buildSrc/src/main/kotlin/neubs/buildflags.kt
parentf89a90e08d2b6cff70d84bb4c35bbdc8a0b49bc0 (diff)
parentf1a5ba28e92da4f46b39da27277b1c8b7a6ec4bb (diff)
downloadNotEnoughUpdates-e29354f810f69a509fba8e6c2ac58d1ce65c5483.tar.gz
NotEnoughUpdates-e29354f810f69a509fba8e6c2ac58d1ce65c5483.tar.bz2
NotEnoughUpdates-e29354f810f69a509fba8e6c2ac58d1ce65c5483.zip
Merge remote-tracking branch 'origin/master' into disabledoptionsdisabledoptions
Diffstat (limited to 'buildSrc/src/main/kotlin/neubs/buildflags.kt')
-rw-r--r--buildSrc/src/main/kotlin/neubs/buildflags.kt23
1 files changed, 11 insertions, 12 deletions
diff --git a/buildSrc/src/main/kotlin/neubs/buildflags.kt b/buildSrc/src/main/kotlin/neubs/buildflags.kt
index 6b7ab489..27c4bbcf 100644
--- a/buildSrc/src/main/kotlin/neubs/buildflags.kt
+++ b/buildSrc/src/main/kotlin/neubs/buildflags.kt
@@ -19,8 +19,13 @@
package neubs
+import org.gradle.api.DefaultTask
import org.gradle.api.Plugin
import org.gradle.api.Project
+import org.gradle.api.file.RegularFileProperty
+import org.gradle.api.provider.MapProperty
+import org.gradle.api.tasks.*
+import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.the
import java.nio.charset.StandardCharsets
import java.util.*
@@ -28,22 +33,16 @@ import java.util.*
const val NEU_BUILDFLAGS_PREFIX = "neu.buildflags."
class NEUBuildFlags : Plugin<Project> {
+
override fun apply(target: Project) {
val props =
target.properties.filterKeys { it.startsWith(NEU_BUILDFLAGS_PREFIX) }.mapValues { it.value as String }
target.extensions.add("buildflags", Extension(props))
- target.tasks.create("generateBuildFlags") {
- outputs.upToDateWhen { false }
- val t = target.layout.buildDirectory.file("buildflags.properties")
- outputs.file(t)
- doLast {
- val p = Properties()
- p.putAll(props)
- t.get().asFile.writer(StandardCharsets.UTF_8).use {
- p.store(it, "Store build time configuration for NEU")
- }
- }
-
+ target.tasks.create<WriteProperties>("generateBuildFlags") {
+ this.encoding = StandardCharsets.UTF_8.name()
+ this.setProperties(props)
+ this.comment = "Store build time configuration for NEU"
+ this.setOutputFile(target.layout.buildDirectory.file("buildflags.properties"))
}
}