Skip to content

Commit

Permalink
Update gradle and maven
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Sep 12, 2024
1 parent 8867e45 commit 006420f
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 113 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,11 @@ following to your `build.gradle.kts`

```kts
repositories {
maven {
url = uri("https://jitpack.io")
}
maven("https://maven.supersanta.me/snapshots")
}

dependencies {
// For the most recent version, use the latest commit hash
modImplementation("com.github.senseiwells:ServerReplay:da3b0e55ce")
modImplementation("me.senseiwells:server-replay:1.1.2+1.21.1")
}
```

Expand Down
151 changes: 71 additions & 80 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import org.apache.commons.io.output.ByteArrayOutputStream
import java.nio.charset.Charset

plugins {
kotlin("jvm")
kotlin("plugin.serialization") version "2.0.0"
id("me.modmuss50.mod-publish-plugin") version "0.4.5"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("fabric-loom")
val jvmVersion = libs.versions.fabric.kotlin.get()
.split("+kotlin.")[1]
.split("+")[0]

kotlin("jvm").version(jvmVersion)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.fabric.loom)
alias(libs.plugins.mod.publish)
alias(libs.plugins.shadow)
`maven-publish`
java
}
Expand All @@ -24,66 +25,43 @@ repositories {
mavenCentral()
}

val modVersion: String by project
val mcVersion: String by project
val parchmentVersion: String by project
val loaderVersion: String by project
val fabricVersion: String by project
val fabricKotlinVersion: String by project

val carpetVersion: String by project
val voicechatVersion: String by project
val voicechatApiVersion: String by project
val vmpVersion: String by project
val permissionsVersion: String by project
val syncmaticaVersion: String by project

val releaseVersion = "${modVersion}+mc${mcVersion}"

val modVersion = "1.1.2"
val releaseVersion = "${modVersion}+mc${libs.versions.minecraft.get()}"
val mavenVersion = "${modVersion}+${libs.versions.minecraft.get()}"
version = releaseVersion
group = "me.senseiwells"

dependencies {
minecraft("com.mojang:minecraft:${mcVersion}")
minecraft(libs.minecraft)
@Suppress("UnstableApiUsage")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${parchmentVersion}@zip")
parchment("org.parchmentmc.data:parchment-${libs.versions.parchment.get()}@zip")
})

modImplementation("net.fabricmc:fabric-loader:${loaderVersion}")
modImplementation("net.fabricmc:fabric-language-kotlin:${fabricKotlinVersion}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricVersion}")

modImplementation("com.github.gnembon:fabric-carpet:${carpetVersion}")
modCompileOnly("maven.modrinth:simple-voice-chat:fabric-${voicechatVersion}")
implementation("de.maxhenkel.voicechat:voicechat-api:${voicechatApiVersion}")

modCompileOnly("maven.modrinth:vmp-fabric:${vmpVersion}")
modCompileOnly("com.github.sakura-ryoko:syncmatica:${syncmaticaVersion}")

// I've had some issues with ReplayStudio and slf4j (in dev env)
// Simplest workaround that I've found is just to unzip the
// jar and yeet the org.slf4j packages then rezip the jar.
shade(modImplementation("com.github.ReplayMod:ReplayStudio:1e96fda605") {
exclude(group = "org.slf4j")
exclude(group = "it.unimi.dsi")
exclude(group = "org.apache.commons")
exclude(group = "commons-cli")
exclude(group = "com.google.guava", module = "guava-jdk5")
exclude(group = "com.google.guava", module = "guava")
exclude(group = "com.google.code.gson", module = "gson")
})
include(modImplementation("me.lucko:fabric-permissions-api:${permissionsVersion}") {
exclude("net.fabricmc.fabric-api")
})
modImplementation(libs.fabric.loader)
modImplementation(libs.fabric.api)
modImplementation(libs.fabric.kotlin)

modCompileOnly(libs.carpet)
modCompileOnly(libs.vmp)
modCompileOnly(libs.syncmatica)
modCompileOnly(libs.voicechat)
implementation(libs.voicechat.api)

shade(modImplementation(libs.replay.studio.get())!!)
includeModImplementation(libs.permissions) {
exclude(libs.fabric.api.get().group)
}
}

