plugins {
    id 'java'
    id 'idea'
    id 'maven-publish'
    id 'fabric-loom'
}
base {
    archivesName = "${mod_name}-fabric-${minecraft_version}"
}
dependencies {
    minecraft "com.mojang:minecraft:${minecraft_version}"
    mappings loom.officialMojangMappings()
    modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
    modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
    implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
    implementation project(":common")

    modImplementation("curse.maven:tardim-531315:4668945")
//    modCompileOnly("com.simibubi.create:create-fabric-1.20.1:0.5.1-d-build.1118+mc1.20.1")
    modCompileOnly("cc.tweaked:cc-tweaked-$minecraft_version-fabric-api:$cc_version")
}

loom {
    if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) {
        accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener"))
    }
    mixin {
        defaultRefmapName.set("${mod_id}.refmap.json")
    }
    runs {
        client {
            client()
            setConfigName("Fabric Client")
            ideConfigGenerated(true)
            runDir("run")
        }
        server {
            server()
            setConfigName("Fabric Server")
            ideConfigGenerated(true)
            runDir("run")
        }
    }
}

tasks.withType(JavaCompile).configureEach {
    source(project(":common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).configureEach {
    source(project(":common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
    from(project(":common").sourceSets.main.allSource)
}

processResources {
    from project(":common").sourceSets.main.resources
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifactId base.archivesName.get()
            from components.java
        }
    }
    repositories {
        maven {
            url "file://" + System.getenv("local_maven")
        }
    }
}
