1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Update to Gradle 9 (#5976)

* Update gradle to 9.2.0

* Eclipse doesn't like defining a generic in an instanceof check...

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>

* Fix launching on standalone due to Gradle 9 changes

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>

* Update indra to v4; fix as many gradle deprecation warnings as possible

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>

* Do task order suggestion; remove properties comment line

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>

* Fix fabric runServer rask

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>

* Fix :neoforge:runServer gradle task

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>

* Fix libs.versions.toml

* Fix dupe runtask def

* Update architectury-loom and resolve properties issues

---------

Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
Co-authored-by: onebeastchris <github@onechris.mozmail.com>
This commit is contained in:
Kas-tle
2025-12-12 19:04:34 -08:00
committed by GitHub
parent def5c97e77
commit e2f873466b
19 changed files with 279 additions and 202 deletions

2
.gitignore vendored
View File

@@ -14,6 +14,7 @@ local.properties
.settings/
.loadpath
.recommenders
.classpath
# External tool builders
.externalToolBuilders/
@@ -98,6 +99,7 @@ local.properties
# Package Files #
*.jar
!gradle/wrapper/gradle-wrapper.jar
*.war
*.nar
*.ear

View File

@@ -8,6 +8,16 @@ architectury {
fabric()
}
loom {
mods {
create("geyser-fabric") {
sourceSet(sourceSets.main.get())
sourceSet("main", projects.mod)
sourceSet("main", projects.core)
}
}
}
dependencies {
modImplementation(libs.fabric.loader)
modApi(libs.fabric.api)

View File

@@ -8,6 +8,16 @@ architectury {
neoForge()
}
loom {
mods {
create("geyser-neoforge") {
sourceSet(sourceSets.main.get())
sourceSet("main", projects.mod)
sourceSet("main", projects.core)
}
}
}
// This is provided by "org.cloudburstmc.math.mutable" too, so yeet.
// NeoForge's class loader is *really* annoying.
provided("org.cloudburstmc.math", "api")

View File

@@ -3,7 +3,7 @@ loaderVersion="[1,)"
license="MIT"
[[mods]]
modId="geyser_neoforge"
version="${version}"
version="${file.jarVersion}"
displayName="Geyser"
displayURL="https://geysermc.org/"
logoFile= "../assets/geyser/icon.png"

View File

@@ -87,5 +87,6 @@ modrinth {
tasks {
runServer {
minecraftVersion(libs.versions.runpaperversion.get())
jvmArgs("-Dcom.mojang.eula.agree=true")
}
}

View File

@@ -34,6 +34,10 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
archiveBaseName.set("Geyser-Standalone")
transform(Log4j2PluginsCacheFileTransformer())
// https://gradleup.com/shadow/configuration/merging/#handling-duplicates-strategy
filesMatching("META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}
tasks.named<JavaExec>("run") {

View File

@@ -25,4 +25,5 @@ dependencies {
implementation(libs.architectury.plugin)
implementation(libs.architectury.loom)
implementation(libs.minotaur)
implementation(libs.loom.companion)
}

View File

@@ -22,7 +22,7 @@ indra {
}
dependencies {
compileOnly("org.checkerframework", "checker-qual", libs.checker.qual.get().version)
compileOnly("org.checkerframework:checker-qual:" + libs.checker.qual.get().version)
}
repositories {

View File

@@ -11,7 +11,11 @@ tasks {
"id" to "geyser",
"name" to "Geyser",
"version" to project.version,
"description" to project.description,
// Must be this for gradle :neoforge:runServer task to work
"file" to mapOf(
"jarVersion" to project.version
),
"description" to project.description as String,
"url" to "https://geysermc.org",
"author" to "GeyserMC"
)

View File

@@ -7,9 +7,3 @@ indra {
publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/maven-snapshots")
publishReleasesTo("geysermc", "https://repo.opencollab.dev/maven-releases")
}
publishing {
// skip shadow jar from publishing. Workaround for https://github.com/johnrengelman/shadow/issues/651
val javaComponent = project.components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() }
}

View File

@@ -2,34 +2,36 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("geyser.base-conventions")
id("com.github.johnrengelman.shadow")
id("com.gradleup.shadow")
}
shadow {
addShadowVariantIntoJavaComponent = false
}
tasks {
named<Jar>("jar") {
from(project.rootProject.file("LICENSE"))
}
val shadowJar = named<ShadowJar>("shadowJar") {
archiveBaseName.set(project.name)
archiveVersion.set("")
archiveClassifier.set("")
val sJar: ShadowJar = this
val currentProjectName = project.name // Capture project name at config time
doFirst {
providedDependencies[project.name]?.forEach { string ->
sJar.dependencies {
println("Excluding $string from ${project.name}")
dependencies {
providedDependencies[currentProjectName]?.forEach { string ->
println("Excluding $string from $currentProjectName")
exclude(dependency(string))
}
}
sJar.dependencies {
exclude(dependency("org.checkerframework:checker-qual:.*"))
exclude(dependency("org.jetbrains:annotations:.*"))
}
}
}
named("build") {
dependsOn(shadowJar)
}

View File

@@ -1,9 +1,18 @@
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.revwalk.RevWalk
import net.kyori.indra.git.RepositoryValueSource
import java.util.Properties
plugins {
// Allow blossom to mark sources root of templates
idea
eclipse
alias(libs.plugins.blossom)
id("geyser.publish-conventions")
id("io.freefair.lombok")
// Allows fabric/neoforge runServer gradle tasks to work correctly
id("dev.architectury.loom-companion")
}
dependencies {
@@ -69,9 +78,11 @@ dependencies {
}
// Test
testImplementation(platform("org.junit:junit-bom:6.0.0"))
testImplementation(libs.junit)
testImplementation(libs.gson.runtime) // Record support
testImplementation(libs.mockito)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// Annotation Processors
compileOnly(projects.ap)
@@ -83,35 +94,114 @@ dependencies {
api(libs.bstats)
}
tasks.processResources {
// This is solely for backwards compatibility for other programs that used this file before the switch to gradle.
// It used to be generated by the maven Git-Commit-Id-Plugin
filesMatching("git.properties") {
val info = GitInfo()
expand(
"branch" to info.branch,
"buildNumber" to info.buildNumber,
"projectVersion" to info.version,
"commit" to info.commit,
"commitAbbrev" to info.commitAbbrev,
"commitMessage" to info.commitMessage,
"repository" to info.repository
)
abstract class CommitMessageValueSource : RepositoryValueSource.Parameterless<String>() {
override fun obtain(repository: Git): String? {
val headCommitId = repository.repository.resolve("HEAD")
if (headCommitId == null) {
return ""
}
RevWalk(repository.repository).use { walk ->
val commit = walk.parseCommit(headCommitId)
return commit.fullMessage
}
}
}
abstract class RepositoryUrlValueSource : RepositoryValueSource.Parameterless<String>() {
override fun obtain(repository: Git): String? {
return repository.repository.config.getString("remote", "origin", "url")
}
}
val gitBranch = indraGit.branchName().orElse("DEV")
val gitCommit = indraGit.commit()
val gitCommitName = gitCommit.map { it?.name ?: "0".repeat(40) }
val gitCommitAbbrev = gitCommit.map { it?.name?.substring(0, 7) ?: "0".repeat(7) }
val gitCommitMessage = indraGit.repositoryValue(CommitMessageValueSource::class.java).orElse("")
val gitRepositoryUrl = indraGit.repositoryValue(RepositoryUrlValueSource::class.java).orElse("").map {
it.replace("git@github.com:", "https://github.com/")
}
val gitRepositoryIsDev = gitBranch.zip(gitRepositoryUrl) { branch, repo ->
isDevBuild(branch, repo)
}
val gitVersion = gitBranch.zip(gitCommitAbbrev) { branch, commit ->
"git-${branch}-${commit}"
}
val projectVersionProvider = gitRepositoryIsDev.map { isDev ->
if (isDev) project.version.toString() else projectVersion(project).toString()
}
val finalVersion = projectVersionProvider.zip(gitVersion) { projVer, gitVer ->
"$projVer ($gitVer)"
}
val buildNumber = provider { buildNumber().toString() }
val gitPropertiesMap = mapOf(
"git.branch" to gitBranch,
"git.build.number" to buildNumber,
"git.build.version" to finalVersion,
"git.commit.id" to gitCommitName,
"git.commit.id.abbrev" to gitCommitAbbrev,
"git.commit.message.full" to gitCommitMessage,
"git.remote.origin.url" to gitRepositoryUrl
)
val generateGitProperties = tasks.register("generateGitProperties") {
description = "Generates git.properties from Git information."
group = "build"
inputs.properties(gitPropertiesMap)
val generatedPropsFile = layout.buildDirectory.file("generated/git/git.properties")
outputs.file(generatedPropsFile)
doLast {
val props = Properties()
gitPropertiesMap.forEach { (key, provider) ->
props[key] = provider.get()
}
generatedPropsFile.get().asFile.apply {
parentFile.mkdirs()
writer().use { props.store(it, null) }
// remove comment line
val lines = readLines()
if (lines.isNotEmpty()) {
writeText(lines.drop(1).joinToString("\n", postfix = "\n"))
}
}
}
}
tasks.processResources {
from(generateGitProperties) {
into(".")
}
}
tasks.named("sourcesJar") {
dependsOn(tasks.named("processResources"))
}
sourceSets {
main {
blossom {
val info = GitInfo()
javaSources {
property("version", info.version)
property("gitVersion", info.gitVersion)
property("buildNumber", info.buildNumber.toString())
property("branch", info.branch)
property("commit", info.commit)
property("repository", info.repository)
property("devVersion", info.isDev.toString())
property("version", finalVersion)
property("gitVersion", gitVersion)
property("buildNumber", buildNumber)
property("branch", gitBranch)
property("commit", gitCommitName)
property("repository", gitRepositoryUrl)
property("devVersion", gitRepositoryIsDev.map { it.toString() })
}
}
}
@@ -121,40 +211,6 @@ fun isDevBuild(branch: String, repository: String): Boolean {
return branch != "master" || repository.equals("https://github.com/GeyserMC/Geyser", ignoreCase = true).not()
}
inner class GitInfo {
val branch: String
val commit: String
val commitAbbrev: String
val gitVersion: String
val version: String
val buildNumber: Int
val commitMessage: String
val repository: String
val isDev: Boolean
init {
branch = indraGit.branchName() ?: "DEV"
val commit = indraGit.commit()
this.commit = commit?.name ?: "0".repeat(40)
commitAbbrev = commit?.name?.substring(0, 7) ?: "0".repeat(7)
gitVersion = "git-${branch}-${commitAbbrev}"
val git = indraGit.git()
commitMessage = git?.commit()?.message ?: ""
repository = git?.repository?.config?.getString("remote", "origin", "url") ?: ""
buildNumber = buildNumber()
isDev = isDevBuild(branch, repository)
val projectVersion = if (isDev) project.version else projectVersion(project)
version = "$projectVersion ($gitVersion)"
}
}
// Manual task to download the bedrock data files from the CloudburstMC/Data repository
// Invoke with ./gradlew :core:downloadBedrockData --suffix=1_20_70
// Set suffix to the current Bedrock version

View File

@@ -797,9 +797,10 @@ public class Entity implements GeyserEntity {
@Override
public <T> void update(@NonNull GeyserEntityProperty<T> property, @Nullable T value) {
Objects.requireNonNull(property, "property must not be null!");
if (!(property instanceof PropertyType<T, ? extends EntityProperty> propertyType)) {
if (!(property instanceof PropertyType)) {
throw new IllegalArgumentException("Invalid property implementation! Got: " + property.getClass().getSimpleName());
}
PropertyType<T, ? extends EntityProperty> propertyType = (PropertyType<T, ?>) property;
int index = propertyDefinitions.getPropertyIndex(property.identifier().toString());
if (index < 0) {
throw new IllegalArgumentException("No property with the name " + property.identifier() + " has been registered.");

View File

@@ -1,7 +0,0 @@
git.branch=${branch}
git.build.number=${buildNumber}
git.build.version=${projectVersion}
git.commit.id=${commit}
git.commit.id.abbrev=${commitAbbrev}
git.commit.message.full=${commitMessage}
git.remote.origin.url=${repository}

View File

@@ -21,7 +21,7 @@ minecraftauth = "5.0.0"
mcprotocollib = "1.21.11-20251210.192611-9"
adventure = "4.25.0"
adventure-platform = "4.4.1"
junit = "5.9.2"
junit = "6.0.0"
checkerframework = "3.19.0"
log4j = "2.20.0"
jline = "3.21.0"
@@ -45,18 +45,21 @@ mixin = "0.8.5"
mixinextras = "0.3.5"
minecraft = "1.21.11"
mockito = "5.+"
runtask = "2.3.1"
runpaperversion = "1.21.11"
runvelocityversion = "3.4.0-SNAPSHOT"
# plugin versions
indra = "3.1.3"
shadow = "8.1.1"
architectury-plugin = "3.4-SNAPSHOT"
architectury-loom = "1.13-SNAPSHOT"
minotaur = "2.8.7"
lombok = "8.4"
blossom = "2.1.0"
indra = "4.0.0"
shadow = "9.2.2"
architectury-plugin = "3.4.162"
architectury-loom = "1.13.457"
loom-companion = "1.13.467"
minotaur = "2.8.10"
lombok = "9.1.0"
blossom = "2.2.0"
runtask = "3.0.2"
# run tasks versions
runpaperversion = "1.21.11"
runvelocityversion = "3.4.0-SNAPSHOT"
[libraries]
base-api = { group = "org.geysermc.api", name = "base-api", version.ref = "base-api" }
@@ -159,10 +162,11 @@ mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }
# plugins
lombok = { group = "io.freefair.gradle", name = "lombok-plugin", version.ref = "lombok" }
indra = { group = "net.kyori", name = "indra-common", version.ref = "indra" }
shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" }
shadow = { group = "com.gradleup.shadow", name = "com.gradleup.shadow.gradle.plugin", version.ref = "shadow" }
architectury-plugin = { group = "architectury-plugin", name = "architectury-plugin.gradle.plugin", version.ref = "architectury-plugin" }
architectury-loom = { group = "dev.architectury.loom", name = "dev.architectury.loom.gradle.plugin", version.ref = "architectury-loom" }
minotaur = { group = "com.modrinth.minotaur", name = "Minotaur", version.ref = "minotaur" }
loom-companion = { group = "dev.architectury.loom-companion", name = "dev.architectury.loom-companion.gradle.plugin", version.ref = "loom-companion" }
[plugins]
indra = { id = "net.kyori.indra", version.ref = "indra" }

Binary file not shown.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

12
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -115,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -173,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -206,15 +203,14 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.

3
gradlew.bat vendored
View File

@@ -70,11 +70,10 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell