Inceptum/build.gradle.kts

59 lines
1.9 KiB
Plaintext
Raw Normal View History

import org.ajoberstar.grgit.Grgit
2022-09-04 21:21:24 +02:00
import org.gradle.internal.os.OperatingSystem
plugins {
id("org.ajoberstar.grgit") version "5.0.0" apply false
}
var currentVer = "0.0.0+nogit"
if (File(".git").exists()) {
val grgit: Grgit = Grgit.open(mapOf("dir" to rootProject.projectDir.toString()))
currentVer = "0.0.0+notag"
val tagList = grgit.tag.list()
tagList.sortWith { left, right -> right.commit.dateTime.compareTo(left.commit.dateTime) }
if (tagList.isNotEmpty()) {
currentVer = tagList[0].name
}
}
println("Building Inceptum $currentVer")
2022-09-04 21:21:24 +02:00
val timestamp: Long =
if (project.hasProperty("timestamp")) "${project.property("timestamp")}".toLong() else (System.currentTimeMillis() / 1000L)
allprojects {
2022-09-04 21:21:24 +02:00
version = currentVer + if (project.hasProperty("release")) "" else "-$timestamp"
group = "io.gitlab.jfronny.inceptum"
}
val lwjglVersion by extra("3.3.1")
val imguiVersion by extra("1.86.4")
val logbackVersion by extra("1.3.0-alpha15")
2022-09-04 21:21:24 +02:00
val jfCommonsVersion by extra("2022.9.4+14-8-34")
val jgitVersion by extra("6.2.0.202206071550-r")
val flavorProp: String by extra(if (project.hasProperty("flavor")) "${project.property("flavor")}" else "custom")
2022-09-04 21:21:24 +02:00
val flavor: String by extra(
if (flavorProp != "custom") flavorProp else when (OperatingSystem.current()) {
OperatingSystem.WINDOWS -> "windows"
OperatingSystem.LINUX -> "linux"
OperatingSystem.MAC_OS -> "macos"
else -> throw IllegalStateException()
2022-09-04 21:21:24 +02:00
}
)
val isPublic by extra(project.hasProperty("public"))
2022-09-04 21:21:24 +02:00
val isRelease by extra(project.hasProperty("release"))
tasks.register("exportMetadata") {
doLast {
projectDir.resolve("version.json").writeText(
"""
{
"version": "$version",
"isPublic": $isPublic,
"isRelease": $isRelease,
"jvm": ${project(":common").extra["javaVersion"]}
}
""".trimIndent()
)
}
}