aboutsummaryrefslogtreecommitdiff
path: root/build.gradle.kts
diff options
context:
space:
mode:
Diffstat (limited to 'build.gradle.kts')
-rw-r--r--build.gradle.kts269
1 files changed, 159 insertions, 110 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 1a31f16..c8bdfdb 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -6,15 +6,19 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
-import com.google.devtools.ksp.gradle.KspTaskJvm
+import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
+import com.google.common.hash.Hashing
+import com.google.devtools.ksp.gradle.KspAATask
import com.google.gson.Gson
import com.google.gson.JsonObject
import moe.nea.licenseextractificator.LicenseDiscoveryTask
import moe.nea.mcautotranslations.gradle.CollectTranslations
import net.fabricmc.loom.LoomGradleExtension
+import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
-import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+import java.nio.charset.StandardCharsets
+import java.util.*
plugins {
java
@@ -24,15 +28,15 @@ plugins {
alias(libs.plugins.kotlin.plugin.powerassert)
alias(libs.plugins.kotlin.plugin.ksp)
// alias(libs.plugins.loom)
+ alias(libs.plugins.shadow) apply false
// TODO: use arch loom once they update to 1.8
- id("fabric-loom") version "1.9.2"
- alias(libs.plugins.shadow)
- id("moe.nea.licenseextractificator")
- id("moe.nea.mc-auto-translations") version "0.1.0"
+ id("fabric-loom") version "1.10.1"
+ id("firmament.common")
+ id("firmament.license-management")
+ alias(libs.plugins.mcAutoTranslations)
}
version = getGitTagInfo(libs.versions.minecraft.get())
-group = rootProject.property("maven_group").toString()
java {
withSourcesJar()
@@ -40,6 +44,7 @@ java {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
+
loom {
mixin.useLegacyMixinAp.set(false)
}
@@ -50,54 +55,6 @@ tasks.withType(KotlinCompile::class) {
}
}
-allprojects {
- repositories {
- mavenCentral()
- maven("https://maven.terraformersmc.com/releases/")
- maven("https://maven.shedaniel.me")
- maven("https://maven.fabricmc.net")
- maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
- maven("https://api.modrinth.com/maven") {
- content {
- includeGroup("maven.modrinth")
- }
- }
- maven("https://repo.sleeping.town") {
- content {
- includeGroup("com.unascribed")
- }
- }
- ivy("https://github.com/HotswapProjects/HotswapAgent/releases/download") {
- patternLayout {
- artifact("[revision]/[artifact]-[revision].[ext]")
- }
- content {
- includeGroup("virtual.github.hotswapagent")
- }
- metadataSources {
- artifact()
- }
- }
- maven("https://server.bbkr.space/artifactory/libs-release")
- maven("https://repo.nea.moe/releases")
- maven("https://maven.notenoughupdates.org/releases")
- maven("https://repo.nea.moe/mirror")
- maven("https://jitpack.io/") {
- content {
- includeGroupByRegex("(com|io)\\.github\\..+")
- excludeModule("io.github.cottonmc", "LibGui")
- }
- }
- maven("https://repo.hypixel.net/repository/Hypixel/")
- maven("https://maven.azureaaron.net/snapshots")
- maven("https://maven.azureaaron.net/releases")
- maven("https://www.cursemaven.com")
- maven("https://maven.isxander.dev/releases") {
- name = "Xander Maven"
- }
- mavenLocal()
- }
-}
kotlin {
sourceSets.all {
languageSettings {
@@ -123,9 +80,13 @@ fun innerJarsOf(name: String, dependency: Dependency): Provider<FileTree> {
val collectTranslations by tasks.registering(CollectTranslations::class) {
this.baseTranslations.from(file("translations/en_us.json"))
+ this.baseTranslations.from(file("translations/extra.json"))
this.classes.from(sourceSets.main.get().kotlin.classesDirectory)
}
+val shadowJar = tasks.register("shadowJar", ShadowJar::class)
+val mergedSourceSetsJar = tasks.register("mergedSourceSetsJar", ShadowJar::class)
+
val compatSourceSets: MutableSet<SourceSet> = mutableSetOf()
fun createIsolatedSourceSet(name: String, path: String = "compat/$name", isEnabled: Boolean = true): SourceSet {
val ss = sourceSets.create(name) {
@@ -135,8 +96,10 @@ fun createIsolatedSourceSet(name: String, path: String = "compat/$name", isEnabl
val mainSS = sourceSets.main.get()
val upperName = ss.name.capitalizeN()
afterEvaluate {
- tasks.named("ksp${upperName}Kotlin", KspTaskJvm::class) {
- this.options.add(SubpluginOption("apoption", "firmament.sourceset=${ss.name}"))
+ tasks.named("ksp${upperName}Kotlin", KspAATask::class) {
+ this.commandLineArgumentProviders.add { // TODO: update https://github.com/google/ksp/issues/2075
+ listOf("firmament.sourceset=${ss.name}")
+ }
}
tasks.named("compile${upperName}Kotlin", KotlinCompile::class) {
this.enabled = isEnabled
@@ -159,17 +122,20 @@ fun createIsolatedSourceSet(name: String, path: String = "compat/$name", isEnabl
extendsFrom(getByName(mainSS.annotationProcessorConfigurationName))
}
(mainSS.runtimeOnlyConfigurationName) {
- extendsFrom(getByName(ss.runtimeClasspathConfigurationName))
+ if (isEnabled)
+ extendsFrom(getByName(ss.runtimeClasspathConfigurationName))
}
("ksp$upperName") {
extendsFrom(ksp.get())
}
}
dependencies {
- runtimeOnly(ss.output)
- (ss.implementationConfigurationName)(sourceSets.main.get().output)
+ if (isEnabled)
+ runtimeOnly(ss.output)
+ (ss.implementationConfigurationName)(project.files(tasks.compileKotlin.map { it.destinationDirectory }))
+ (ss.implementationConfigurationName)(project.files(tasks.compileJava.map { it.destinationDirectory }))
}
- tasks.shadowJar {
+ mergedSourceSetsJar.configure {
from(ss.output)
}
// TODO: figure out why inheritances are not being respected by tiny kotlin names
@@ -177,8 +143,7 @@ fun createIsolatedSourceSet(name: String, path: String = "compat/$name", isEnabl
classpath.from(configurations.getByName(ss.compileClasspathConfigurationName))
}
collectTranslations {
- // TODO: this does not work, somehow
- this.classes.from(sourceSets.main.get().kotlin.classesDirectory)
+ this.classes.from(ss.kotlin.classesDirectory)
}
return ss
}
@@ -188,6 +153,11 @@ val SourceSet.modImplementationConfigurationName
loom.remapConfigurations.find {
it.targetConfigurationName.get() == this.implementationConfigurationName
}!!.sourceConfiguration
+val SourceSet.modRuntimeOnlyConfigurationName
+ get() =
+ loom.remapConfigurations.find {
+ it.targetConfigurationName.get() == this.runtimeOnlyConfigurationName
+ }!!.sourceConfiguration
val shadowMe by configurations.creating {
exclude(group = "org.jetbrains.kotlin")
@@ -215,14 +185,17 @@ val testAgent by configurations.creating {
}
-val configuredSourceSet = createIsolatedSourceSet("configured",
- isEnabled = false) // Wait for update (also low prio, because configured sucks)
+val configuredSourceSet = createIsolatedSourceSet(
+ "configured",
+ isEnabled = false
+) // Wait for update (also low prio, because configured sucks)
val sodiumSourceSet = createIsolatedSourceSet("sodium", isEnabled = false)
val citResewnSourceSet = createIsolatedSourceSet("citresewn", isEnabled = false) // TODO: Wait for update
val yaclSourceSet = createIsolatedSourceSet("yacl")
val explosiveEnhancementSourceSet =
createIsolatedSourceSet("explosiveEnhancement", isEnabled = false) // TODO: wait for their port
val wildfireGenderSourceSet = createIsolatedSourceSet("wildfireGender")
+val jadeSourceSet = createIsolatedSourceSet("jade")
val modmenuSourceSet = createIsolatedSourceSet("modmenu")
val reiSourceSet = createIsolatedSourceSet("rei")
val moulconfigSourceSet = createIsolatedSourceSet("moulconfig")
@@ -247,16 +220,15 @@ dependencies {
(explosiveEnhancementSourceSet.modImplementationConfigurationName)(libs.explosiveenhancement)
modImplementation(libs.hypixelmodapi)
include(libs.hypixelmodapi.fabric)
- compileOnly(project(":javaplugin"))
- annotationProcessor(project(":javaplugin"))
- implementation("com.google.auto.service:auto-service-annotations:1.1.1")
+ compileOnly(projects.javaplugin)
+ annotationProcessor(projects.javaplugin)
+ nonModImplentation("com.google.auto.service:auto-service-annotations:1.1.1")
ksp("dev.zacsweers.autoservice:auto-service-ksp:1.2.0")
include(libs.manninghamMills)
- include(libs.moulconfig)
-
+ shadowMe(libs.moulconfig)
annotationProcessor(libs.mixinextras)
- implementation(libs.mixinextras)
+ nonModImplentation(libs.mixinextras)
include(libs.mixinextras)
nonModImplentation(libs.nealisp)
@@ -264,7 +236,6 @@ dependencies {
modCompileOnly(libs.fabric.api)
modRuntimeOnly(libs.fabric.api.deprecated)
- modApi(libs.architectury)
modCompileOnly(libs.jarvis.api)
include(libs.jarvis.fabric)
@@ -272,6 +243,7 @@ dependencies {
(wildfireGenderSourceSet.implementationConfigurationName)(customTexturesSourceSet.output)
(configuredSourceSet.modImplementationConfigurationName)(libs.configured)
(sodiumSourceSet.modImplementationConfigurationName)(libs.sodium)
+ (jadeSourceSet.modImplementationConfigurationName)(libs.jade)
(citResewnSourceSet.modImplementationConfigurationName)(
innerJarsOf("citresewn", dependencies.create(libs.citresewn.get()))
@@ -280,10 +252,8 @@ dependencies {
(yaclSourceSet.modImplementationConfigurationName)(libs.yacl)
// Actual dependencies
- (reiSourceSet.modImplementationConfigurationName)(libs.rei.api) {
- exclude(module = "architectury")
- exclude(module = "architectury-fabric")
- }
+ (reiSourceSet.modImplementationConfigurationName)(libs.rei.api)
+ (reiSourceSet.modRuntimeOnlyConfigurationName)(libs.rei.fabric)
nonModImplentation(libs.repoparser)
shadowMe(libs.repoparser)
fun ktor(mod: String) = "io.ktor:ktor-$mod-jvm:${libs.versions.ktor.get()}"
@@ -306,11 +276,11 @@ dependencies {
}
- testImplementation("io.kotest:kotest-runner-junit5:6.0.0.M1")
- testAgent(project(":testagent", configuration = "shadow"))
+ testImplementation("net.fabricmc:fabric-loader-junit:${libs.versions.fabric.loader.get()}")
+ testAgent(files(tasks.getByPath(":testagent:jar")))
- implementation(project(":symbols"))
- ksp(project(":symbols"))
+ implementation(projects.symbols)
+ ksp(projects.symbols)
}
loom {
@@ -321,11 +291,13 @@ loom {
configureEach {
property("fabric.log.level", "info")
property("firmament.debug", "true")
- property("firmament.classroots",
- compatSourceSets.joinToString(File.pathSeparator) {
- File(it.output.classesDirs.asPath).absolutePath
- })
+ property(
+ "firmament.classroots",
+ compatSourceSets.joinToString(File.pathSeparator) {
+ File(it.output.classesDirs.asPath).absolutePath
+ })
property("mixin.debug.export", "true")
+ property("mixin.debug", "true")
parseEnvFile(file(".env")).forEach { (t, u) ->
environmentVariable(t, u)
@@ -337,9 +309,9 @@ loom {
named("client") {
property("devauth.enabled", "true")
vmArg("-ea")
- vmArg("-XX:+AllowEnhancedClassRedefinition")
- vmArg("-XX:HotswapAgent=external")
- vmArg("-javaagent:${hotswap.resolve().single().absolutePath}")
+// vmArg("-XX:+AllowEnhancedClassRedefinition")
+// vmArg("-XX:HotswapAgent=external")
+// vmArg("-javaagent:${hotswap.resolve().single().absolutePath}")
}
}
}
@@ -358,12 +330,16 @@ val updateTestRepo by tasks.registering {
doLast {
val propertiesFile = rootProject.file("gradle.properties")
val json =
- Gson().fromJson(uri("https://api.github.com/repos/NotEnoughUpdates/NotEnoughUpdates-REPO/branches/master")
- .toURL().readText(), JsonObject::class.java)
+ Gson().fromJson(
+ uri("https://api.github.com/repos/NotEnoughUpdates/NotEnoughUpdates-REPO/branches/master")
+ .toURL().readText(), JsonObject::class.java
+ )
val latestSha = json["commit"].asJsonObject["sha"].asString
var text = propertiesFile.readText()
- text = text.replace("firmament\\.compiletimerepohash=[^\n]*".toRegex(),
- "firmament.compiletimerepohash=$latestSha")
+ text = text.replace(
+ "firmament\\.compiletimerepohash=[^\n]*".toRegex(),
+ "firmament.compiletimerepohash=$latestSha"
+ )
propertiesFile.writeText(text)
}
}
@@ -377,8 +353,10 @@ tasks.test {
doFirst {
wd.mkdirs()
wd.resolve("config").deleteRecursively()
- systemProperty("firmament.testrepo",
- downloadTestRepo.flatMap { it.outputDirectory.asFile }.map { it.absolutePath }.get())
+ systemProperty(
+ "firmament.testrepo",
+ downloadTestRepo.flatMap { it.outputDirectory.asFile }.map { it.absolutePath }.get()
+ )
jvmArgs("-javaagent:${testAgent.singleFile.absolutePath}")
}
systemProperty("jdk.attach.allowAttachSelf", "true")
@@ -396,13 +374,15 @@ tasks.withType<JavaCompile> {
this.targetCompatibility = "21"
options.encoding = "UTF-8"
val module = "ALL-UNNAMED"
- options.forkOptions.jvmArgs!!.addAll(listOf(
- "--add-exports=jdk.compiler/com.sun.tools.javac.util=$module",
- "--add-exports=jdk.compiler/com.sun.tools.javac.comp=$module",
- "--add-exports=jdk.compiler/com.sun.tools.javac.tree=$module",
- "--add-exports=jdk.compiler/com.sun.tools.javac.api=$module",
- "--add-exports=jdk.compiler/com.sun.tools.javac.code=$module",
- ))
+ options.forkOptions.jvmArgs!!.addAll(
+ listOf(
+ "--add-exports=jdk.compiler/com.sun.tools.javac.util=$module",
+ "--add-exports=jdk.compiler/com.sun.tools.javac.comp=$module",
+ "--add-exports=jdk.compiler/com.sun.tools.javac.tree=$module",
+ "--add-exports=jdk.compiler/com.sun.tools.javac.api=$module",
+ "--add-exports=jdk.compiler/com.sun.tools.javac.code=$module",
+ )
+ )
options.isFork = true
afterEvaluate {
options.compilerArgs.add("-Xplugin:IntermediaryNameReplacement mappingFile=${LoomGradleExtension.get(project).mappingsFile.absolutePath} sourceNs=named")
@@ -413,27 +393,39 @@ tasks.jar {
destinationDirectory.set(layout.buildDirectory.dir("badjars"))
archiveClassifier.set("slim")
}
-
-tasks.shadowJar {
+mergedSourceSetsJar.configure {
+ from(zipTree(tasks.jar.flatMap { it.archiveFile }))
+ destinationDirectory.set(layout.buildDirectory.dir("badjars"))
+ archiveClassifier.set("merged-source-sets")
+ mergeServiceFiles()
+}
+shadowJar.configure {
+ from(zipTree(tasks.remapJar.flatMap { it.archiveFile }))
configurations = listOf(shadowMe)
- archiveClassifier.set("dev")
+ archiveClassifier.set("")
relocate("io.github.moulberry.repo", "moe.nea.firmament.deps.repo")
- destinationDirectory.set(layout.buildDirectory.dir("badjars"))
+ relocate("io.github.notenoughupdates.moulconfig", "moe.nea.firmament.deps.moulconfig")
mergeServiceFiles()
+ transform<FabricModTransform>()
}
tasks.remapJar {
// injectAccessWidener.set(true)
- inputFile.set(tasks.shadowJar.flatMap { it.archiveFile })
- dependsOn(tasks.shadowJar)
- archiveClassifier.set("")
+ inputFile.set(mergedSourceSetsJar.flatMap { it.archiveFile })
+ dependsOn(mergedSourceSetsJar)
+ destinationDirectory.set(layout.buildDirectory.dir("badjars"))
+ archiveClassifier.set("remapped")
}
+tasks.assemble { dependsOn(shadowJar) }
+
+
tasks.processResources {
val replacements = listOf(
"version" to project.version.toString(),
"minecraft_version" to libs.versions.minecraft.get(),
"fabric_kotlin_version" to libs.versions.fabric.kotlin.get(),
+ "fabric_api_version" to libs.versions.fabric.api.get(),
"rei_version" to libs.versions.rei.get()
)
replacements.forEach { (key, value) -> inputs.property(key, value) }
@@ -450,12 +442,18 @@ tasks.processResources {
tasks.scanLicenses {
scanConfiguration(nonModImplentation)
scanConfiguration(configurations.modCompileClasspath.get())
+ compatSourceSets.forEach {
+ scanConfiguration(it.modImplementationConfigurationName.get())
+ }
outputFile.set(layout.buildDirectory.file("LICENSES-FIRMAMENT.json"))
licenseFormatter.set(moe.nea.licenseextractificator.JsonLicenseFormatter())
}
-tasks.create("printAllLicenses", LicenseDiscoveryTask::class.java, licensing).apply {
+tasks.register("printAllLicenses", LicenseDiscoveryTask::class.java, licensing).configure {
outputFile.set(layout.buildDirectory.file("LICENSES-FIRMAMENT.txt"))
licenseFormatter.set(moe.nea.licenseextractificator.TextLicenseFormatter())
+ compatSourceSets.forEach {
+ scanConfiguration(it.modImplementationConfigurationName.get())
+ }
scanConfiguration(nonModImplentation)
scanConfiguration(configurations.modCompileClasspath.get())
doLast {
@@ -463,10 +461,61 @@ tasks.create("printAllLicenses", LicenseDiscoveryTask::class.java, licensing).ap
}
outputs.upToDateWhen { false }
}
+fun patchRenderDoc(
+ javaLauncher: JavaLauncher,
+): JavaLauncher {
+ val wrappedJavaExecutable = javaLauncher.executablePath.asFile.absolutePath
+ require("\"" !in wrappedJavaExecutable)
+ val hashBytes = Hashing.sha256().hashString(wrappedJavaExecutable, StandardCharsets.UTF_8)
+ val hash = Base64.getUrlEncoder().encodeToString(hashBytes.asBytes())
+ .replace("=", "")
+ val wrapperJavaRoot = rootProject.layout.buildDirectory
+ .dir("binaries/renderdoc-wrapped-java/$hash/")
+ .get()
+ val isWindows = Os.isFamily(Os.FAMILY_WINDOWS)
+ val wrapperJavaExe =
+ if (isWindows) wrapperJavaRoot.file("java.cmd")
+ else wrapperJavaRoot.file("java")
+ return object : JavaLauncher {
+ override fun getMetadata(): JavaInstallationMetadata {
+ return object : JavaInstallationMetadata by javaLauncher.metadata {
+ override fun isCurrentJvm(): Boolean {
+ return false
+ }
+ }
+ }
+
+ override fun getExecutablePath(): RegularFile {
+ val fileF = wrapperJavaExe.asFile
+ if (!fileF.exists()) {
+ fileF.parentFile.mkdirs()
+ if (isWindows) {
+ fileF.writeText(
+ """
+ setlocal enableextensions
+ start "" renderdoccmd.exe capture --opt-hook-children --wait-for-exit --working-dir . "$wrappedJavaExecutable" %*
+ endlocal
+ """.trimIndent()
+ )
+ } else {
+ fileF.writeText(
+ """
+ #!/usr/bin/env bash
+ exec renderdoccmd capture --opt-hook-children --wait-for-exit --working-dir . "$wrappedJavaExecutable" "$@"
+ """.trimIndent()
+ )
+ fileF.setExecutable(true)
+ }
+ }
+ return wrapperJavaExe
+ }
+ }
+}
+tasks.runClient {
+ javaLauncher.set(javaToolchains.launcherFor(java.toolchain).map { patchRenderDoc(it) })
+}
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
-
-licensing.addExtraLicenseMatchers()