loom {
accessWidenerPath.set(file("src/main/resources/serverreplay.accesswidener"))

runs {
getByName("server") {
runDir = "run/$mcVersion"
runDir = "run/${libs.versions.minecraft.get()}"
}

getByName("client") {
Expand All @@ -92,11 +70,11 @@ loom {
}
}

tasks {
register("relocateResources") {

}
java {
withSourcesJar()
}

tasks {
processResources {
inputs.property("version", modVersion)
filesMatching("fabric.mod.json") {
Expand Down Expand Up @@ -138,13 +116,13 @@ tasks {
type = STABLE
modLoaders.add("fabric")

displayName = "ServerReplay $modVersion for $mcVersion"
displayName = "ServerReplay $modVersion for ${libs.versions.minecraft.get()}"
version = releaseVersion

modrinth {
accessToken = providers.environmentVariable("MODRINTH_API_KEY")
projectId = "qCvSZ8ra"
minecraftVersions.add(mcVersion)
minecraftVersions.add(libs.versions.minecraft)

requires {
id = "P7dR8mSH"
Expand All @@ -158,39 +136,52 @@ tasks {
}
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
groupId = "com.github.senseiwells"
artifactId = "ServerReplay"
version = getGitHash()
from(project.components.getByName("java"))
}
}
}

register("updateReadme") {
val readmes = listOf("./README.md")
val regex = Regex("""com.github.Senseiwells:ServerReplay:[a-z0-9]+""")
val replacement = "com.github.Senseiwells:ServerReplay:${getGitHash()}"
val regex = Regex("""me\.senseiwells:server-replay:[\d\.\-a-zA-Z+]+""")
val replacement = "me.senseiwells:server-replay:${mavenVersion}"
for (path in readmes) {
val readme = file(path)
readme.writeText(readme.readText().replace(regex, replacement))
}

println("Successfully updated all READMEs")
}
}

java {
withSourcesJar()
named("publish").configure {
finalizedBy("updateReadme")
}
}

fun getGitHash(): String {
val out = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short=10", "HEAD")
standardOutput = out
publishing {
publications {
create<MavenPublication>("ServerReplay") {
groupId = "me.senseiwells"
artifactId = "server-replay"
version = mavenVersion
from(components["java"])
}
}
return out.toString(Charset.defaultCharset()).trim()

repositories {
val mavenUrl = System.getenv("MAVEN_URL")
if (mavenUrl != null) {
maven {
url = uri(mavenUrl)
val mavenUsername = System.getenv("MAVEN_USERNAME")
val mavenPassword = System.getenv("MAVEN_PASSWORD")
if (mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}
}
}

private fun DependencyHandler.includeModImplementation(provider: Provider<*>, action: Action<ExternalModuleDependency>) {
this.include(provider, action)
this.modImplementation(provider, action)
}
17 changes: 0 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,4 @@ systemProp.org.gradle.internal.http.connectionTimeout=180000
systemProp.org.gradle.internal.http.socketTimeout=180000

kotlin.code.style=official

loomVersion=1.7-SNAPSHOT

mcVersion=1.21
parchmentVersion=1.20.6:2024.06.16
loaderVersion=0.15.11
fabricKotlinVersion=1.11.0+kotlin.2.0.0
permissionsVersion=0.3.1
fabricVersion=0.100.1+1.21
carpetVersion=1.4.147
voicechatVersion=1.21.1-2.5.20
voicechatApiVersion=2.5.0
vmpVersion=0.2.0+beta.7.162+1.21
syncmaticaVersion=1.21-sakura.6

modVersion=1.1.2

org.gradle.jvmargs=-Xmx4000m
36 changes: 36 additions & 0 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[versions]
fabric-loom = "1.7-SNAPSHOT"
mod-publish = "0.7.0"
kotlin-serialization = "1.9.21"
shadow = "8.1.1"
minecraft = "1.21.1"
fabric-loader = "0.16.5"
parchment = "1.21:2024.07.28"
fabric-api = "0.103.0+1.21.1"
fabric-kotlin = "1.11.0+kotlin.2.0.0"
permissions = "0.3.1"
carpet = "1.4.147"
voicechat = "fabric-1.21.1-2.5.20"
voicechat-api = "2.5.0"
vmp = "0.2.0+beta.7.162+1.21"
syncmatica = "1.21-sakura.6"
replay-studio = "1e96fda605"

[libraries]
minecraft = { module = "com.mojang:minecraft" , version.ref = "minecraft" }
fabric-loader = { module = "net.fabricmc:fabric-loader" , version.ref = "fabric-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" }
permissions = { module = "me.lucko:fabric-permissions-api" , version.ref = "permissions" }
carpet = { module = "com.github.gnembon:fabric-carpet" , version.ref = "carpet" }
voicechat = { module = "maven.modrinth:simple-voice-chat" , version.ref = "voicechat" }
voicechat-api = { module = "de.maxhenkel.voicechat:voicechat-api" , version.ref = "voicechat-api" }
vmp = { module = "maven.modrinth:vmp-fabric" , version.ref = "vmp" }
syncmatica = { module = "com.github.sakura-ryoko:syncmatica" , version.ref = "syncmatica" }
replay-studio = { module = "com.github.ReplayMod:ReplayStudio" , version.ref = "replay-studio" }

[plugins]
fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-serialization" }
mod-publish = { id = "me.modmuss50.mod-publish-plugin", version.ref = "mod-publish" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
19 changes: 9 additions & 10 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
rootProject.name = "ServerReplay"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("libs.versions.toml"))
}
}
}

pluginManagement {
repositories {
maven("https://maven.fabricmc.net/") {
Expand All @@ -7,14 +16,4 @@ pluginManagement {
mavenCentral()
gradlePluginPortal()
}

val loomVersion: String by settings
val fabricKotlinVersion: String by settings
plugins {
id("fabric-loom") version loomVersion
id("org.jetbrains.kotlin.jvm") version
fabricKotlinVersion
.split("+kotlin.")[1] // Grabs the sentence after `+kotlin.`
.split("+")[0] // Ensures sentences like `+build.1` are ignored
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import net.minecraft.network.protocol.Packet as MinecraftPacket
*/
abstract class ReplayRecorder(
val server: MinecraftServer,
public val profile: GameProfile,
val profile: GameProfile,
private val recordings: Path
) {
private val packets by lazy { Object2ObjectOpenHashMap<String, DebugPacketData>() }
Expand Down

0 comments on commit 006420f

Please sign in to comment.