plugins {
    id 'java-library'
    id 'idea'
}

tasks.named('wrapper', Wrapper).configure {
    distributionType = Wrapper.DistributionType.BIN
}

version = mod_version
group = mod_group_id

base {
    archivesName = mod_id
}

java.toolchain.languageVersion = JavaLanguageVersion.of(25)

var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
    var replaceProperties = [
            minecraft_version      : minecraft_version,
            minecraft_version_range: minecraft_version_range,
            neoforge_loader_range  : neoforge_loader_range,
            fabric_loader_version  : fabric_loader_version,
            mod_id                 : mod_id,
            mod_name               : mod_name,
            mod_license            : mod_license,
            mod_version            : mod_version,
            mod_authors            : mod_authors,
            mod_description        : mod_description,
            decocraft_version      : decocraft_version
    ]
    inputs.properties replaceProperties
    expand replaceProperties
    from "src/main/templates"
    into "build/generated/sources/modMetadata"
}

sourceSets.main.resources.srcDir generateModMetadata

processResources {
    exclude '**/models_backup/**'
    exclude '**/*.zip'
}

jar {
    from(sourceSets.main.resources) {
        include '**/*'
    }
    from("build/generated/sources/modMetadata") {
        include '**/*'
    }
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.named('jar').configure {
    dependsOn generateModMetadata
}

idea {
    module {
        downloadSources = true
        downloadJavadoc = true
    }
}