import org.gradle.internal.os.OperatingSystem

buildscript {
    repositories {
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.github.johnrengelman:shadow:8.1.1'
    }
}

plugins {
	id 'com.github.johnrengelman.shadow' version '8.1.1'
	id 'java'
	id 'eclipse'
}

project.ext.lwjglVersion = "3.3.3"

switch (OperatingSystem.current()) {
	case OperatingSystem.LINUX:
		project.ext.lwjglNatives = "natives-linux"
		def osArch = System.getProperty("os.arch")
		if (osArch.startsWith("arm") || osArch.startsWith("aarch64")) {
			project.ext.lwjglNatives += osArch.contains("64") || osArch.startsWith("armv8") ? "-arm64" : "-arm32"
		} else if  (osArch.startsWith("ppc")) {
			project.ext.lwjglNatives += "-ppc64le"
		} else if  (osArch.startsWith("riscv")) {
			project.ext.lwjglNatives += "-riscv64"
		}
		break
	case OperatingSystem.MAC_OS:
		project.ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
		break
	case OperatingSystem.WINDOWS:
		def osArch = System.getProperty("os.arch")
		project.ext.lwjglNatives = osArch.contains("64")
			? "natives-windows${osArch.startsWith("aarch64") ? "-arm64" : ""}"
			: "natives-windows-x86"
		break
}

group = 'me.eldodebug'
version = '1.0'
sourceCompatibility = targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'

repositories {
	maven { url 'https://www.jitpack.io' }
	mavenCentral()
}

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

    implementation 'com.google.code.findbugs:jsr305:3.0.2'

	implementation "org.lwjgl:lwjgl"
	implementation "org.lwjgl:lwjgl-glfw"
	implementation "org.lwjgl:lwjgl-openal"
	implementation "org.lwjgl:lwjgl-opengl"
	runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
	runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
	runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
	runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"

    implementation fileTree(dir: 'libs', include: ['*.jar'])
}

tasks.named('test') {
	useJUnitPlatform()
}

shadowJar {
    exclude 'net/java/**'
	exclude 'javax/**'
}