plugins {
    id "com.github.johnrengelman.shadow" version "7.1.2"
}

repositories {
    maven { url "https://maven.quiltmc.org/repository/release/" }
    maven { url "https://api.modrinth.com/maven" }
}

architectury {
    platformSetupLoomIde()
    loader("quilt")
}

loom {
}

configurations {
    common
    shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
    compileClasspath.extendsFrom common
    runtimeClasspath.extendsFrom common
    developmentQuilt.extendsFrom common
    archivesBaseName = rootProject.archives_base_name + "-quilt"
}

dependencies {
    modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
    modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}"
    // Remove the next few lines if you don't want to depend on the API
    //modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") {
    //    // We must not pull Fabric Loader from Architectury Fabric
    //    exclude group: "net.fabricmc"
    //    exclude group: "net.fabricmc.fabric-api"
    //}
    modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"
    include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"

    common(project(path: ":common", configuration: "namedElements")) { transitive false }
    shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false }
    //common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
    //shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false }
}

processResources {
    inputs.property "group", rootProject.maven_group
    inputs.property "version", project.version

    filesMatching("quilt.mod.json") {
        expand "group": rootProject.maven_group,
                "version": project.version
    }
}

shadowJar {
    exclude "architectury.common.json"

    configurations = [project.configurations.shadowCommon]
    classifier "dev-shadow"
}

remapJar {
    input.set shadowJar.archiveFile
    dependsOn shadowJar
    classifier null
}

jar {
    classifier "dev"
}

sourcesJar {
    def commonSources = project(":common").sourcesJar
    dependsOn commonSources
    from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
    withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
        skip()
    }
}

publishing {
    publications {
        mavenQuilt(MavenPublication) {
            artifactId = rootProject.archives_base_name + "-" + project.name
            from components.java
        }
    }

    // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
    repositories {
        // Add repositories to publish to here.
    }
}
