From 8b3914edc68dc4b7172b2555913cf4708380f30d Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Sun, 5 Jan 2025 16:22:31 +0300 Subject: [PATCH] prepare hard fork environment --- .gitattributes | 7 + .gitignore | 17 +- build-data/dev-imports.txt | 4 + build-data/divinemc.at | 2 + build.gradle.kts | 139 ++++++++--------- divinemc-server/build.gradle.kts.patch | 11 ++ gradle.properties | 3 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 3 +- gradlew.bat | 188 +++++++++++------------ settings.gradle.kts | 10 +- 11 files changed, 202 insertions(+), 184 deletions(-) create mode 100644 .gitattributes create mode 100644 build-data/divinemc.at create mode 100644 divinemc-server/build.gradle.kts.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c850393 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +* text=auto eol=lf + +*.sh text eol=lf +gradlew text eol=lf +*.bat text eol=crlf + +*.jar binary \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8cdd4cd..5e8389b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,16 @@ -# DivineMC-API and DivineMC-Server changes + paper-api-generator -DivineMC-API -DivineMC-Server -paper-api-generator/* - # IDE and Gradle things build .gradle run .idea -# Other files and folders -build-data \ No newline at end of file +# Server things +/divinemc-server/build.gradle.kts +/divinemc-server/src/minecraft +/paper-server +/purpur-server +/divinemc-api/build.gradle.kts +/paper-api +/paper-api-generator +/purpur-api +*.jar diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index b818b96..1d9862a 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -8,3 +8,7 @@ # To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId: # minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter # minecraft net/minecraft/world/level/entity/LevelEntityGetter.java +# To import minecraft data files, like the default chat type, use `mc_data` as the prefix: +# mc_data chat_type/chat.json +# mc_data dimension_type/overworld.json +# diff --git a/build-data/divinemc.at b/build-data/divinemc.at new file mode 100644 index 0000000..82bf45f --- /dev/null +++ b/build-data/divinemc.at @@ -0,0 +1,2 @@ +# This file is auto generated, any changes may be overridden! +# See CONTRIBUTING.md on how to add access transformers. diff --git a/build.gradle.kts b/build.gradle.kts index 5905e3e..c79fee3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,43 +1,65 @@ -import io.papermc.paperweight.util.constants.PAPERCLIP_CONFIG +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { java - `maven-publish` - id("io.papermc.paperweight.patcher") version "1.7.7" + id("io.papermc.paperweight.patcher") version "2.0.0-beta.11" } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" -repositories { - mavenCentral() - maven("https://papermc.io/repo/repository/maven-public/") { - content { - onlyForConfigurations(PAPERCLIP_CONFIG) +paperweight { + upstreams.register("purpur") { + repo = github("PurpurMC", "Purpur") + ref = providers.gradleProperty("purpurRef") + + patchFile { + path = "purpur-server/build.gradle.kts" + outputFile = file("divinemc-server/build.gradle.kts") + patchFile = file("divinemc-server/build.gradle.kts.patch") } - } -} - -dependencies { - remapper("net.fabricmc:tiny-remapper:0.10.3:fat") - decompiler("org.vineflower:vineflower:1.10.1") - paperclip("io.papermc:paperclip:3.0.3") -} - -allprojects { - apply(plugin = "java") - apply(plugin = "maven-publish") - - java { - toolchain { - languageVersion = JavaLanguageVersion.of(21) + patchFile { + path = "purpur-api/build.gradle.kts" + outputFile = file("divinemc-api/build.gradle.kts") + patchFile = file("divinemc-api/build.gradle.kts.patch") + } + patchRepo("paperApi") { + upstreamPath = "paper-api" + patchesDir = file("divinemc-api/paper-patches") + outputDir = file("paper-api") + } + patchRepo("paperApiGenerator") { + upstreamPath = "paper-api-generator" + patchesDir = file("divinemc-api-generator/paper-patches") + outputDir = file("paper-api-generator") + } + patchDir("purpurApi") { + upstreamPath = "purpur-api" + excludes = listOf("build.gradle.kts", "build.gradle.kts.patch", "paper-patches") + patchesDir = file("divinemc-api/purpur-patches") + outputDir = file("purpur-api") } } } subprojects { + apply(plugin = "java-library") + apply(plugin = "maven-publish") + + extensions.configure { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } + } + + dependencies { + "testRuntimeOnly"("org.junit.platform:junit-platform-launcher") + } + tasks.withType { options.encoding = Charsets.UTF_8.name() - options.release.set(21) + options.release = 21 + options.isFork = true } tasks.withType { options.encoding = Charsets.UTF_8.name() @@ -45,64 +67,29 @@ subprojects { tasks.withType { filteringCharset = Charsets.UTF_8.name() } + tasks.withType { + testLogging { + showStackTraces = true + exceptionFormat = TestExceptionFormat.FULL + events(TestLogEvent.STANDARD_OUT) + } + } + tasks.withType().configureEach { + isPreserveFileTimestamps = false + isReproducibleFileOrder = true + } repositories { mavenCentral() maven(paperMavenPublicUrl) - maven("https://oss.sonatype.org/content/groups/public/") - maven("https://ci.emc.gs/nexus/content/groups/aikar/") - maven("https://repo.aikar.co/content/groups/aikar") - maven("https://repo.md-5.net/content/repositories/releases/") - maven("https://hub.spigotmc.org/nexus/content/groups/public/") maven("https://jitpack.io") } -} -paperweight { - serverProject.set(project(":divinemc-server")) - - remapRepo.set("https://maven.fabricmc.net/") - decompileRepo.set(paperMavenPublicUrl) - - useStandardUpstream("purpur") { - url.set(github("PurpurMC", "Purpur")) - ref.set(providers.gradleProperty("purpurRef")) - - withStandardPatcher { - apiSourceDirPath.set("Purpur-API") - serverSourceDirPath.set("Purpur-Server") - - apiPatchDir.set(layout.projectDirectory.dir("patches/api")) - apiOutputDir.set(layout.projectDirectory.dir("DivineMC-API")) - - serverPatchDir.set(layout.projectDirectory.dir("patches/server")) - serverOutputDir.set(layout.projectDirectory.dir("DivineMC-Server")) - } - - patchTasks.register("generatedApi") { - isBareDirectory = true - upstreamDirPath = "paper-api-generator/generated" - patchDir = layout.projectDirectory.dir("patches/generated-api") - outputDir = layout.projectDirectory.dir("paper-api-generator/generated") - } - } -} - -tasks.generateDevelopmentBundle { - apiCoordinates = "space.bxteam.divinemc:divinemc-api" - libraryRepositories.set( - listOf( - "https://repo.maven.apache.org/maven2/", - paperMavenPublicUrl - ) - ) -} - -publishing { - if (project.providers.gradleProperty("publishDevBundle").isPresent) { - publications.create("devBundle") { - artifact(tasks.generateDevelopmentBundle) { - artifactId = "dev-bundle" + extensions.configure { + repositories { + maven("https://repo.bx-team.space/snapshots") { + name = "divinemc" + credentials(PasswordCredentials::class) } } } diff --git a/divinemc-server/build.gradle.kts.patch b/divinemc-server/build.gradle.kts.patch new file mode 100644 index 0000000..4768c03 --- /dev/null +++ b/divinemc-server/build.gradle.kts.patch @@ -0,0 +1,11 @@ +--- a/purpur-server/build.gradle.kts ++++ b/purpur-server/build.gradle.kts +@@ -146,7 +_,7 @@ + // Paper end - configure mockito agent that is needed in newer java versions + + dependencies { +- implementation(project(":purpur-api")) ++ implementation(project(":divinemc-api")) // DivineMC + implementation("ca.spottedleaf:concurrentutil:0.0.2") // Paper - Add ConcurrentUtil dependency + // Paper start + implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 07b8fac..0e1f626 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,8 +2,9 @@ group = space.bxteam.divinemc mcVersion = 1.21.4 version = 1.21.4-R0.1-SNAPSHOT -purpurRef = 4bf1b988c3e2cc1277ed912e0107e2f34ab36a43 +purpurRef = e11f9642928cdce00437b6a11cf3fb1881939d9a +org.gradle.configuration-cache=true org.gradle.caching = true org.gradle.parallel = true org.gradle.vfs.watch = false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6..f3b75f3 100755 --- a/gradlew +++ b/gradlew @@ -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 diff --git a/gradlew.bat b/gradlew.bat index 9b42019..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,94 +1,94 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -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 %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +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 %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts index bc6c6f3..e44a065 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,15 +2,19 @@ import java.util.Locale pluginManagement { repositories { - mavenLocal() gradlePluginPortal() - maven("https://papermc.io/repo/repository/maven-public/") + mavenLocal() + maven("https://repo.papermc.io/repository/maven-public/") } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0" +} + rootProject.name = "DivineMC" -for (name in listOf("DivineMC-API", "DivineMC-Server", "paper-api-generator")) { +for (name in listOf("divinemc-api", "divinemc-server", "divinemc-api-generator")) { val projName = name.lowercase(Locale.ENGLISH) include(projName) findProject(":$projName")!!.projectDir = file(name)