plugins {
    id 'fabric-loom' version '1.7-SNAPSHOT'
    id "com.github.johnrengelman.shadow" version "8.1.1"
}

version = project.mod_version
group = project.maven_group

base {
    archivesName = project.archives_base_name
}

repositories {
    maven {
        name = 'spongepowered-repo'
        url = 'https://repo.spongepowered.org/maven'
    }
}

configurations {
    implementation.extendsFrom(library)
    shadow.extendsFrom(library)
}

loom {
    accessWidenerPath = file("src/main/resources/earthhack.accesswidener")
}

dependencies {
    minecraft "com.mojang:minecraft:${project.minecraft_version}"
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
    modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

    library "club.minnced:java-discord-rpc:2.0.2"

    library group: 'org.lwjgl', name: 'lwjgl-nanovg', version: '3.3.3'
    library "org.lwjgl:lwjgl-nanovg::natives-windows"
    library "org.lwjgl:lwjgl-nanovg::natives-linux"
    library "org.lwjgl:lwjgl-nanovg::natives-macos"
}

processResources {
    inputs.property "version", project.version

    filesMatching("fabric.mod.json") {
        expand "version": project.version
    }
}

shadowJar {
    configurations = [project.configurations.shadow]

    dependencies {
        exclude {
            // System.out.println(it.moduleGroup)
            it.moduleGroup == "net.java.dev.jna"
        }
    }
}

remapJar {
    dependsOn shadowJar
    inputFile.set(shadowJar.archiveFile)
}

tasks.withType(JavaCompile).configureEach {
    it.options.release = 21
}

java {
    withSourcesJar()
    sourceCompatibility = JavaVersion.VERSION_21
    targetCompatibility = JavaVersion.VERSION_21
}

jar {
    from("LICENSE") {
        rename { "${it}_${project.base.archivesName.get()}"}
    }

    manifest {
        attributes(
                'Manifest-Version': 1.0,
                "Main-Class": 'me.earth.earthhack.Main'
        )
    }
}