From 23dfb368e1d8a8768d472dc57ecebc477e63e301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20R=C3=B6sch?= Date: Thu, 20 Jul 2017 03:11:55 +0200 Subject: [PATCH] Add automatic version replacement in Forgelin.kt (#20) * Add automatic version replacement in Forgelin.kt * Remove unnecessary newlines caused by IDEA --- build.gradle | 22 +++++++++++++++++-- .../net/shadowfacts/forgelin/Forgelin.kt | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 8ef0da4..0a93b49 100644 --- a/build.gradle +++ b/build.gradle @@ -31,8 +31,7 @@ minecraft { mappings = mcp_mappings - replaceIn "Reference.kt" - replaceIn "Reference.kt" + replaceIn "Forgelin.kt" replace "@VERSION@", mod_version useDepAts = true @@ -90,6 +89,25 @@ shadowJar { tasks.build.dependsOn shadowJar +import net.minecraftforge.gradle.user.TaskSourceCopy + +// Enables source replacements for Kotlin code +for (set in sourceSets) { + def taskName = "source${set.name.capitalize()}Kotlin" + def dir = new File(project.getBuildDir(), "sources/${set.name}/kotlin") + task(taskName, type: TaskSourceCopy) { + source = set.getKotlin() + output = dir + } + def compileTask = tasks[set.getCompileTaskName("kotlin")] + compileTask.source = dir + compileTask.dependsOn taskName + def dirPath = dir.toPath() + compileKotlin.include { + return it.file.toPath().startsWith(dirPath) + } +} + artifacts { archives shadowJar } diff --git a/src/main/kotlin/net/shadowfacts/forgelin/Forgelin.kt b/src/main/kotlin/net/shadowfacts/forgelin/Forgelin.kt index 36644d4..3b1a69d 100644 --- a/src/main/kotlin/net/shadowfacts/forgelin/Forgelin.kt +++ b/src/main/kotlin/net/shadowfacts/forgelin/Forgelin.kt @@ -10,6 +10,6 @@ object Forgelin { const val MOD_ID = "forgelin" const val NAME = "Forgelin" - const val VERSION = "1.4.2" + const val VERSION = "@VERSION@" } \ No newline at end of file