Untitled

 avatar
Cerbon
groovy
24 days ago
4.8 kB
1
Indexable
Never
import net.darkhax.curseforgegradle.TaskPublishCurseForge

plugins {
    id "com.github.johnrengelman.shadow" version "7.1.2"
    id 'net.darkhax.curseforgegradle' version '1.1.18'
    id "com.modrinth.minotaur" version "2.+"
}

architectury {
    platformSetupLoomIde()
    neoForge()
}

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
    developmentNeoForge.extendsFrom common
}

dependencies {
    neoForge "net.neoforged:neoforge:${neo_version}"

    // Mod Dependencies
    modImplementation "com.cerbon:cerbons_api-neoforge-${minecraft_version}:${cerbons_api_version}"

    // Useful Mods
    modCompileOnlyApi "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
    modRuntimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"

    //modImplementation "curse.maven:jade-324717:${jade_version_forge}"

    // All Projects Dependencies
    compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixin_extras_version}"))
    implementation(include("io.github.llamalad7:mixinextras-neoforge:${mixin_extras_version}"))

    common(project(path: ":common", configuration: "namedElements")) { transitive false }
    shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
}

processResources {
    var replaceProperties = [
            minecraft_version_range         : minecraft_version_range_forge,
            neo_version_range               : neo_version_range,
            neo_loader_version_range        : neo_loader_version_range,
            mod_id                          : mod_id,
            mod_name                        : mod_name,
            mod_license                     : mod_license,
            mod_version                     : mod_version,
            mod_authors                     : mod_authors,
            mod_description                 : mod_description,
            issues_url                      : issues_url,
            curseforge_url                  : curseforge_url,
            logo_file                       : logo_file,
            cerbons_api_version_range_forge : cerbons_api_version_range_forge
    ]
    inputs.properties replaceProperties

    filesMatching(["META-INF/mods.toml", "pack.mcmeta"]) {
        expand replaceProperties + [project: project]
    }
}

base {
    archivesBaseName = archives_base_name + "-NeoForge-${minecraft_version}"
}

shadowJar {
    exclude "fabric.mod.json"

    configurations = [project.configurations.shadowCommon]
    archiveClassifier.set("dev-shadow")
}

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

jar {
    archiveClassifier.set("dev")
}

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

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

tasks.register("publishCurseForgeAndModrinth", Task) {
    dependsOn publishCurseForge
    dependsOn tasks.modrinth
}

tasks.register("publishCurseForge", TaskPublishCurseForge) {
    apiToken = System.getenv("CURSEFORGE_TOKEN")

    def mainFile = upload(curseforge_project_id, remapJar)
    mainFile.addModLoader("NeoForge")
    mainFile.addGameVersion(game_versions.replaceAll(" ", "").split(","))

    mainFile.releaseType = release_type
    mainFile.changelogType = changelog_type
    mainFile.changelog = rootProject.file(changelog).getText("UTF-8")

    mainFile.addRequirement(required_dependencies_neo.replaceAll(" ", "").split(","))
}

modrinth {
    token = System.getenv("MODRINTH_TOKEN")

    projectId = modrinth_project_id
    uploadFile = remapJar
    loaders = ["neoforge"]

    gameVersions = game_versions.replaceAll(" ", "").split(",") as Iterable<? extends String>

    versionName = archivesBaseName + "-" + mod_version
    versionNumber = mod_version
    versionType = release_type

    changelog = rootProject.file(project.changelog).getText('UTF-8')

    dependencies {
        required.project required_dependencies_neo.replaceAll(" ", "").split(",")
    }
}

publishing {
    publications {
        mavenForge(MavenPublication) {
            artifactId = 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 {

    }
}
Leave a Comment