
import org.gradle.internal.jvm.Jvm

plugins {
	kotlin("jvm") version "1.9.10"
	id("me.champeau.jmh") version "0.7.1"
	java
	application
}

group = "ru.dbotthepony"
version = "0.1-SNAPSHOT"

val lwjglVersion: String by project
val lwjglNatives: String by project
val kotlinVersion: String by project
val kotlinCoroutinesVersion: String by project

repositories {
	mavenCentral()

	maven {
		url = uri("https://maven.dbotthepony.ru/")
	}
}

application {
	mainClass.set("ru.dbotthepony.kstarbound.MainKt")
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

tasks.compileKotlin {
	kotlinOptions {
		jvmTarget = "17"
		freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
		freeCompilerArgs += "-Xjvm-default=all"
	}
}

dependencies {
	val kommonsVersion: String by project

	implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
	implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
	implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion")

	implementation("org.apache.logging.log4j:log4j-api:2.17.1")
	implementation("org.apache.logging.log4j:log4j-core:2.17.1")

	testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
	testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

	implementation("com.google.code.gson:gson:2.8.9")

	implementation("it.unimi.dsi:fastutil:8.5.6")

	implementation("com.google.guava:guava:33.0.0-jre")

	implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))

	implementation("org.lwjgl", "lwjgl")
	implementation("org.lwjgl", "lwjgl-glfw")
	implementation("org.lwjgl", "lwjgl-opengl")
	implementation("org.lwjgl", "lwjgl-opus")
	implementation("org.lwjgl", "lwjgl-stb")

	runtimeOnly("org.lwjgl", "lwjgl", classifier = lwjglNatives)
	runtimeOnly("org.lwjgl", "lwjgl-glfw", classifier = lwjglNatives)
	runtimeOnly("org.lwjgl", "lwjgl-opengl", classifier = lwjglNatives)
	runtimeOnly("org.lwjgl", "lwjgl-opus", classifier = lwjglNatives)
	runtimeOnly("org.lwjgl", "lwjgl-stb", classifier = lwjglNatives)

	val ffiVersion: String by project

	implementation("net.java.dev.jna:jna:5.13.0")
	implementation("com.github.jnr:jnr-ffi:$ffiVersion")

	implementation("ru.dbotthepony.kommons:kommons:[$kommonsVersion,)") { setTransitive(false) }
	implementation("ru.dbotthepony.kommons:kommons-gson:[$kommonsVersion,)") { setTransitive(false) }
	implementation("ru.dbotthepony.kommons:kommons-guava:[$kommonsVersion,)") { setTransitive(false) }
	implementation("ru.dbotthepony.kommons:kommons-linear-algebra:[$kommonsVersion,)") { setTransitive(false) }
	implementation("ru.dbotthepony.kommons:kommons-gson-linear-algebra:[$kommonsVersion,)") { setTransitive(false) }

	implementation("com.github.ben-manes.caffeine:caffeine:3.1.5")
	implementation(project(":luna"))

	implementation("io.netty:netty-transport:4.1.105.Final")
}

jmh {
	iterations.set(5)
	timeOnIteration.set("1s")
	warmup.set("1s")
	fork.set(1)
	includes.add("ht")
	synchronizeIterations.set(false)
	threads.set(4)
}

tasks.getByName<Test>("test") {
	useJUnitPlatform()
}
