Skip to content

Commit

Permalink
Build: Remove multiversion, switch over to fabric loom
Browse files Browse the repository at this point in the history
  • Loading branch information
camnwalter committed Jan 8, 2024
1 parent 79e7b14 commit 3303273
Show file tree
Hide file tree
Showing 33 changed files with 290 additions and 506 deletions.
49 changes: 28 additions & 21 deletions api/ctjs.api

Large diffs are not rendered by default.

241 changes: 113 additions & 128 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,52 @@ import java.io.ByteArrayOutputStream

buildscript {
dependencies {
classpath("org.jetbrains.dokka:versioning-plugin:1.8.20")
classpath(libs.versioning)
}
}

plugins {
kotlin("jvm") version "1.8.21"
kotlin("plugin.serialization") version "1.8.21"
id("gg.essential.multi-version")

// Apply defaults individually since "gg.essential.defaults" includes
// mixin-extras which requires Essential
id("gg.essential.defaults.java")
id("gg.essential.defaults.loom")
id("gg.essential.defaults.repo")

id("io.github.juuxel.loom-quiltflower") version "1.10.0"
id("org.jetbrains.dokka") version "1.8.20"
alias(libs.plugins.kotlin)
alias(libs.plugins.serialization)
alias(libs.plugins.loom)
alias(libs.plugins.dokka)
alias(libs.plugins.validator)
}

val modVersion = property("mod_version")!!.toString()
val mcVersion = platform.toString()

version = "${modVersion}_$mcVersion"
group = property("mod_group")!!
val yarnMappings = property("yarn_mappings")!!
version = property("mod_version").toString()

repositories {
maven("https://jitpack.io")
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
maven("https://maven.terraformersmc.com/releases")
maven("https://repo.essential.gg/repository/maven-public")
}

