diff --git a/.gitignore b/.gitignore index c18c0ad9..064a5f01 100644 --- a/.gitignore +++ b/.gitignore @@ -121,4 +121,5 @@ run/ client.txt libs/ -src/forge \ No newline at end of file +src/forge +kotlin-compiler-*.salive \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 44b575b9..a8106f20 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,8 @@ +@file:Suppress("LocalVariableName", "UnstableApiUsage") + import org.ajoberstar.grgit.Grgit import org.jetbrains.kotlin.daemon.common.toHexString +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import xyz.bluspring.kilt.gradle.AccessTransformerRemapper import java.security.MessageDigest @@ -37,77 +40,6 @@ loom { } } -repositories { - mavenCentral() - mavenLocal() - - maven("https://mvn.devos.one/releases/") { - name = "devOS Maven" - } - - maven("https://mvn.devos.one/snapshots/") { - name = "devOS Maven (Snapshots)" - } - - maven("https://jitpack.io/") { - name = "JitPack" - } - - maven("https://maven.cafeteria.dev/releases/") { - name = "Cafeteria Dev" - } - - maven("https://maven.jamieswhiteshirt.com/libs-release") { - name = "JamiesWhiteShirt Dev" - content { - includeGroup("com.jamieswhiteshirt") - } - } - - maven("https://raw.githubusercontent.com/Fuzss/modresources/main/maven/") { - name = "Fuzs Mod Resources" - } - - maven("https://maven.minecraftforge.net/") { - name = "MinecraftForge Maven" - } - - maven("https://maven.architectury.dev") { - name = "Architectury" - } - - maven("https://maven.parchmentmc.org") { - name = "ParchmentMC" - } - - flatDir { - dir("libs") - } - - // Testing mod sources - maven("https://api.modrinth.com/maven") { - name = "Modrinth" - content { - includeGroup("maven.modrinth") - } - } - - maven("https://cursemaven.com") { - name = "CurseMaven" - content { - includeGroup("curse.maven") - } - } - - maven("https://maven.terraformersmc.com/") { - name = "TerraformersMC" - } - - maven("https://maven.su5ed.dev/releases") { - name = "Su5ed" - } -} - dependencies { // To change the versions see the gradle.properties file minecraft ("com.mojang:minecraft:${property("minecraft_version")}") @@ -229,16 +161,20 @@ java { sourceCompatibility = javaVersion targetCompatibility = javaVersion - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. withSourcesJar() } +interface InjectedServices { + @get:Inject val fs: FileSystemOperations + @get:Inject val layout: ProjectLayout + @get:Inject val provider: ProviderFactory +} + tasks { register("countPatchProgress") { group = "kilt" description = "Counts the total of patches in Forge, and checks how many Kilt ForgeInjects there are, to check how much is remaining." + notCompatibleWithConfigurationCache("Must not be cached") doFirst { // Scan Forge patches dir @@ -271,6 +207,7 @@ tasks { register("tagPatches") { group = "kilt" description = "Tags the Kilt ForgeInjects with their currently tracked patch hash to ensure they are all up to date." + notCompatibleWithConfigurationCache("Must not be cached") doFirst { fun readDir(file: File) { @@ -314,28 +251,26 @@ tasks { } } + val projectVersion = project.version + processResources { - inputs.property("version", project.version) - inputs.property("loader_version", project.property("loader_version")) - inputs.property("fabric_version", project.property("fabric_version")) - inputs.property("minecraft_version", project.property("minecraft_version")) - inputs.property("fabric_kotlin_version", project.property("fabric_kotlin_version")) - inputs.property("fabric_asm_version", project.property("fabric_asm_version")) - inputs.property("forge_config_version", project.property("forgeconfigapiport_version")) - inputs.property("architectury_version", project.property("architectury_version")) + val provider = objects.newInstance().provider + val propertiesMap = mutableMapOf( + "version" to projectVersion, + "loader_version" to provider.gradleProperty("loader_version"), + "fabric_version" to provider.gradleProperty("fabric_version"), + "minecraft_version" to provider.gradleProperty("minecraft_version"), + "fabric_kotlin_version" to provider.gradleProperty("fabric_kotlin_version"), + "fabric_asm_version" to provider.gradleProperty("fabric_asm_version"), + "forge_config_version" to provider.gradleProperty("forgeconfigapiport_version"), + "architectury_version" to provider.gradleProperty("architectury_version"), + ) + propertiesMap.forEach { (key, value) -> inputs.property(key, value) } + filteringCharset = "UTF-8" filesMatching("fabric.mod.json") { - expand(mutableMapOf( - "version" to project.version, - "loader_version" to project.property("loader_version"), - "fabric_version" to project.property("fabric_version"), - "minecraft_version" to project.property("minecraft_version"), - "fabric_kotlin_version" to project.property("fabric_kotlin_version"), - "fabric_asm_version" to project.property("fabric_asm_version"), - "forge_config_version" to project.property("forgeconfigapiport_version"), - "architectury_version" to project.property("architectury_version"), - )) + expand(propertiesMap) } // Rename Forge's mods.toml, so launchers like Prism don't end up detecting it over Kilt. @@ -345,7 +280,9 @@ tasks { } compileKotlin { - kotlinOptions.jvmTarget = targetJavaVersion + compilerOptions { + jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion)) + } } jar { @@ -371,35 +308,33 @@ tasks { } } - // 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. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. + mavenLocal() } } register("setupDevEnvironment") { group = "kilt" + val services = project.objects.newInstance() doLast { - val configDir = File("$projectDir/run/config") - if (!configDir.exists()) - configDir.mkdirs() - - val loaderDepsFile = File(configDir, "fabric_loader_dependencies.json") - - if (!loaderDepsFile.exists()) - loaderDepsFile.createNewFile() - - loaderDepsFile.writeText(File("$projectDir/gradle/loader_dep_overrides.json").readText()) + val configDir = services.layout.projectDirectory.dir("run/config") + configDir.asFile.mkdirs() + + val loaderDepsFile = configDir.file("fabric_loader_dependencies.json") + val templateFile = services.layout.projectDirectory.file("gradle/loader_dep_overrides.json") + services.fs.copy { + from(templateFile) + into(loaderDepsFile) + } } } register("transformerToWidener") { group = "kilt" + notCompatibleWithConfigurationCache("Must not be cached") + val minecraft_version: String by project doLast { val remapper = AccessTransformerRemapper() val transformerFile = File("$projectDir/forge/src/main/resources/META-INF/accesstransformer.cfg") @@ -408,8 +343,8 @@ tasks { remapper.convertTransformerToWidener( transformerFile.readText(), widenerFile, - project.property("minecraft_version") as String, - layout.buildDirectory.get().asFile + minecraft_version, + layout.buildDirectory.asFile.get() ) } } @@ -423,4 +358,4 @@ fun getVersionMetadata(): String { System.getenv("GITHUB_SHA") ?: grgit.head().abbreviatedId return "+build.${commitHash.subSequence(0, 6)}${if (System.getenv("GITHUB_RUN_NUMBER") == null) "-local" else ""}" -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index e2a70215..55992f4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,3 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G - # Fabric Properties # check these on https://fabricmc.net/develop minecraft_version=1.20.1 @@ -82,4 +79,14 @@ forgerenamer_version=0.1.48 securejarhandler_version=fabric-2.1.6 # https://mvnrepository.com/artifact/org.openjdk.nashorn/nashorn-core -nashorn_version=15.4 \ No newline at end of file +nashorn_version=15.4 + + +# Gradle configuration +org.gradle.caching=true +org.gradle.parallel=true +org.gradle.parallel.threads=4 +org.gradle.configureondemand=true +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true +org.gradle.jvmargs=-Xmx2G -Dfile.encoding=UTF-8 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 81aa1c04..d6e308a6 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.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 9a868b6c..a8d873d3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,12 @@ +@file:Suppress("UnstableApiUsage") + +import org.gradle.kotlin.dsl.dir +import org.gradle.kotlin.dsl.flatDir +import org.gradle.kotlin.dsl.mavenCentral + + +enableFeaturePreview("STABLE_CONFIGURATION_CACHE") + pluginManagement { repositories { maven("https://maven.fabricmc.net/") { @@ -16,3 +25,78 @@ pluginManagement { .split("+")[0] // Ensures sentences like `+build.1` are ignored } } + +dependencyResolutionManagement { + repositories { + mavenCentral() + mavenLocal() + + maven("https://mvn.devos.one/releases/") { + name = "devOS Maven" + } + + maven("https://mvn.devos.one/snapshots/") { + name = "devOS Maven (Snapshots)" + } + + maven("https://jitpack.io/") { + name = "JitPack" + } + + maven("https://maven.cafeteria.dev/releases/") { + name = "Cafeteria Dev" + } + + maven("https://maven.jamieswhiteshirt.com/libs-release") { + name = "JamiesWhiteShirt Dev" + content { + includeGroup("com.jamieswhiteshirt") + } + } + + maven("https://raw.githubusercontent.com/Fuzss/modresources/main/maven/") { + name = "Fuzs Mod Resources" + } + + maven("https://maven.minecraftforge.net/") { + name = "MinecraftForge Maven" + } + + maven("https://maven.architectury.dev") { + name = "Architectury" + } + + maven("https://maven.parchmentmc.org") { + name = "ParchmentMC" + } + + flatDir { + dir("libs") + } + + // Testing mod sources + maven("https://api.modrinth.com/maven") { + name = "Modrinth" + content { + includeGroup("maven.modrinth") + } + } + + maven("https://cursemaven.com") { + name = "CurseMaven" + content { + includeGroup("curse.maven") + } + } + + maven("https://maven.terraformersmc.com/") { + name = "TerraformersMC" + } + + maven("https://maven.su5ed.dev/releases") { + name = "Su5ed" + } + } +} + +rootProject.name = "Kilt"