diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2023-01-25 19:43:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 19:43:51 +0100 |
commit | f1a5ba28e92da4f46b39da27277b1c8b7a6ec4bb (patch) | |
tree | f8ad2c2ab2f859446345e189e62007b3e28b44c0 /buildSrc | |
parent | f1ce88fb8e98b41a10ba374d32cb312b949ba8ef (diff) | |
download | NotEnoughUpdates-f1a5ba28e92da4f46b39da27277b1c8b7a6ec4bb.tar.gz NotEnoughUpdates-f1a5ba28e92da4f46b39da27277b1c8b7a6ec4bb.tar.bz2 NotEnoughUpdates-f1a5ba28e92da4f46b39da27277b1c8b7a6ec4bb.zip |
Annotation registering (and also some comptime performance) (#554)
Diffstat (limited to 'buildSrc')
-rw-r--r-- | buildSrc/src/main/kotlin/neubs/buildflags.kt | 23 |
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")) } } |