mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 23:25:10 +01:00
187 lines
7.4 KiB
Groovy
187 lines
7.4 KiB
Groovy
plugins {
|
|
id 'fabric-loom' version '1.1-SNAPSHOT'
|
|
id 'java-library'
|
|
id 'maven-publish'
|
|
id 'com.github.johnrengelman.shadow' version '7.0.0'
|
|
id 'com.modrinth.minotaur' version '2.+'
|
|
id 'net.darkhax.curseforgegradle' version '1.+'
|
|
}
|
|
|
|
import net.darkhax.curseforgegradle.TaskPublishCurseForge
|
|
|
|
group = project.maven_group
|
|
version = "${project.mod_version}+${getMCVersionString()}"
|
|
|
|
// This field defines the Java version your mod target.
|
|
def targetJavaVersion = 17
|
|
|
|
boolean isMCVersionNonRelease() {
|
|
return project.minecraft_version.matches('^\\d\\dw\\d\\d[a-z]$')
|
|
|| project.minecraft_version.matches('\\d+\\.\\d+-(pre|rc)(\\d+)')
|
|
}
|
|
|
|
String getMCVersionString() {
|
|
if (isMCVersionNonRelease() || project.minecraft_version == "1.20.4") {
|
|
return project.minecraft_version
|
|
}
|
|
def version = project.minecraft_version.split('\\.')
|
|
return version[0] + '.' + version[1]
|
|
}
|
|
|
|
boolean pingUrl(String address) {
|
|
try {
|
|
def conn = (HttpURLConnection) new URL(address).openConnection()
|
|
int responseCode = conn.getResponseCode()
|
|
return (200 <= responseCode && responseCode <= 399)
|
|
} catch (IOException ignored) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
String parseReadme() {
|
|
def excludeRegex = /(?m)<!-- modrinth_exclude\.start -->(.|\n)*?<!-- modrinth_exclude\.end -->/
|
|
def linkRegex = /!\[([A-z_ ]+)]\((images\/[A-z.\/_]+)\)/
|
|
|
|
def readme = (String) file('README.md').text
|
|
readme = readme.replaceAll(excludeRegex, '')
|
|
return readme
|
|
}
|
|
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
mavenCentral()
|
|
maven { url 'https://aperlambda.github.io/maven' }
|
|
maven {
|
|
name 'Gegy'
|
|
url 'https://maven.gegy.dev'
|
|
}
|
|
maven {
|
|
name = "CottonMC"
|
|
url = "https://server.bbkr.space/artifactory/libs-release"
|
|
}
|
|
maven { url "https://maven.terraformersmc.com/releases/" }
|
|
maven { url 'https://maven.kosmx.dev' }
|
|
maven { url 'https://maven.isxander.dev/releases' }
|
|
maven { url 'https://maven.shedaniel.me/' }
|
|
maven { url 'https://jitpack.io' }
|
|
maven { url "https://api.modrinth.com/maven" }
|
|
maven { url 'https://maven.quiltmc.org/repository/release'}
|
|
}
|
|
|
|
configurations {
|
|
shadow
|
|
api.extendsFrom shadow
|
|
}
|
|
|
|
dependencies {
|
|
//to change the versions see the gradle.properties file
|
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
|
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
|
|
|
modImplementation ("dev.lambdaurora:spruceui:${project.spruceui_version}") {
|
|
exclude(group: "net.fabricmc.fabric-api")
|
|
}
|
|
include "dev.lambdaurora:spruceui:${project.spruceui_version}"
|
|
api('org.aperlambda:lambdajcommon:1.8.1') {
|
|
exclude group: 'com.google.code.gson'
|
|
exclude group: 'com.google.guava'
|
|
}
|
|
include 'org.aperlambda:lambdajcommon:1.8.1'
|
|
|
|
modCompileOnlyApi ("com.terraformersmc:modmenu:${project.modmenu_version}") {
|
|
exclude(group: "net.fabricmc.fabric-api")
|
|
}
|
|
|
|
// Compatibility mods
|
|
|
|
// Ok Zoomer and LibZoomer are temporarily disabled for the time being, as we are currently using Reflection at runtime instead in OkZoomerCompat due to there being two major, completely incompatible API versions.
|
|
// modImplementation("maven.modrinth:ok-zoomer:${project.ok_zoomer_version}")
|
|
// modImplementation "io.github.ennuil:LibZoomer:${project.libzoomer_version}"
|
|
|
|
modCompileOnlyApi "io.github.cottonmc:LibGui:${project.libgui_version}"
|
|
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
|
|
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}"
|
|
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
|
|
modCompileOnlyApi "maven.modrinth:emotecraft:${project.emotecraft_version}"
|
|
modCompileOnlyApi "io.github.kosmx:bendy-lib:${project.bendylib_version}"
|
|
modCompileOnlyApi "dev.isxander:yet-another-config-lib:${project.yacl_version}"
|
|
modCompileOnlyApi "maven.modrinth:inventory-tabs-updated:${project.inventorytabs_version}"
|
|
modCompileOnlyApi "maven.modrinth:bedrockify:${project.bedrockify_version}"
|
|
// Required for Inventory Tabs
|
|
modCompileOnlyApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") {
|
|
exclude(group: "net.fabricmc.fabric-api")
|
|
}
|
|
|
|
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
|
|
include "maven.modrinth:midnightlib:${project.midnightlib_version}"
|
|
|
|
shadow 'com.electronwill.night-config:core:3.6.3'
|
|
shadow 'com.electronwill.night-config:toml:3.6.3'
|
|
apply plugin: 'java-library'
|
|
}
|
|
loom {
|
|
accessWidenerPath = file("src/main/resources/midnightcontrols.accesswidener")
|
|
}
|
|
|
|
java {
|
|
sourceCompatibility = JavaVersion.toVersion(targetJavaVersion)
|
|
targetCompatibility = JavaVersion.toVersion(targetJavaVersion)
|
|
|
|
withSourcesJar()
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
it.options.encoding = 'UTF-8'
|
|
|
|
it.options.release.set(targetJavaVersion)
|
|
}
|
|
|
|
processResources {
|
|
inputs.property 'version', project.version
|
|
|
|
filesMatching('fabric.mod.json') {
|
|
expand 'version': project.version
|
|
}
|
|
}
|
|
modrinth {
|
|
token = System.getenv("MODRINTH_TOKEN") // Remember to have the MODRINTH_TOKEN environment variable set or else this will fail - just make sure it stays private!
|
|
projectId = project.archives_base_name // This can be the project ID or the slug. Either will work!
|
|
versionNumber = project.version // You don't need to set this manually. Will fail if Modrinth has this version already
|
|
versionName = "MidnightControls " + project.mod_version + " - " + project.minecraft_version
|
|
versionType = isMCVersionNonRelease() ? "beta" : "release" // Can also be `beta` or `alpha`
|
|
uploadFile = remapJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
|
|
gameVersions = [(String) project.minecraft_version] // Must be an array, even with only one version
|
|
loaders = ["fabric","quilt"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
|
|
dependencies { // A special DSL for creating dependencies
|
|
// scope.type
|
|
// The scope can be `required`, `optional`, `incompatible`, or `embedded`
|
|
// The type can either be `project` or `version`
|
|
required.project "midnightlib" // Creates a new required dependency on MidnightLib
|
|
}
|
|
changelog = project.changelog
|
|
}
|
|
tasks.register('publishCurseForge', TaskPublishCurseForge) {
|
|
|
|
// This token is used to authenticate with CurseForge. It should be handled
|
|
// with the same level of care and security as your actual password. You
|
|
// should never share your token with an untrusted source or publish it
|
|
// publicly to GitHub or embed it within a project. The best practice is to
|
|
// store this token in an environment variable or a build secret.
|
|
apiToken = System.getenv("CURSEFORGE_TOKEN")
|
|
|
|
// Tells CurseForgeGradle to publish the output of the jar task. This will
|
|
// return a UploadArtifact object that can be used to further configure the
|
|
// file.
|
|
def mainFile = upload(project.curseforge_id, remapJar)
|
|
mainFile.changelog = project.changelog
|
|
mainFile.displayName = "MidnightControls " + project.mod_version + " - " + project.minecraft_version
|
|
mainFile.addModLoader("Fabric", "Quilt")
|
|
mainFile.addRequirement("midnightlib")
|
|
mainFile.releaseType = "release"
|
|
}
|