Files
MidnightLib/neoforge/build.gradle
Martin Prokoph 3db1c1eb23 fix: crash on servers
- This makes overriding the screen less flexible, but out of all options, this was the best way to do it. Previously, the `@EnvType` annotation took care of keeping this out of the server code, but NeoForge decided to break perfectly functional behaviour once again, requiring me to remove the annotations 🫠
2025-10-03 14:55:40 +02:00

167 lines
4.6 KiB
Groovy

plugins {
id 'com.github.johnrengelman.shadow'
id "me.shedaniel.unified-publishing"
}
repositories {
maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
}
architectury {
platformSetupLoomIde()
neoForge {
platformPackage = "neoforge"
}
}
sourceSets {
test {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
java {
srcDirs.add('src/test/java' as File)
}
resources {
srcDirs.add('src/test/resources' as File)
}
}
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
runs {
testClient {
client()
name = "Test Minecraft Client"
mods {
create('midnightlib') {
sourceSet sourceSets.main
}
create('modid') { // test mod
sourceSet sourceSets.test
}
}
source sourceSets.test
}
testServer {
server()
name = "Test Minecraft Server"
mods {
create('midnightlib') {
sourceSet sourceSets.main
}
create('modid') { // test mod
sourceSet sourceSets.test
}
}
source sourceSets.test
}
}
}
configurations {
common {
canBeResolved = true
canBeConsumed = false
}
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentNeoForge.extendsFrom common
// Files in this configuration will be bundled into your mod using the Shadow plugin.
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
shadowBundle {
canBeResolved = true
canBeConsumed = false
}
archivesBaseName = rootProject.archives_base_name
version = rootProject.mod_version + "-" + project.name + "+" + rootProject.minecraft_version
}
dependencies {
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
// testImplementation common(project(path: ':common', configuration: 'namedElements')) { transitive false }
testImplementation common(project(path: ':common', configuration: 'testOutput')) { transitive false }
testImplementation sourceSets.main.output
}
processResources {
inputs.property 'version', rootProject.version
filesMatching('META-INF/neoforge.mods.toml') {
expand version: rootProject.version
}
}
processTestResources {
inputs.property 'version', rootProject.version
filesMatching('META-INF/neoforge.mods.toml') {
expand version: rootProject.version
}
}
shadowJar {
configurations = [project.configurations.shadowBundle]
archiveClassifier = 'dev-shadow'
}
remapJar {
input.set shadowJar.archiveFile
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
unifiedPublishing {
project {
displayName = "MidnightLib $rootProject.version - NeoForge $project.minecraft_version"
releaseType = "$project.release_type"
changelog = releaseChangelog()
gameVersions = []
gameLoaders = ["neoforge"]
mainPublication remapJar
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
}
}
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = rootProject.mod_version + "+" + rootProject.minecraft_version + "-" + project.name
gameVersions.addAll project.minecraft_version
if (project.supported_versions != "") gameVersions.addAll project.supported_versions
}
}
}
}