diff --git a/build.gradle.kts b/build.gradle.kts index c433288c28..8d003e3f9b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,17 @@ plugins { id("java") - id("fabric-loom") version("1.7.2") apply(false) + id("fabric-loom") version("1.7.3") apply(false) } val MINECRAFT_VERSION by extra { "1.21.1" } -val NEOFORGE_VERSION by extra { "21.1.62" } -val FABRIC_LOADER_VERSION by extra { "0.16.0" } -val FABRIC_API_VERSION by extra { "0.102.0+1.21.1" } -val SODIUM_FILE by extra { "sodium-LOADER-0.6.0-beta.2+mc1.21.1.jar" } +val NEOFORGE_VERSION by extra { "21.1.46" } +val FABRIC_LOADER_VERSION by extra { "0.16.4" } +val FABRIC_API_VERSION by extra { "0.103.0+1.21.1" } + +// This value can be set to null to disable Parchment. +// TODO: Re-add Parchment +val PARCHMENT_VERSION by extra { null } // https://semver.org/ val MOD_VERSION by extra { "1.8.0-beta.5" } @@ -22,17 +25,15 @@ tasks.withType { options.encoding = "UTF-8" } +tasks.jar { + enabled = false +} + subprojects { apply(plugin = "maven-publish") java.toolchain.languageVersion = JavaLanguageVersion.of(21) - repositories { - maven { - name = "ParchmentMC" - url = uri("https://maven.parchmentmc.org") - } - } fun createVersionString(): String { val builder = StringBuilder() diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 719ccd4efb..d054674ed6 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,17 +1,30 @@ -import net.fabricmc.loom.task.AbstractRemapJarTask - plugins { id("java") id("idea") - id("fabric-loom") version "1.7.2" + id("fabric-loom") version "1.7.3" id("com.github.gmazzo.buildconfig") version "5.3.5" } +repositories { + maven("https://maven.parchmentmc.org/") + + exclusiveContent { + forRepository { + maven { + name = "Modrinth" + url = uri("https://api.modrinth.com/maven") + } + } + filter { + includeGroup("maven.modrinth") + } + } +} + val MINECRAFT_VERSION: String by rootProject.extra +val PARCHMENT_VERSION: String? by rootProject.extra val FABRIC_LOADER_VERSION: String by rootProject.extra val FABRIC_API_VERSION: String by rootProject.extra -val SODIUM_VERSION: String by rootProject.extra -val SODIUM_FILE: String by rootProject.extra sourceSets.create("desktop") @@ -31,37 +44,33 @@ buildConfig { } } -// This trick hides common tasks in the IDEA list. -tasks.configureEach { - group = null -} - dependencies { minecraft(group = "com.mojang", name = "minecraft", version = MINECRAFT_VERSION) - mappings(loom.layered { + + mappings(loom.layered() { officialMojangMappings() - parchment("org.parchmentmc.data:parchment-1.21:2024.07.28@zip") + if (PARCHMENT_VERSION != null) { + parchment("org.parchmentmc.data:parchment-${MINECRAFT_VERSION}:${PARCHMENT_VERSION}@zip") + } }) - modCompileOnly("net.fabricmc:fabric-loader:$FABRIC_LOADER_VERSION") + + modImplementation("net.fabricmc:fabric-loader:$FABRIC_LOADER_VERSION") + + modCompileOnly("net.fabricmc.fabric-api:fabric-renderer-api-v1:3.2.9+1172e897d7") + + modImplementation("maven.modrinth", "sodium", "mc1.21-0.6.0-beta.2-fabric") modCompileOnly("org.antlr:antlr4-runtime:4.13.1") modCompileOnly("io.github.douira:glsl-transformer:2.0.1") modCompileOnly("org.anarres:jcpp:1.4.14") - modCompileOnly(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "fabric")))) - - modCompileOnly(files(rootDir.resolve("DHApi.jar"))) -} - -tasks.withType().forEach { - it.targetNamespace = "named" + compileOnly(files(rootDir.resolve("DHApi.jar"))) } sourceSets { val main = getByName("main") - val test = getByName("test") val headers = create("headers") val vendored = create("vendored") - val sodiumCompatibility = create("sodiumCompatibility") + val desktop = getByName("desktop") headers.apply { java { @@ -69,23 +78,15 @@ sourceSets { } } - test.apply { - java { - compileClasspath += main.compileClasspath - compileClasspath += main.output - } - } - vendored.apply { java { compileClasspath += main.compileClasspath } } - sodiumCompatibility.apply { + desktop.apply { java { - compileClasspath += main.compileClasspath - compileClasspath += main.output + srcDir("src/desktop/java") } } @@ -109,7 +110,6 @@ loom { mods { val main by creating { // to match the default mod generated for Forge sourceSet("vendored") - sourceSet("sodiumCompatibility") sourceSet("main") } } @@ -128,6 +128,15 @@ tasks { from(vendored.output.classesDirs) from(vendored.output.resourcesDir) - manifest.attributes["Main-Class"] = "net.caffeinemc.mods.sodium.desktop.LaunchWarn" + val desktop = sourceSets.getByName("desktop") + from(desktop.output.classesDirs) + from(desktop.output.resourcesDir) + + manifest.attributes["Main-Class"] = "net.irisshaders.iris.LaunchWarn" } } + +// This trick hides common tasks in the IDEA list. +tasks.configureEach { + group = null +} diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 5766d66552..34606ecfd9 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,72 +1,86 @@ plugins { - java - idea - `maven-publish` - id("fabric-loom") version("1.7.2") + id("java") + id("idea") + id("fabric-loom") version ("1.7.3") } val MINECRAFT_VERSION: String by rootProject.extra +val PARCHMENT_VERSION: String? by rootProject.extra val FABRIC_LOADER_VERSION: String by rootProject.extra val FABRIC_API_VERSION: String by rootProject.extra val MOD_VERSION: String by rootProject.extra -val SODIUM_FILE: String by rootProject.extra +repositories { + exclusiveContent { + forRepository { + maven { + name = "Modrinth" + url = uri("https://api.modrinth.com/maven") + } + } + filter { + includeGroup("maven.modrinth") + } + } +} base { archivesName.set("iris-fabric") } -sourceSets { - main.get().apply { - compileClasspath += project(":common").sourceSets.getByName("headers").output - } -} - dependencies { minecraft("com.mojang:minecraft:${MINECRAFT_VERSION}") mappings(loom.layered { officialMojangMappings() - parchment("org.parchmentmc.data:parchment-1.21:2024.07.28@zip") + if (PARCHMENT_VERSION != null) { + parchment("org.parchmentmc.data:parchment-${MINECRAFT_VERSION}:${PARCHMENT_VERSION}@zip") + } }) modImplementation("net.fabricmc:fabric-loader:$FABRIC_LOADER_VERSION") + fun addRuntimeFabricModule(name: String) { + val module = fabricApi.module(name, FABRIC_API_VERSION) + modRuntimeOnly(module) + } + fun addEmbeddedFabricModule(name: String) { val module = fabricApi.module(name, FABRIC_API_VERSION) modImplementation(module) include(module) } - fun addRuntimeFabricModule(name: String) { - val module = fabricApi.module(name, FABRIC_API_VERSION) - modRuntimeOnly(module) + fun implementAndInclude(name: String) { + modImplementation(name) + include(name) } // Fabric API modules addEmbeddedFabricModule("fabric-api-base") addEmbeddedFabricModule("fabric-key-binding-api-v1") - - modImplementation("org.antlr:antlr4-runtime:4.13.1") - include("org.antlr:antlr4-runtime:4.13.1") - modImplementation("io.github.douira:glsl-transformer:2.0.1") - include("io.github.douira:glsl-transformer:2.0.1") - modImplementation("org.anarres:jcpp:1.4.14") - include("org.anarres:jcpp:1.4.14") - - modImplementation(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "fabric")))) - - modCompileOnly(files(rootDir.resolve("DHApi.jar"))) - - modRuntimeOnly(group = "com.lodborg", name = "interval-tree", version = "1.0.0") - - addRuntimeFabricModule("fabric-api-base") addRuntimeFabricModule("fabric-block-view-api-v2") addRuntimeFabricModule("fabric-renderer-api-v1") addRuntimeFabricModule("fabric-rendering-data-attachment-v1") addRuntimeFabricModule("fabric-rendering-fluids-v1") addRuntimeFabricModule("fabric-resource-loader-v0") - implementation("com.google.code.findbugs:jsr305:3.0.1") - compileOnly(project(":common")) + modImplementation("maven.modrinth", "sodium", "mc1.21-0.6.0-beta.2-fabric") + implementAndInclude("org.antlr:antlr4-runtime:4.13.1") + implementAndInclude("io.github.douira:glsl-transformer:2.0.1") + implementAndInclude("org.anarres:jcpp:1.4.14") + + implementation(project.project(":common").sourceSets.getByName("vendored").output) + compileOnly(project.project(":common").sourceSets.getByName("headers").output) + implementation(project.project(":common").sourceSets.getByName("main").output) + + compileOnly(files(rootDir.resolve("DHApi.jar"))) +} + +tasks.named("compileTestJava").configure { + enabled = false +} + +tasks.named("test").configure { + enabled = false } loom { @@ -74,52 +88,21 @@ loom { accessWidenerPath.set(project(":common").file("src/main/resources/iris.accesswidener")) @Suppress("UnstableApiUsage") - mixin { defaultRefmapName.set("iris.refmap.json") } + mixin { defaultRefmapName.set("iris-fabric.refmap.json") } runs { named("client") { client() configName = "Fabric Client" ideConfigGenerated(true) - vmArgs("-Dmixin.debug.export=true") - runDir("run") - } - create("clientQuickplay") { - client() - configName = "Fabric Client" - ideConfigGenerated(true) - programArgs("--quickPlaySingleplayer", "\"GAMING\"") - runDir("run") - } - named("server") { - server() - configName = "Fabric Server" - ideConfigGenerated(true) runDir("run") } } } tasks { - getByName("compileTestJava") { - enabled = false - } - - getByName("test") { - enabled = false - } - - withType { - source(project(":common").sourceSets.main.get().allSource) - source(project(":common").sourceSets.getByName("desktop").allSource) - source(project(":common").sourceSets.getByName("vendored").allSource) - } - - javadoc { source(project(":common").sourceSets.main.get().allJava) } - processResources { - from(project(":common").sourceSets.main.get().resources) - + from(project.project(":common").sourceSets.main.get().resources) inputs.property("version", project.version) filesMatching("fabric.mod.json") { @@ -128,21 +111,12 @@ tasks { } jar { - from(rootDir.resolve("LICENSE.md")) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE - manifest.attributes["Main-Class"] = "net.irisshaders.iris.LaunchWarn" - } -} + from(zipTree(project.project(":common").tasks.jar.get().archiveFile)) -publishing { - publications { - register("mavenJava", MavenPublication::class) { - artifactId = base.archivesName.get() - from(components["java"]) - } + manifest.attributes["Main-Class"] = "net.irisshaders.iris.LaunchWarn" } - repositories { - maven("file://${System.getenv("local_maven")}") - } + remapJar.get().destinationDirectory = rootDir.resolve("build").resolve("libs") } diff --git a/gradle.properties b/gradle.properties index 33d00f0b0b..620fc8765c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,3 @@ org.gradle.jvmargs = -Xmx4G org.gradle.caching=true +org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 28f5fcf957..c1e5736f25 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 675398a565..e216767339 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -1,15 +1,13 @@ plugins { id("idea") - id("maven-publish") - id("net.neoforged.moddev") version "2.0.16-beta" + id("net.neoforged.moddev") version "2.0.28-beta" id("java-library") } - val MINECRAFT_VERSION: String by rootProject.extra +val PARCHMENT_VERSION: String? by rootProject.extra val NEOFORGE_VERSION: String by rootProject.extra val MOD_VERSION: String by rootProject.extra -val SODIUM_FILE: String by rootProject.extra base { archivesName = "iris-neoforge" @@ -19,6 +17,9 @@ sourceSets { } repositories { + maven("https://maven.su5ed.dev/releases") + maven("https://maven.neoforged.net/releases/") + exclusiveContent { forRepository { maven { @@ -30,24 +31,39 @@ repositories { includeGroup("maven.modrinth") } } - maven { url = uri("https://maven.neoforged.net/releases/") } - } tasks.jar { - from(rootDir.resolve("LICENSE")) + val vendored = project.project(":common").sourceSets.getByName("vendored") + from(vendored.output.classesDirs) + from(vendored.output.resourcesDir) + + val main = project.project(":common").sourceSets.getByName("main") + from(main.output.classesDirs) { + exclude("/iris.refmap.json") + } + from(main.output.resourcesDir) + + from(rootDir.resolve("LICENSE.md")) + + filesMatching("neoforge.mods.toml") { + expand(mapOf("version" to MOD_VERSION)) + } + manifest.attributes["Main-Class"] = "net.irisshaders.iris.LaunchWarn" } +tasks.jar.get().destinationDirectory = rootDir.resolve("build").resolve("libs") + neoForge { // Specify the version of NeoForge to use. version = NEOFORGE_VERSION - parchment { - // Get versions from https://parchmentmc.org/docs/getting-started - // Omit the "v"-prefix in mappingsVersion - minecraftVersion = "1.21" - mappingsVersion = "2024.07.28" + if (PARCHMENT_VERSION != null) { + parchment { + minecraftVersion = MINECRAFT_VERSION + mappingsVersion = PARCHMENT_VERSION + } } runs { @@ -59,64 +75,44 @@ neoForge { mods { create("sodium") { sourceSet(sourceSets.main.get()) + sourceSet(project.project(":common").sourceSets.main.get()) + sourceSet(project.project(":common").sourceSets.getByName("vendored")) } } } -val localRuntime = configurations.create("localRuntime") - -dependencies { - compileOnly(project(":common")) - - implementation("io.github.douira:glsl-transformer:2.0.1") - additionalRuntimeClasspath("io.github.douira:glsl-transformer:2.0.1") - jarJar("io.github.douira:glsl-transformer:[2.0.1,2.0.2]") { - isTransitive = false - } - implementation("org.anarres:jcpp:1.4.14") - additionalRuntimeClasspath("org.anarres:jcpp:1.4.14") - jarJar("org.anarres:jcpp:[1.4.14,1.4.15]") { - isTransitive = false - } - - if (!rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "neoforge")).exists()) { - throw IllegalStateException("Sodium jar doesn't exist!!! It needs to be at $SODIUM_FILE") - } - - implementation(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "neoforge")))) - - compileOnly(files(rootDir.resolve("DHApi.jar"))) +fun includeDep(dependency: String, closure: Action) { + dependencies.implementation(dependency, closure) + dependencies.jarJar(dependency, closure) } -// Sets up a dependency configuration called 'localRuntime'. -// This configuration should be used instead of 'runtimeOnly' to declare -// a dependency that will be present for runtime testing but that is -// "optional", meaning it will not be pulled by dependents of this mod. -configurations { - runtimeClasspath.get().extendsFrom(localRuntime) +fun includeDep(dependency: String) { + dependencies.implementation(dependency) + dependencies.jarJar(dependency) } -// NeoGradle compiles the game, but we don't want to add our common code to the game's code -val notNeoTask: (Task) -> Boolean = { it: Task -> !it.name.startsWith("neo") && !it.name.startsWith("compileService") } - -tasks.withType().matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.get().allSource) - source(project(":common").sourceSets.getByName("vendored").allSource) - source(project(":common").sourceSets.getByName("desktop").allSource) - source(project(":common").sourceSets.getByName("sodiumCompatibility").allSource) +fun includeAdditional(dependency: String) { + includeDep(dependency) + dependencies.additionalRuntimeClasspath(dependency) } -tasks.withType().matching(notNeoTask).configureEach { - source(project(":common").sourceSets.main.get().allJava) +tasks.named("compileTestJava").configure { + enabled = false } -tasks.withType().matching(notNeoTask).configureEach { - from(project(":common").sourceSets.main.get().resources) - from(project(":common").sourceSets.getByName("sodiumCompatibility").resources) +dependencies { + compileOnly(project.project(":common").sourceSets.main.get().output) + compileOnly(project.project(":common").sourceSets.getByName("vendored").output) + compileOnly(project.project(":common").sourceSets.getByName("headers").output) + includeDep("org.sinytra.forgified-fabric-api:fabric-api-base:0.4.42+d1308ded19") + includeDep("org.sinytra.forgified-fabric-api:fabric-renderer-api-v1:3.4.0+acb05a3919") + includeDep("org.sinytra.forgified-fabric-api:fabric-rendering-data-attachment-v1:0.3.48+73761d2e19") + includeDep("org.sinytra.forgified-fabric-api:fabric-block-view-api-v2:1.0.10+9afaaf8c19") + + implementation("maven.modrinth", "sodium", "mc1.21-0.6.0-beta.2-neoforge") + includeAdditional("org.antlr:antlr4-runtime:4.13.1") + includeAdditional("io.github.douira:glsl-transformer:2.0.1") + includeAdditional("org.anarres:jcpp:1.4.14") } java.toolchain.languageVersion = JavaLanguageVersion.of(21) - -tasks.named("compileTestJava").configure { - enabled = false -} diff --git a/settings.gradle.kts b/settings.gradle.kts index 90b22e16d2..a48a25c429 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,18 +2,9 @@ rootProject.name = "Iris" pluginManagement { repositories { - maven("https://maven.fabricmc.net/") { - name = "Fabric" - } + maven { url = uri("https://maven.fabricmc.net/") } maven { url = uri("https://maven.neoforged.net/releases/") } - - mavenCentral() gradlePluginPortal() - - maven { - name = "ParchmentMC" - url = uri("https://maven.parchmentmc.org") - } } }