plugins {
    id 'fabric-loom' version '0.8-SNAPSHOT'
    id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

minecraft {
    accessWidener = file("src/main/resources/dashloader.accesswidener")
}

repositories {
    maven {
        name = "Jitpack"
        url = "https://jitpack.io"
    }
    maven {
        name = "Auoeke's Maven"
        url = "https://auoeke.jfrog.io/artifactory/maven"
    }
    maven {
        name = "Technici4n"
        url = "https://raw.githubusercontent.com/Technici4n/Technici4n-maven/master/"
        content {
            includeGroup "net.fabricmc.fabric-api"
            includeGroup "dev.technici4n"
            includeGroup "dev.latvian.mods"
        }
    }
}

dependencies {
    modApi "io.activej:activej-serializer:$activej_version"
    include "io.activej:activej-serializer:$activej_version"
    include "io.activej:activej-codegen:$activej_version"
    include "org.slf4j:slf4j-api:1.7.29"

    //to change the versions see the gradle.properties file
    minecraft "com.mojang:minecraft:${project.minecraft_version}"
    mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
    modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

    //snakeyaml
    modImplementation "org.yaml:snakeyaml:1.27"
    include "org.yaml:snakeyaml:1.27"

    modCompileOnly fabricApi.module("fabric-renderer-indigo", "0.36.1+1.17");
}

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

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

tasks.withType(JavaCompile).configureEach {
    it.options.encoding = "UTF-8"
    it.options.release = 16
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = "sources"
    from sourceSets.main.allSource
}

jar {
    from "LICENSE"
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact(remapJar) {
                builtBy remapJar
            }
            artifact(sourcesJar) {
                builtBy remapSourcesJar
            }
        }
    }

    repositories {
        // uncomment to publish to the local maven
        mavenLocal()
    }
}
