|
| 1 | +import net.darkhax.curseforgegradle.TaskPublishCurseForge |
| 2 | +import net.darkhax.curseforgegradle.UploadArtifact |
| 3 | + |
| 4 | +plugins { |
| 5 | + id 'dev.architectury.loom' version '1.10-SNAPSHOT' |
| 6 | + id "com.github.johnrengelman.shadow" version "8.1.1" |
| 7 | + id 'net.darkhax.curseforgegradle' version '1.1.+' |
| 8 | +} |
| 9 | + |
| 10 | +boolean isNeo = minecraft_version == "1.21.1" |
| 11 | +boolean isOld = minecraft_version == "1.16.5" |
| 12 | + |
| 13 | +boolean useShadow = use_shadow == "true" |
| 14 | +boolean useMixin = use_mixin == "true" |
| 15 | +boolean useMixinExtras = use_mixin_extras == "true" |
| 16 | +boolean useDuplicationLess = use_duplicationless == "true" |
| 17 | +boolean claimIntegration = claim_integration == "true" |
| 18 | +boolean embeddiumIntegration = embeddium_integration == "true" |
| 19 | + |
| 20 | +if (isNeo) useShadow = false |
| 21 | + |
| 22 | +if (useShadow) { |
| 23 | + configurations { |
| 24 | + shadow |
| 25 | + implementation.extendsFrom(shadow) |
| 26 | + } |
| 27 | + |
| 28 | + shadowJar { |
| 29 | + configurations = [project.configurations.shadow] |
| 30 | + relocate "com.llamalad7.mixinextras", "me.kall.${archives_name}.mixinextras" |
| 31 | + mergeServiceFiles() |
| 32 | + archiveClassifier = "dev-shadow" |
| 33 | + } |
| 34 | + |
| 35 | + remapJar { |
| 36 | + dependsOn tasks.named("shadowJar") |
| 37 | + inputFile = shadowJar.archiveFile |
| 38 | + archiveClassifier = null |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +group = project.maven_group |
| 43 | +version = "${project.minecraft_version}-${project.mod_version}" |
| 44 | + |
| 45 | +base { |
| 46 | + archivesName = project.archives_name |
| 47 | +} |
| 48 | + |
| 49 | +loom { |
| 50 | + silentMojangMappingsLicense() |
| 51 | + |
| 52 | + if (!isNeo && useMixin) { |
| 53 | + forge { |
| 54 | + mixinConfig "${archives_name}.mixins.json" |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +repositories { |
| 60 | + maven { name = 'ParchmentMC'; url = 'https://maven.parchmentmc.org' } |
| 61 | + maven { |
| 62 | + name = "Modrinth" |
| 63 | + url = "https://api.modrinth.com/maven" |
| 64 | + content { includeGroup "maven.modrinth" } |
| 65 | + } |
| 66 | + maven { |
| 67 | + url "https://cursemaven.com" |
| 68 | + content { includeGroup "curse.maven" } |
| 69 | + } |
| 70 | + maven { name = 'NeoForged'; url = 'https://maven.neoforged.net/releases' } |
| 71 | +} |
| 72 | + |
| 73 | +def versionMap = [ |
| 74 | + "1.20.1": [forge: "47.4.2", parchment: "2023.09.03", ftbChunks: "6431735", ftbLib: "6164053", opac: "6242869", embeddium: "5681725", duplicationless: "7349275"], |
| 75 | + "1.19.2": [forge: "43.5.0", parchment: "2022.11.27", ftbChunks: "5710631", ftbLib: "4661834", opac: "6242849", embeddium: "5539178", duplicationless: "7349271"], |
| 76 | + "1.18.2": [forge: "40.3.10", parchment: "2022.11.06", ftbChunks: "5423717", ftbLib: "4396792", opac: "6242845", embeddium: "5322305", duplicationless: "7349269"], |
| 77 | + "1.16.5": [forge: "36.2.42", parchment: "2022.03.06", ftbChunks: "4297564", ftbLib: "3553840", opac: "unfound" , embeddium: "5322311", duplicationless: "7349267"], |
| 78 | + "1.21.1": [neo : "21.1.192", parchment: "2024.11.17", ftbChunks: "6504893", ftbLib: "6711324", opac: "6476205", embeddium: "6118392", duplicationless: "7349264"] |
| 79 | +] |
| 80 | + |
| 81 | +LinkedHashMap<String, String> versionInfo = versionMap[minecraft_version] |
| 82 | +if (versionInfo == null) throw new IllegalArgumentException("Unsupported version: ${minecraft_version}") |
| 83 | + |
| 84 | +String forgeVersion = versionInfo.forge ?: "" |
| 85 | +String parchmentVersion = versionInfo.parchment |
| 86 | +String ftbChunks = versionInfo.ftbChunks ?: "" |
| 87 | +String ftbLib = versionInfo.ftbLib ?: "" |
| 88 | +String opac = versionInfo.opac ?: "" |
| 89 | +String embeddium = versionInfo.embeddium ?: "" |
| 90 | +String duplicationLess = versionInfo.duplicationless ?: "" |
| 91 | + |
| 92 | +if (isNeo) useMixinExtras = false |
| 93 | + |
| 94 | +dependencies { |
| 95 | + minecraft "net.minecraft:minecraft:$project.minecraft_version" |
| 96 | + mappings loom.layered { |
| 97 | + officialMojangMappings() |
| 98 | + parchment("org.parchmentmc.data:parchment-${project.minecraft_version}:${parchmentVersion}@zip") |
| 99 | + } |
| 100 | + |
| 101 | + if (isNeo) { |
| 102 | + neoForge "net.neoforged:neoforge:${versionInfo.neo}" |
| 103 | + } else { |
| 104 | + forge "net.minecraftforge:forge:${project.minecraft_version}-${forgeVersion}" |
| 105 | + } |
| 106 | + |
| 107 | + if (useShadow) { |
| 108 | + if (useMixinExtras) shadow(annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixinextras_version}")) |
| 109 | + } |
| 110 | + |
| 111 | + if (claimIntegration) { |
| 112 | + modImplementation("curse.maven:ftb-chunks-forge-314906:${ftbChunks}") |
| 113 | + modImplementation("curse.maven:ftb-library-forge-404465:${ftbLib}") |
| 114 | + if (!isOld) modImplementation("curse.maven:open-parties-and-claims-636608:${opac}") |
| 115 | + } |
| 116 | + |
| 117 | + if (embeddiumIntegration) modImplementation("curse.maven:embeddium-908741:${embeddium}") |
| 118 | + if (useDuplicationLess) modImplementation("curse.maven:duplicationless-1380105:${duplicationLess}") |
| 119 | + modImplementation("curse.maven:astral-sorcery-241721:3813365") |
| 120 | +} |
| 121 | + |
| 122 | +processResources { |
| 123 | + inputs.property 'version', project.version |
| 124 | + if (isNeo) { |
| 125 | + filesMatching('META-INF/neoforge.mods.toml') { |
| 126 | + expand version: project.version |
| 127 | + } |
| 128 | + exclude("META-INF/mods.toml") |
| 129 | + } else { |
| 130 | + filesMatching('META-INF/mods.toml') { |
| 131 | + expand version: project.version |
| 132 | + } |
| 133 | + exclude("META-INF/neoforge.mods.toml") |
| 134 | + } |
| 135 | +} |
| 136 | + |
| 137 | +java { |
| 138 | + withSourcesJar() |
| 139 | + JavaVersion javaVer = isNeo ? JavaVersion.VERSION_21 : (isOld ? JavaVersion.VERSION_1_8 : JavaVersion.VERSION_17) |
| 140 | + sourceCompatibility = javaVer |
| 141 | + targetCompatibility = javaVer |
| 142 | +} |
| 143 | + |
| 144 | +tasks.withType(JavaCompile).configureEach { |
| 145 | + it.options.release = isNeo ? 21 : (isOld ? 8 : 17) |
| 146 | +} |
| 147 | + |
| 148 | +String currentChangeLog = file("CHANGELOG.md").getText("UTF-8") |
| 149 | +String[] javaVersions = isNeo ? ["Java 21", "Java 22"] : (isOld ? ["Java 8", "Java 17", "Java 21", "Java 22"] : ["Java 17", "Java 21", "Java 22"]) |
| 150 | + |
| 151 | +tasks.register("publishCurseForge", TaskPublishCurseForge) { |
| 152 | + if (cf_project_id != "") { |
| 153 | + apiToken = System.getenv("CURSEFORGE_TOKEN") |
| 154 | + disableVersionDetection() |
| 155 | + |
| 156 | + UploadArtifact mainFile = upload(cf_project_id, remapJar) |
| 157 | + mainFile.displayName = "${archives_name}-${version}" |
| 158 | + mainFile.releaseType = "release" |
| 159 | + mainFile.changelog = currentChangeLog |
| 160 | + mainFile.changelogType = "markdown" |
| 161 | + mainFile.addModLoader(isNeo ? "NeoForge" : "Forge") |
| 162 | + mainFile.addJavaVersion(javaVersions) |
| 163 | + mainFile.addGameVersion(minecraft_version) |
| 164 | + if (claimIntegration) { |
| 165 | + mainFile.addOptional("ftb-chunks-forge") |
| 166 | + if (!isOld) mainFile.addOptional("open-parties-and-claims") |
| 167 | + } |
| 168 | + if (embeddiumIntegration) mainFile.addOptional("embeddium") |
| 169 | + if (useDuplicationLess) mainFile.addRequirement("duplicationless") |
| 170 | + |
| 171 | + UploadArtifact sourcesFile = mainFile.withAdditionalFile(sourcesJar) |
| 172 | + sourcesFile.changelog = currentChangeLog |
| 173 | + sourcesFile.changelogType = "markdown" |
| 174 | + } |
| 175 | +} |
0 commit comments