dependencies {
include(modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")!!)
include(modImplementation("net.fabricmc.fabric-api:fabric-api:${property("fabric_version")}")!!)

include(modImplementation("net.fabricmc:fabric-language-kotlin:1.9.4+kotlin.1.8.21")!!)
include(modImplementation("net.fabricmc:mapping-io:0.5.1")!!)
include(modImplementation("com.github.ChatTriggers:rhino:739c70599b")!!)
include(modImplementation("com.fasterxml.jackson.core:jackson-core:2.13.2")!!)
include(modImplementation("com.fifesoft:rsyntaxtextarea:3.2.0")!!)
include(modImplementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")!!)
include(modImplementation("com.github.char:Koffee:3a78d8a437")!!)

include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:0.2.0")!!)!!)

// 1.18 versions are good enough for Elementa and Vigilance, but not UC, so we
// need to exclude this version
configurations.modImplementation { exclude("gg.essential", "universalcraft-1.18.1-fabric") }

include(modImplementation("gg.essential:vigilance-1.18.1-fabric:295")!!)
val ucArtifact = if (mcVersion == "1.19.4-fabric") mcVersion else "1.20.3-fabric"
include(modImplementation("gg.essential:universalcraft-$ucArtifact:320")!!)
include(modImplementation("gg.essential:elementa-1.18.1-fabric:610")!!)

val modMenuVersion = when (mcVersion) {
"1.20.4-fabric" -> "9.0.0"
"1.19.4-fabric" -> "6.3.1"
else -> throw Exception("Minecraft version $mcVersion is not supported")
// To change the versions see the gradle/libs.versions.toml
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn) { classifier("v2") })
modImplementation(libs.bundles.fabric)

modImplementation(libs.bundles.included) { include(this) }
modImplementation(libs.bundles.essential) {
exclude("gg.essential", "universalcraft-1.18.1-fabric")
include(this)
}
modApi("com.terraformersmc:modmenu:$modMenuVersion")


modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:1.1.2")
modApi(libs.modmenu)
modRuntimeOnly(libs.devauth)
dokkaPlugin(libs.versioning)

dokkaPlugin("org.jetbrains.dokka:versioning-plugin:1.8.20")
configurations.all {
resolutionStrategy {
force(libs.fabric.loader)
}
}
}

loom {
accessWidenerPath.set(rootProject.file("src/main/resources/chattriggers.accesswidener"))
accessWidenerPath.set(file("src/main/resources/chattriggers.accesswidener"))
}

base {
Expand All @@ -90,13 +66,31 @@ java {
targetCompatibility = JavaVersion.VERSION_17
}

apiValidation {
ignoredPackages.add("com.chattriggers.ctjs.internal")
}

tasks {
processResources {
inputs.property("yarn_mappings", yarnMappings)
val flkVersion = libs.versions.fabric.kotlin.get()
val yarnVersion = libs.versions.yarn.get()
val fapiVersion = libs.versions.fabric.api.get()
val loaderVersion = libs.versions.loader.get()

inputs.property("version", project.version)
inputs.property("yarn_mappings", yarnVersion)
inputs.property("fabric_kotlin_version", flkVersion)
inputs.property("fabric_api_version", fapiVersion)
inputs.property("loader_version", loaderVersion)

filesMatching("fabric.mod.json") {
expand("version" to project.version, "yarn_mappings" to yarnMappings)
expand(
"version" to project.version,
"yarn_mappings" to yarnVersion,
"fabric_kotlin_version" to flkVersion,
"fabric_api_version" to fapiVersion,
"loader_version" to loaderVersion
)
}
}

Expand All @@ -117,99 +111,90 @@ tasks {
}
}

build {
doLast {
allprojects {
copy {
from("build/libs")
into(rootProject.file("build"))
}
}
}
}
}
dokkaHtml {
// Just use the module name here since the MC version doesn't affect CT's API
// across the same mod version
moduleVersion.set(project.version.toString())
moduleName.set("ctjs")

tasks.dokkaHtml {
// Just use the module name here since the MC version doesn't affect CT's API
// across the same mod version
moduleVersion.set(modVersion)
moduleName.set("ctjs")
val docVersionsDir = projectDir.resolve("build/javadocs")
val currentVersion = project.version.toString()
val currentDocsDir = docVersionsDir.resolve(currentVersion)
outputs.upToDateWhen { docVersionsDir.exists() }

val docVersionsDir = projectDir.resolve("build/javadocs")
val currentVersion = project.version.toString()
val currentDocsDir = docVersionsDir.resolve(currentVersion)
outputs.upToDateWhen { docVersionsDir.exists() }
outputDirectory.set(file(currentDocsDir))

outputDirectory.set(file(currentDocsDir))
pluginConfiguration<VersioningPlugin, VersioningConfiguration> {
version = project.version.toString()
olderVersionsDir = docVersionsDir
renderVersionsNavigationOnAllPages = true
}

pluginConfiguration<VersioningPlugin, VersioningConfiguration> {
version = modVersion
olderVersionsDir = docVersionsDir
renderVersionsNavigationOnAllPages = true
}
suppressObviousFunctions.set(true)
suppressInheritedMembers.set(true)

suppressObviousFunctions.set(true)
suppressInheritedMembers.set(true)
val branch = getBranch()
dokkaSourceSets {
configureEach {
jdkVersion.set(17)

val branch = getBranch()
dokkaSourceSets {
configureEach {
jdkVersion.set(17)
perPackageOption {
matchingRegex.set("com\\.chattriggers\\.ctjs\\.internal(\$|\\.).*")
suppress.set(true)
}

perPackageOption {
matchingRegex.set("com\\.chattriggers\\.ctjs\\.internal(\$|\\.).*")
suppress.set(true)
}
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(URL("https://github.com/ChatTriggers/ctjs/blob/$branch/src/main/kotlin"))
remoteLineSuffix.set("#L")
}

sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(URL("https://github.com/ChatTriggers/ctjs/blob/$branch/src/main/kotlin"))
remoteLineSuffix.set("#L")
}
externalDocumentationLink {
val yarnVersion = libs.versions.yarn.get()

externalDocumentationLink {
url.set(URL("https://maven.fabricmc.net/docs/yarn-$yarnMappings/"))
packageListUrl.set(URL("https://maven.fabricmc.net/docs/yarn-$yarnMappings/element-list"))
url.set(URL("https://maven.fabricmc.net/docs/yarn-$yarnVersion/"))
packageListUrl.set(URL("https://maven.fabricmc.net/docs/yarn-$yarnVersion/element-list"))
}
}
}
}

doFirst {
val archiveBase = "https://www.chattriggers.com/javadocs-archive/"
val versions = String(downloadFile(archiveBase + "versions")).lines().map(String::trim)
val tmpFile = File(temporaryDir, "oldVersionsZip.zip")

versions.filter(String::isNotEmpty).map(String::trim).forEach { version ->
val zipBytes = downloadFile("$archiveBase$version.zip")
tmpFile.writeBytes(zipBytes)
unzipTo(docVersionsDir, tmpFile)
}
doFirst {
val archiveBase = "https://www.chattriggers.com/javadocs-archive/"
val versions = String(downloadFile(archiveBase + "versions")).lines().map(String::trim)
val tmpFile = File(temporaryDir, "oldVersionsZip.zip")

tmpFile.delete()
}
versions.filter(String::isNotEmpty).map(String::trim).forEach { version ->
val zipBytes = downloadFile("$archiveBase$version.zip")
tmpFile.writeBytes(zipBytes)
unzipTo(docVersionsDir, tmpFile)
}

doLast {
// At this point we have a structure that looks something like this:
// javadocs
// \-- 2.2.0-1.8.9
// \-- 3.0.0
// \-- older
//
// The "older" directory contains all old versions, so we want to
// delete the top-level older versions and move everything inside the
// latest directory to the top level so the GitHub actions workflow
// doesn't need to figure out the correct version name

docVersionsDir.listFiles()?.forEach {
if (it.name != version)
it.deleteRecursively()
tmpFile.delete()
}

val latestVersionDir = docVersionsDir.listFiles()!!.single()
latestVersionDir.listFiles()!!.forEach {
it.renameTo(File(it.parentFile.parentFile, it.name))
doLast {
// At this point we have a structure that looks something like this:
// javadocs
// \-- 2.2.0-1.8.9
// \-- 3.0.0
// \-- older
//
// The "older" directory contains all old versions, so we want to
// delete the top-level older versions and move everything inside the
// latest directory to the top level so the GitHub actions workflow
// doesn't need to figure out the correct version name

docVersionsDir.listFiles()?.forEach {
if (it.name != version)
it.deleteRecursively()
}

val latestVersionDir = docVersionsDir.listFiles()!!.single()
latestVersionDir.listFiles()!!.forEach {
it.renameTo(File(it.parentFile.parentFile, it.name))
}
latestVersionDir.deleteRecursively()
}
latestVersionDir.deleteRecursively()
}
}

Expand Down
8 changes: 2 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true

# Mod Properties
mod_version = 3.0.0-beta
mod_group = com.chattriggers
archives_base_name = ctjs
supportedMcVersions=1.19.4-fabric,1.20.4-fabric

loader_version=0.15.3

essential.defaults.loom=1
63 changes: 63 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[versions]
# Library versions
minecraft = "1.20.4"
yarn = "1.20.4+build.3"

loader = "0.15.3"
fabric-api = "0.91.2+1.20.4"
fabric-kotlin = "1.10.16+kotlin.1.9.21"

mapping-io = "0.5.1"
rhino = "96d0c07966"
jackson-core = "2.13.2"
textarea = "3.2.0"
serialization = "1.5.1"
koffee = "3a78d8a437"

universalcraft = "323"
elementa = "619"
vigilance = "295"

modmenu = "9.0.0"
devauth = "1.2.0"
dokka = "1.9.10"

# Plugin Versions
kotlin = "1.9.21"
loom = "1.4-SNAPSHOT"
validator = "0.13.2"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
yarn = { module = "net.fabricmc:yarn", version.ref = "yarn" }

fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "loader" }
fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" }
fabric-kotlin = { module = "net.fabricmc:fabric-language-kotlin", version.ref = "fabric-kotlin" }

mapping-io = { module = "net.fabricmc:mapping-io", version.ref = "mapping-io" }
rhino = { module = "com.github.ChatTriggers:rhino", version.ref = "rhino" }
jackson-core = { module = "com.fasterxml.jackson.core:jackson-core", version.ref = "jackson-core" }
textarea = { module = "com.fifesoft:rsyntaxtextarea", version.ref = "textarea" }
serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
koffee = { module = "com.github.char:Koffee", version.ref = "koffee" }

universalcraft = { module = "gg.essential:universalcraft-1.20.4-fabric", version.ref = "universalcraft" }
elementa = { module = "gg.essential:elementa-1.18.1-fabric", version.ref = "elementa" }
vigilance = { module = "gg.essential:vigilance-1.18.1-fabric", version.ref = "vigilance" }

modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
devauth = { module = "me.djtheredstoner:DevAuth-fabric", version.ref = "devauth" }
versioning = { module = "org.jetbrains.dokka:versioning-plugin", version.ref = "dokka" }

[bundles]
fabric = ["fabric-loader", "fabric-api", "fabric-kotlin"]
included = ["mapping-io", "rhino", "jackson-core", "textarea", "serialization", "koffee"]
essential = ["universalcraft", "elementa", "vigilance"]

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
loom = { id = "fabric-loom", version.ref = "loom" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "validator" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 3303273

Please sign in to comment.