attempt at setting up fawe.properties

This commit is contained in:
MattBDev 2019-08-22 21:06:03 -04:00
parent b5b89412d9
commit 70d4af006a
3 changed files with 29 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import org.ajoberstar.grgit.Grgit
import java.time.format.DateTimeFormatter
plugins {
id("com.gradle.build-scan") version "2.4.1"
@ -18,6 +19,28 @@ logger.lifecycle("""
*******************************************
""")
//TODO FIX THIS WHEN I FEEL LIKE IT
var rootVersion = "1.13"
var revision: String = ""
var buildNumber = ""
var date: String = ""
ext {
val git: Grgit = Grgit.open {
dir = File(rootDir.toString() + "/.git");
}
ext["date"] = git.head().dateTime.format(DateTimeFormatter.ofPattern("yy.MM.dd"));
ext["revision"] = "-${git.head().abbreviatedId}";
var parents: MutableList<String>? = git.head().parentIds;
if (project.hasProperty("buildnumber")) {
buildNumber = project.properties["buildnumber"] as String;
} else {
var index = -2109; // Offset to match CI
while (parents != null && parents.isNotEmpty()) {
parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
index++;
}
buildNumber = index.toString();
}
}
//def rootVersion = "1.13"
//def revision = ""
//def buildNumber = ""
@ -40,6 +63,8 @@ logger.lifecycle("""
//
//version = String.format("%s.%s", rootVersion, buildNumber)
version = String.format("%s.%s", rootVersion, buildNumber)
if (!project.hasProperty("gitCommitHash")) {
apply(plugin = "org.ajoberstar.grgit")
ext["gitCommitHash"] = try {

View File

@ -1,4 +1,4 @@
group=com.sk89q.worldedit
version=7.1.0-SNAPSHOT
#version=7.1.0-SNAPSHOT
org.gradle.jvmargs=-Xmx1G

View File

@ -59,9 +59,9 @@ sourceSets {
tasks.named<Copy>("processResources") {
filesMatching("fawe.properties") {
// expand("version" to project.ext["internalVersion"])
// expand("commit" to "TODO GIT")
// expand("date" to "TODO Date")
expand("version" to "$version")
expand("commit" to "${rootProject.ext["revision"]}")
expand("date" to "${rootProject.ext["date"]}")
}
}
tasks.named<ShadowJar>("shadowJar") {