Inceptum/build.gradle.kts

122 lines
4.3 KiB
Plaintext

import org.gradle.internal.os.OperatingSystem
import org.ajoberstar.grgit.Grgit
plugins {
java
application
`maven-publish`
id("com.github.johnrengelman.shadow") version "7.1.2"
id("org.ajoberstar.grgit") version "5.0.0" apply false
}
application {
mainClass.set("io.gitlab.jfronny.inceptum.Inceptum")
}
repositories {
mavenCentral()
maven {
setUrl("https://gitlab.com/api/v4/projects/35745143/packages/maven")
}
}
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")
allprojects {
version = currentVer + if (project.hasProperty("release")) "" else "-" + (if (project.hasProperty("timestamp")) project.property("timestamp") else "${System.currentTimeMillis() / 1000L}")
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")
val jfCommonsVersion by extra("2022.7.4+11-13-3")
val jgitVersion by extra("6.2.0.202206071550-r")
val flavorProp: String by extra(if (project.hasProperty("flavor")) "${project.property("flavor")}" else "custom")
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()
})
val isPublic by extra(project.hasProperty("public"))
val isRelease by extra(project.hasProperty("release"))
dependencies {
implementation("ch.qos.logback:logback-classic:$logbackVersion")
implementation("io.gitlab.jfronny:commons:$jfCommonsVersion")
implementation("io.gitlab.jfronny:commons-gson:$jfCommonsVersion")
implementation("io.gitlab.jfronny:commons-slf4j:$jfCommonsVersion")
implementation("org.eclipse.jgit:org.eclipse.jgit:$jgitVersion")
implementation(project(":wrapper"))
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
arrayOf("", "-opengl", "-glfw", "-tinyfd").forEach { it ->
implementation("org.lwjgl:lwjgl$it:$lwjglVersion")
if (flavor == "windows" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-windows")
if (flavor == "linux" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-linux")
if (flavor == "macos" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-macos")
}
implementation("io.github.spair:imgui-java-binding:$imguiVersion") // https://github.com/SpaiR/imgui-java
implementation ("io.github.spair:imgui-java-lwjgl3:$imguiVersion")
if (flavor == "windows" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-windows:$imguiVersion")
if (flavor == "linux" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-linux:$imguiVersion")
if (flavor == "macos" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-macos:$imguiVersion")
}
tasks.processResources {
inputs.property("version", project.version)
filesMatching("version.json") {
expand(
"version" to project.version,
"flavor" to flavorProp,
"isPublic" to isPublic,
"isRelease" to isRelease,
"jvm" to project.java.targetCompatibility
)
}
}
tasks.shadowJar {
archiveClassifier.set(flavorProp)
exclude("about.html")
exclude("plugin.properties")
exclude("META-INF/**")
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifact(tasks.shadowJar) {
builtBy(tasks.shadowJar)
}
}
}
if (isPublic) {
repositories.maven {
url = uri("https://gitlab.com/api/v4/projects/30862253/packages/maven")
name = "gitlab"
credentials(HttpHeaderCredentials::class) {
name = "Job-Token"
value = System.getenv().get("CI_JOB_TOKEN")
}
}
}
repositories.mavenLocal()
}