Remove Unimined and restore Architectury build system

This commit is contained in:
James Seibel
2024-04-24 22:05:59 -05:00
parent ffda83c25d
commit 6c4740e8aa
8 changed files with 420 additions and 341 deletions
+157 -115
View File
@@ -7,16 +7,11 @@ plugins {
// Plugin to create merged jars
id "io.github.pacifistmc.forgix" version "1.2.6"
// Unimined is our all in one solution to minecraft loaders
// id "xyz.wagyourtail.unimined" version "1.2.0-SNAPSHOT" apply false // Unstable Release (TODO: Check back to see when the unstable branch fixes forge run without the jank)
id "xyz.wagyourtail.unimined" version "1.1.2-SNAPSHOT" apply false // LTS Release
}
// Manifold preprocessor
id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha"
// Transfers the values set in settings.gradle to the rest of the project
project.gradle.ext.getProperties().each { prop ->
rootProject.ext.set(prop.key, prop.value)
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
// Architectury is used here only as a replacement for forge's own loom
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
}
@@ -54,6 +49,14 @@ def writeBuildGradlePredefine(List<String> mcVers, int mcIndex)
new File(projectDir, "build.properties").text = sb.toString()
}
// Transfers the values set in settings.gradle to the rest of the project
project.gradle.ext.getProperties().each { prop ->
rootProject.ext.set(prop.key, prop.value)
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
}
// Sets up manifold stuff
writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex)
@@ -61,7 +64,6 @@ writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex)
// Sets up the version string (the name we use for our jar)
rootProject.versionStr = rootProject.mod_version + "-" + rootProject.minecraft_version // + "-" + new Date().format("yyyy_MM_dd_HH_mm")
// Forgix settings (used for merging jars)
forgix {
group = "com.seibel.distanthorizons"
@@ -92,7 +94,7 @@ forgix {
}
subprojects { p ->
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":forge") || p == project("WhateverLoaderWeAddLaterOn")"
// Does the same as "p == project(":common") || p == project(":fabric") || p == project(":quilt") || p == project(":forge") || p == project("WhateverWeAddLaterOn")"
// Useful later on so we dont have duplicated code
def isMinecraftSubProject = p != project(":core") && p != project(":api")
@@ -100,68 +102,72 @@ subprojects { p ->
// Apply plugins
apply plugin: "java"
apply plugin: "com.github.johnrengelman.shadow"
if (isMinecraftSubProject)
apply plugin: "systems.manifold.manifold-gradle-plugin"
if (p == project(":core"))
apply plugin: "application"
if (isMinecraftSubProject) {
apply plugin: "xyz.wagyourtail.unimined"
// Apply forge's loom
if (
(findProject(":forge") && p == project(":forge")) ||
(findProject(":neoforge") && p == project(":neoforge"))
)
apply plugin: "dev.architectury.loom"
unimined.minecraft(sourceSets.main, true) {
version = rootProject.minecraft_version
def parchmentVersionParts = rootProject.parchment_version.split(":")
mappings {
mojmap()
parchment(parchmentVersionParts[0], parchmentVersionParts[1])
devNamespace "mojmap"
}
runs {
config("client") {
workingDir = rootProject.file("run")
}
config("server") {
workingDir = rootProject.file("run") // TODO: When running the server, would it be a better idea to change this to a different dir?
disabled = true // TODO: Once server-side support is added, remove this
}
}
}
if (p != project(":common")) {
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.java)
source(project(":api").sourceSets.main.java)
source(project(":core").sourceSets.main.java)
}
}
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// Disable testing for projects that aren't the core or api project.
// If not done compiling will fail due to an issue with Manifold
if (isMinecraftSubProject) {
test {
enabled = false
}
compileTestJava {
enabled = false
}
// Set the manifold version (may not be required tough)
manifold {
manifoldVersion = rootProject.manifold_version
}
// set up custom configurations (configurations are a way to handle dependencies)
configurations {
// extends the shadowJar configuration
shadowMc // Configuration that doesn't contain coreProjects
shadowMe
// have implemented dependencies automatically embedded in the final jar
implementation.extendsFrom(shadowMc)
implementation.extendsFrom(shadowMe)
// Add shaded libraries very early in the classpath (excluding coreProjects as that's added in a different way)
minecraftLibraries.extendsFrom(shadowMc)
// Configuration fpr core & api
coreProjects
shadowMe.extendsFrom(coreProjects)
// FIXME this additional configuration is necessary because forge
// needs forgeRuntimeLibrary, although adding it to shadowMe
// causes runtime issues where the libraries aren't properly added
forgeShadowMe
// this should match shadowMe pretty closely
implementation.extendsFrom(forgeShadowMe)
shadowMe.extendsFrom(forgeShadowMe)
forgeRuntimeLibrary.extendsFrom(forgeShadowMe)
if (isMinecraftSubProject && p != project(":common")) {
// Shadow common
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
if (findProject(":forge"))
developmentForge.extendsFrom common
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom common
compileClasspath.extendsFrom coreProjects
runtimeClasspath.extendsFrom coreProjects
if (findProject(":forge"))
developmentForge.extendsFrom coreProjects
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom coreProjects
if (findProject(":fabricLike") && p != project(":fabricLike")) {
// Shadow fabricLike
fabricLike
shadowFabricLike
compileClasspath.extendsFrom fabricLike
runtimeClasspath.extendsFrom fabricLike
}
}
}
@@ -173,7 +179,7 @@ subprojects { p ->
}
}
dependencies { // TODO: Move the libraries only used in core to the core's build.gradle (Remember to also move the shadowJar stuff over there)
dependencies {
//=====================//
// shared dependencies //
//=====================//
@@ -184,47 +190,46 @@ subprojects { p ->
}
// Log4j
// TODO: Change to shadowCore later to work in the standalone jar
// TODO: Change to shadowMe later to work in the standalone jar
// We cannot do this now as it would break Quilt
implementation("org.apache.logging.log4j:log4j-api:${rootProject.log4j_version}")
implementation("org.apache.logging.log4j:log4j-core:${rootProject.log4j_version}")
// JOML
if (project.hasProperty("embed_joml") && embed_joml == "true")
forgeShadowMe("org.joml:joml:${rootProject.joml_version}")
else
implementation("org.joml:joml:${rootProject.joml_version}")
// JUnit tests
implementation("org.junit.jupiter:junit-jupiter:5.8.2")
implementation("org.junit.jupiter:junit-jupiter-engine:5.8.2")
implementation("junit:junit:4.13")
// javax.annotation's (IE @Nullable)
// only needed at compile time to prevent issues between javax.annotation's and org.jetbrains.annotations
implementation("com.google.code.findbugs:jsr305:3.0.2")
// JOML
if (project.hasProperty("embed_joml") && embed_joml == "true")
shadowMc("org.joml:joml:${rootProject.joml_version}")
else
implementation("org.joml:joml:${rootProject.joml_version}")
// Compression
shadowMc("org.lz4:lz4-java:${rootProject.lz4_version}") // LZ4
shadowMc("com.github.luben:zstd-jni:${rootProject.zstd_version}") // Zstd
shadowMc("org.tukaani:xz:${rootProject.xz_version}") // LZMA
forgeShadowMe("org.lz4:lz4-java:${rootProject.lz4_version}") // LZ4
forgeShadowMe("com.github.luben:zstd-jni:${rootProject.zstd_version}") // Zstd
forgeShadowMe("org.tukaani:xz:${rootProject.xz_version}") // LZMA
// Sqlite Database
shadowMc("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}")
forgeShadowMe("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}")
// NightConfig (includes Toml & Json)
shadowMc("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
shadowMc("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
forgeShadowMe("com.electronwill.night-config:toml:${rootProject.nightconfig_version}")
forgeShadowMe("com.electronwill.night-config:json:${rootProject.nightconfig_version}")
// Fastutil
forgeShadowMe("it.unimi.dsi:fastutil:${rootProject.fastutil_version}")
// SVG (not needed atm)
//shadowMc("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
// forgeShadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
// Netty
// Breaks 1.16.5
//shadowMc("io.netty:netty-all:${rootProject.netty_version}")
//forgeShadowMe("io.netty:netty-all:${rootProject.netty_version}")
// Remember, for lwjgl dependencies that arent included in Minecraft, you need to also need to add it to the ShadowJar thing
shadowMc("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") {
forgeShadowMe("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") {
exclude group: "org.lwjgl", module: "lwjgl" // This module is imported by Minecraft so exclude it
}
@@ -237,12 +242,11 @@ subprojects { p ->
// Add core
if (isMinecraftSubProject) {
compileOnly(project(path: ':core', configuration: 'shadowedArtifact')) {
coreProjects(project(":core")) {
// Remove Junit test libraries
exclude group: "org.junit.jupiter", module: "junit-jupiter"
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
exclude group: "junit", module: "junit"
// Removed dependencies
transitive false
}
@@ -250,12 +254,11 @@ subprojects { p ->
// Add the api
if (p != project(":api")) {
implementation(project(":api")) {
coreProjects(project(":api")) {
// Remove Junit test libraries
exclude group: "org.junit.jupiter", module: "junit-jupiter"
exclude group: "org.junit.jupiter", module: "junit-jupiter-engine"
exclude group: "junit", module: "junit"
// Removed dependencies
transitive false
}
@@ -264,19 +267,29 @@ subprojects { p ->
// Add common
if (isMinecraftSubProject && p != project(":common")) {
// Common
compileOnly(project(":common")) { transitive false }
common(project(":common")) { transitive false }
shadowCommon(project(":common")) { transitive false }
// FabricLike
if (findProject(":fabricLike") && p != project(":fabricLike")) {
fabricLike(project(path: ":fabricLike")) { transitive false }
shadowFabricLike(project(path: ":fabricLike")) { transitive false }
}
}
}
shadowJar {
configurations = [project.configurations.shadowMc]
configurations = [project.configurations.shadowMe]
if (isMinecraftSubProject && p != project(":common")) {
configurations.push(project.configurations.shadowCommon) // Shadow the common subproject
relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location
if (findProject(":fabricLike") && p != project(":fabricLike")) {
configurations.push(project.configurations.shadowFabricLike) // Shadow the fabricLike subproject
relocate "com.seibel.distanthorizons.fabriclike", "loaderCommon.${p.name}.com.seibel.distanthorizons.fabriclike" // Move the loader files to a different location
}
}
def librariesLocation = "distanthorizons.libraries"
// LWJGL
@@ -294,6 +307,9 @@ subprojects { p ->
if (project.hasProperty("embed_joml") && embed_joml == "true")
relocate "org.joml", "${librariesLocation}.joml"
// FastUtil
relocate "it.unimi.dsi.fastutil", "${librariesLocation}.unimi.dsi.fastutil"
// NightConfig (includes Toml & Json)
relocate "com.electronwill.nightconfig", "${librariesLocation}.electronwill.nightconfig"
@@ -311,20 +327,7 @@ subprojects { p ->
// Put stuff from gradle.properties into the mod info
processResources {
duplicatesStrategy = DuplicatesStrategy.WARN
// Include all the resources
from project(":common").sourceSets.main.resources
from project(":core").sourceSets.main.resources
from project(":api").sourceSets.main.resources
// Copy accessWideners
// FIXME: remove copyCommonLoaderResources and use this instead (and if you are removing that task, also remove copyCoreResources while your at it)
// from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
// into(file(p.file("build/resources/main")))
rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener"
// Location of where to inject the properties
def resourceTargets = [
def resourceTargets = [ // Location of where to inject the properties
// Holds info like git commit
// TODO: For some reason this script doesnt work with the core project
"build_info.json",
@@ -337,7 +340,7 @@ subprojects { p ->
// The mixins for each of the loaders
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
]
def buildResourceTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
def intoTargets = ["$buildDir/resources/main/"] // Location of the built resources folder
// Fix forge version numbering system as it is weird
// For whatever reason forge uses [1.18, 1.18.1, 1.18.2) instead of the standard ["1.18", "1.18.1", "1.18.2"]
@@ -345,7 +348,7 @@ subprojects { p ->
// println compatible_forgemc_versions
// Quilt's custom contributors system
// has to be in the format:
// This has to be like
// "Person": "Developer", "Another person": "Developer"
def quilt_contributors = []
def mod_author_list = mod_authors.replaceAll("\"", "").replace("[", "").replace("]", "").split(",")
@@ -397,14 +400,12 @@ subprojects { p ->
// replace any properties in the sub-projects with the values defined here
inputs.properties replaceProperties
replaceProperties.put("project", project)
replaceProperties.put "project", project
filesMatching(resourceTargets) {
expand replaceProperties
}
// copy all our resources into the loader specific resource directory
buildResourceTargets.each { target ->
intoTargets.each { target ->
if (file(target).exists()) {
copy {
from(sourceSets.main.resources) {
@@ -561,23 +562,64 @@ allprojects { p ->
// TODO: If neoforged is ever needed, should we use that, or call it a forge mod?
}
// Adds some dependencies that are in vanilla but not in core
if (p == project(":core")) {
OperatingSystem os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
// Set the OS lwjgl is using to the current os
project.ext.lwjglNatives = "natives-" + os.toFamilyName()
dependencies { // All of these dependencies are in Vanilla Minecraft, but we need to depend on it as we arent importing Minecraft in the core
// Imports most of lwjgl's libraries (well, only the ones that we need)
implementation platform("org.lwjgl:lwjgl-bom:${rootProject.lwjgl_version}") // TODO: Use Minecraft's version for lwjgl_version (which changes in nearly every version) instead of a hard defined version for all versions
// REMEMBER: Dont shadow stuff here, these are just the libs that are included in Minecraft so that the core can use
implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-assimp"
implementation "org.lwjgl:lwjgl-glfw"
implementation "org.lwjgl:lwjgl-openal"
implementation "org.lwjgl:lwjgl-opengl"
implementation "org.lwjgl:lwjgl-stb"
implementation "org.lwjgl:lwjgl-tinyfd"
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives"
implementation "org.joml:joml:${rootProject.joml_version}"
// Some other dependencies
implementation("org.jetbrains:annotations:16.0.2")
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("com.google.common:google-collect:0.5")
implementation("com.google.guava:guava:31.1-jre")
}
}
// TODO: Remove this as no loader needs this
// - Fabric can rename which aw they use
// - (Neo)Forge converts the aw to their own at, which is stored at a different place
task copyCommonLoaderResources(type: Copy) {
from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
into(file(p.file("build/resources/main")))
rename "${accessWidenerVersion}.distanthorizons.accesswidener", "distanthorizons.accesswidener"
// Move the fabricLike mixin to its different places for each subproject
if (findProject(":fabricLike")) {
from project(":fabricLike").file("src/main/resources/DistantHorizons.fabricLike.mixins.json")
into(file(p.file("build/resources/main")))
rename "DistantHorizons.fabricLike.mixins.json", "DistantHorizons." + p.name + ".fabricLike.mixins.json"
}
}
// TODO: Remove this later as we no longer need this. We are now including the resources in the processResources section
task copyCoreResources(type: Copy) {
from fileTree(project(":core").file("src/main/resources"))
into p.file("build/resources/main")
}
compileJava {
tasks.withType(JavaCompile) {
if (isMinecraftSubProject) {
options.release = rootProject.java_version as Integer
options.compilerArgs += ["-Xplugin:Manifold"]
+21 -12
View File
@@ -1,21 +1,30 @@
// Use Unimined's implimentation for MC as we can use Parchment mappings in common now! :tada:
// With Sponge's vanilla gradle, we cannot change the mappings to anything out of mojmaps
unimined.minecraft {
fabric { // TODO: Find a way to only include the mc stuff, not fabric's loader
loader rootProject.fabric_loader_version
accessWidener(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))
skipInsertAw = true
}
plugins {
id "org.spongepowered.gradle.vanilla" version "0.2.1-SNAPSHOT"
}
defaultRemapJar = false
minecraft {
accessWideners(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))
version(rootProject.minecraft_version)
}
dependencies {
// So mixins can be written in common
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
}
tasks.register('prepareWorkspace') {
// the build system complains if prepareWorkspace isn't present
publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.mod_readable_name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}
+55 -43
View File
@@ -1,49 +1,76 @@
unimined.minecraft {
fabric {
loader rootProject.fabric_loader_version
accessWidener(project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"))
plugins {
id "fabric-loom" version "1.6-SNAPSHOT"
}
skipInsertAw = true
loom {
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
// "runs" isn't required, but when we do need it then it can be useful
runs {
client {
client()
setConfigName("Fabric Client")
ideConfigGenerated(true)
runDir("../run")
}
server {
server()
setConfigName("Fabric Server")
ideConfigGenerated(true)
runDir("../run")
}
}
}
remapJar {
inputFile = shadowJar.archiveFile
dependsOn shadowJar
// classifier null
}
configurations {
// The addModJar basically embeds the mod to the built jar
addModJar
include.extendsFrom addModJar
modImplementation.extendsFrom addModJar
dummy
}
def addMod(path, enabled) {
if (enabled == "2")
dependencies { modImplementation(path) }
else if (enabled == "1")
dependencies { compileOnly(path) }
}
// TODO: There currently seems to be a bug which causes the regular addModJar to not work, swap back to the regular addModJar when fixed
def addModJar_(path) {
dependencies {
modImplementation(path)
include(path)
}
dependencies { modCompileOnly(path) }
}
dependencies {
annotationProcessor "javax.annotation:javax.annotation-api:1.3.2"
implementation("javax.annotation:javax.annotation-api:1.3.2")
runtimeOnly "javax.annotation:javax.annotation-api:1.3.2"
compileOnly "javax.annotation:javax.annotation-api:1.3.2"
modImplementation "javax.annotation:javax.annotation-api:1.3.2"
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.layered() {
// Mojmap mappings
officialMojangMappings()
// Parchment mappings (it adds parameter mappings & javadoc)
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
}
// Fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// annotationProcessor "javax.annotation:javax.annotation-api:1.3.2"
// implementation("javax.annotation:javax.annotation-api:1.3.2")
// runtimeOnly "javax.annotation:javax.annotation-api:1.3.2"
// compileOnly "javax.annotation:javax.annotation-api:1.3.2"
// modImplementation "javax.annotation:javax.annotation-api:1.3.2"
// Fabric API
addModJar_(fabricApi.fabricModule("fabric-api-base", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-resource-loader-v0", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-events-interaction-v0", rootProject.fabric_api_version))
addModJar_(fabricApi.fabricModule("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy)
addModJar_(fabricApi.fabricModule("fabric-networking-api-v1", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version))
addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy)
addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version))
// Mod Menu
modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}")
@@ -105,6 +132,7 @@ remapJar {
}
task deleteResources(type: Delete) {
delete file("build/resources/main")
}
@@ -114,31 +142,15 @@ processResources {
dependsOn(copyCommonLoaderResources)
}
afterEvaluate {
runClient {
runClient {
dependsOn(copyCoreResources)
dependsOn(copyCommonLoaderResources)
// jvmArgs([ "-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg ])
finalizedBy(deleteResources)
}
}
//jar {
// classifier "dev"
//}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
// def fabricLikeSources = project(":fabricLike").sourcesJar
// dependsOn fabricLikeSources
// from fabricLikeSources.archiveFile.map { zipTree(it) }
}
//components.java {
// withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
// skip()
// }
//}
+75 -97
View File
@@ -1,76 +1,51 @@
unimined.minecraft {
minecraftForge {
loader forge_version
mixinConfig("DistantHorizons.forge.mixins.json")
file("build/sourcesSets/main/META-INF/").mkdirs()
accessTransformer(aw2at(
project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"),
file("build/sourcesSets/main/META-INF/accesstransformer.cfg") // We'd wanna output the access transformer to somewhere where it'll only appear in the final jar
))
}
plugins {
// Note: This is only needed for multi-loader projects
// The main architectury loom version is set at the start of the root build.gradle
id "architectury-plugin" version "3.4-SNAPSHOT"
}
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
def addMod(path, enabled) {
if (enabled == "2")
dependencies { modImplementation(path) }
else if (enabled == "1")
dependencies { compileOnly(path) }
architectury {
platformSetupLoomIde()
forge()
}
dependencies {
// Architectury API
// if (minecraft_version == "1.16.5") {
// implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
// } else {
// implementation("dev.architectury:architectury-forge:${rootProject.architectury_version}")
//loom {
// forge {
// convertAccessWideners.set(true)
// extraAccessWideners.add("lod.accesswidener")
// mixinConfigs("DistantHorizons.mixins.json")
// }
//}
// Starlight
addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge)
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
loom {
silentMojangMappingsLicense() // Shut the licencing warning
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
forge {
convertAccessWideners = true
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
// annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
// if (System.getProperty("idea.sync.active") != "true") {
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
// }
}
tasks.register('copyAllResources') {
dependsOn(copyCoreResources)
dependsOn(copyCommonLoaderResources)
}
processResources {
dependsOn(tasks.named('copyAllResources'))
}
afterEvaluate {
runClient {
dependsOn(tasks.named('copyAllResources'))
mixinConfigs = [
"DistantHorizons.forge.mixins.json"
]
}
// TODO this isn't a great place for these, but `tasks.build.doLast` doesn't always work and I'm not sure of a better place right now
tasks.runClient.doFirst {
// TODO can we just ignore these folders instead?
// deleting them may cause issues if the OS locks the files
// and it feels hacky
try
{
delete file("../common/build/libs")
delete file("../coreSubProjects/core/build/libs")
delete file("../coreSubProjects/api/build/libs")
// "runs" isn't required, but when we do need it then it can be useful
runs {
client {
client()
setConfigName("Forge Client")
ideConfigGenerated(true)
runDir("../run")
// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
}
catch (ignored)
{
println('lib directories already deleted')
server {
server()
setConfigName("Forge Server")
ideConfigGenerated(true)
runDir("../run")
}
}
}
@@ -78,45 +53,48 @@ afterEvaluate {
remapJar {
inputFile = shadowJar.archiveFile
dependsOn shadowJar
// classifier null
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
def addMod(path, enabled) {
if (enabled == "2")
dependencies { implementation(path) }
else if (enabled == "1")
dependencies { modCompileOnly(path) }
}
//components.java {
// withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
// skip()
// }
//}
// TODO this was specifically added for MC 1.20.4 and should not be used on MC versions prior to it
// source: https://github.com/MinecraftForge/MinecraftForge/blob/5d0047753dfac0caaf5d97cc3f5c9a8b0990cb44/mdk/build.gradle#L209-L217
//
// Merge the resources and classes into the same directory.
// This is done because java expects modules to be in a single directory.
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
sourceSets.each {
if ( // Only run on MC 1.20.4 or later
// FIXME: Add an environment variable for the Major, Minor, and Patch version number of Minecraft
minecraft_version.split("\\.")[1].toInteger() >= 20 &&
(
minecraft_version.split("\\.").length > 1 && // Incase there isn't a minor version
minecraft_version.split("\\.")[2].toInteger() >= 4
)
) {
// all of our code and resources should be in the sourceSets/main/ folder for Forge 1.20.4+
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
println "source name: [" + it.name + "]"// as of 2024-2-4 "it.name" only returned "main" and "test"
it.output.resourcesDir = dir
it.java.destinationDirectory = dir
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
// Mojmap mappings
officialMojangMappings()
// Parchment mappings (it adds parameter mappings & javadoc)
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
}
// Forge
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
}
task deleteResources(type: Delete) {
delete file("build/resources/main")
}
tasks.register('copyAllResources') {
dependsOn(copyCoreResources)
dependsOn(copyCommonLoaderResources)
}
processResources {
dependsOn(tasks.named('copyAllResources'))
}
tasks.named('runClient') {
dependsOn(tasks.named('copyAllResources'))
finalizedBy(deleteResources)
}
+84 -39
View File
@@ -1,44 +1,98 @@
unimined.minecraft {
neoForged {
loader neoforge_version
mixinConfig("DistantHorizons.neoforge.mixins.json")
plugins {
// Note: This is only needed for multi-loader projects
// The main architectury loom version is set at the start of the root build.gradle
id "architectury-plugin" version "3.4-SNAPSHOT"
}
file("build/sourcesSets/main/META-INF/").mkdirs()
accessTransformer(aw2at(
project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener"),
file("build/sourcesSets/main/META-INF/accesstransformer.cfg") // We'd wanna output the access transformer to somewhere where it'll only appear in the final jar
))
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
architectury {
platformSetupLoomIde()
neoForge()
}
// TODO this is already defined in the main settings.gradle file, why doesn't it work unless also defined here? (If compiling does work without this block feel free to remove)
repositories {
maven {
name "Neoforge"
url "https://maven.neoforged.net/releases/"
}
}
//loom {
// forge {
// convertAccessWideners.set(true)
// extraAccessWideners.add("lod.accesswidener")
// mixinConfigs("DistantHorizons.mixins.json")
// }
//}
loom {
silentMojangMappingsLicense() // Shut the licencing warning
accessWidenerPath = project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
neoForge {
// Access wideners are now defined in the `remapJar.atAccessWideners`
// convertAccessWideners = true
// extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
// Mixins are now defined in the `mods.toml`
// mixinConfigs = [
// "DistantHorizons.mixins.json"
// ]
}
mixin {
// Mixins are now defined in the `mods.toml`
// mixinConfigs = [
// "DistantHorizons.mixins.json"
// ]
}
// "runs" isn't required, but when we do need it then it can be useful
runs {
client {
client()
setConfigName("NeoForge Client")
ideConfigGenerated(true)
runDir("../run")
// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
}
server {
server()
setConfigName("NeoForge Server")
ideConfigGenerated(true)
runDir("../run")
}
}
}
remapJar {
inputFile = shadowJar.archiveFile
dependsOn shadowJar
// classifier null
atAccessWideners.add("distanthorizons.accesswidener")
}
def addMod(path, enabled) {
if (enabled == "2")
dependencies { modImplementation(path) }
dependencies { implementation(path) }
else if (enabled == "1")
dependencies { compileOnly(path) }
dependencies { modCompileOnly(path) }
}
dependencies {
// Architectury API
// if (minecraft_version == "1.16.5") {
// implementation("me.shedaniel:architectury-forge:${rootProject.architectury_version}")
// } else {
// implementation("dev.architectury:architectury-forge:${rootProject.architectury_version}")
// }
// Starlight
addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge)
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
addMod("curse.maven:TerraForged-363820:${rootProject.terraforged_version}", rootProject.enable_terraforged)
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
// Mojmap mappings
officialMojangMappings()
// Parchment mappings (it adds parameter mappings & javadoc)
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
}
// Neoforge
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
// annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
// if (System.getProperty("idea.sync.active") != "true") {
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
// }
}
task deleteResources(type: Delete) {
@@ -54,20 +108,11 @@ processResources {
dependsOn(tasks.named('copyAllResources'))
}
afterEvaluate {
runClient {
tasks.named('runClient') {
dependsOn(tasks.named('copyAllResources'))
finalizedBy(deleteResources)
}
}
remapJar {
inputFile = shadowJar.archiveFile
dependsOn shadowJar
// classifier null
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
+5 -12
View File
@@ -10,9 +10,13 @@ pluginManagement {
url "https://maven.minecraftforge.net/"
}
maven {
name "NeoForge"
name "NeoForge Releases"
url "https://maven.neoforged.net/releases/"
}
maven {
name "NeoForge Snapshot"
url "https://maven.neoforged.net/snapshots/"
}
maven {
name "Architectury (Better Forge because regular Forge is annoying)" // TODO: Once we switch to NeoForge, would it's gradle work better? or will it have Forge's problems in it
url "https://maven.architectury.dev/"
@@ -29,12 +33,6 @@ pluginManagement {
name "ParchmentMC"
url "https://maven.parchmentmc.org"
}
maven {
url = "https://maven.wagyourtail.xyz/releases"
}
maven {
url = "https://maven.wagyourtail.xyz/snapshots"
}
mavenCentral()
gradlePluginPortal()
@@ -43,11 +41,6 @@ pluginManagement {
}
}
plugins {
// handles JVM and toolchain downloading
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
// Throw an error and a little help message if the user forgot to clone the core sub-project
+1 -1
View File
@@ -39,7 +39,7 @@ fabric_api_version=0.91.2+1.20.4
# (Neo)Forge loader
forge_version=49.0.30
neoforge_version=118-beta
neoforge_version=20.4.233
# (Neo)Forge mod versions
starlight_version_forge=
terraforged_version=