Merge pull request 'Stonecutter step 1: build 1.21.11 from a shared src/' (#24) from stonecutter-scaffold into stonecutter
Reviewed-on: #24
This commit was merged in pull request #24.
This commit is contained in:
@@ -47,8 +47,8 @@ git clone --recurse-submodules https://git.selimaj.dev/saturnclientmc/saturnclie
|
|||||||
cd saturnclient
|
cd saturnclient
|
||||||
|
|
||||||
./gradlew buildAll # every version → build/allJars/
|
./gradlew buildAll # every version → build/allJars/
|
||||||
./gradlew :mc-1.21.11:build # a single version
|
./gradlew :1.21.11:build # a single version (versions not on Stonecutter yet: :mc-1.21.10)
|
||||||
./gradlew :mc-1.21.11:runClient # launch a development client
|
./gradlew :1.21.11:runClient # launch a development client
|
||||||
```
|
```
|
||||||
|
|
||||||
Building needs Java 21.
|
Building needs Java 21.
|
||||||
|
|||||||
+31
-11
@@ -4,12 +4,30 @@ How Saturn Client supports several Minecraft versions, and how to change or add
|
|||||||
|
|
||||||
## Layout
|
## Layout
|
||||||
|
|
||||||
- `common/`: all version-independent code (mods, UI, cosmetics, the server client). It has no Minecraft dependency and reaches the game only through the interfaces in `org.saturnclient.common`.
|
Saturn is moving from one full copy of the version-specific code per Minecraft version to a single copy built with [Stonecutter](https://stonecutter.kikugie.dev/) (issue #8). During the move there are two kinds of version:
|
||||||
- `versions/<mc>/`: one module per Minecraft version, implementing those interfaces (providers, refs, mixins). Each is a full copy, and they differ only where Minecraft's API differs.
|
|
||||||
- `gradle.properties`: the Minecraft, Yarn, Fabric Loader and Fabric API versions.
|
|
||||||
- `src/`: the version-specific code and the three mixin configs.
|
|
||||||
|
|
||||||
`settings.gradle` includes every folder under `versions/` automatically, as the Gradle project `:mc-<mc>`.
|
- `common/`: all version-independent code (mods, UI, cosmetics, the server client). It has no Minecraft dependency and reaches the game only through the interfaces in `org.saturnclient.common`.
|
||||||
|
- `src/`: the version-specific code (providers, refs, mixins and the three mixin configs) for the versions built by Stonecutter, currently **1.21.11**. It's one copy: where Minecraft's API differs between them, the code goes behind version comments (see below). Each of these versions is the Gradle project `:<mc>`, and `versions/<mc>/` holds only its `gradle.properties` (Minecraft, Yarn, Fabric Loader and Fabric API versions), `build/` and `run/`.
|
||||||
|
- `versions/<mc>/src/`: the versions not moved yet (1.21.4 to 1.21.10), each a full copy, as the Gradle project `:mc-<mc>` with its own `build.gradle`.
|
||||||
|
|
||||||
|
`settings.gradle.kts` lists the Stonecutter versions in `stonecutterVersions` and includes every other folder under `versions/` as `:mc-<mc>`. The root `build.gradle.kts` builds each Stonecutter version, and `stonecutter.gradle.kts` configures the root project (shared repositories, the `common` wiring and `buildAll`). Loom's version for the Stonecutter versions is `loom_version` in the root `gradle.properties`.
|
||||||
|
|
||||||
|
## Version-specific code with Stonecutter
|
||||||
|
|
||||||
|
The code in `src/` is always plain Java for the **active** version (1.21.11, set in `stonecutter.gradle.kts`). Code for other versions sits in comments that Stonecutter swaps before building each version:
|
||||||
|
|
||||||
|
```java
|
||||||
|
//? if >=1.21.9 {
|
||||||
|
public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {
|
||||||
|
//?} else
|
||||||
|
/*public void render(MatrixStack matrices, VertexConsumerProvider consumers, int light, PlayerEntityRenderState state, float limbAngle, float limbDistance) {*/
|
||||||
|
```
|
||||||
|
|
||||||
|
- `./gradlew "Set active project to <mc>"` (or the Stonecutter IntelliJ plugin) rewrites `src/` so that version's code is the uncommented one, for editing it in the IDE.
|
||||||
|
- `./gradlew "Reset active project"` switches back to 1.21.11. **Run it before committing**, so `src/` is always committed with 1.21.11 active.
|
||||||
|
- Each version's processed copy is compiled from `versions/<mc>/build/generated/stonecutter/`, which is also where to look when a non-active version fails to compile.
|
||||||
|
|
||||||
|
The `emotes` repository uses the same setup, and its `BentCubeRenderer` and `PlayerModelMixin` are small examples of version comments.
|
||||||
|
|
||||||
## Porting a change to the other versions
|
## Porting a change to the other versions
|
||||||
|
|
||||||
@@ -22,13 +40,13 @@ scripts/port.sh --to 1.21.9,1.21.10 # only some versions
|
|||||||
scripts/port.sh --commit <rev> # port what a commit changed instead
|
scripts/port.sh --commit <rev> # port what a commit changed instead
|
||||||
```
|
```
|
||||||
|
|
||||||
The script applies the diff under `versions/<from>/src` to each other version with `git apply --3way`:
|
The script applies the diff under one version's source to each other version with `git apply --3way`. The Stonecutter `src/` counts as one version (1.21.11), so changes port between it and the old copies in both directions:
|
||||||
|
|
||||||
- **applied**: the files matched, and nothing else is needed.
|
- **applied**: the files matched, and nothing else is needed.
|
||||||
- **CONFLICTS**: that version's code really differs. The file gets normal conflict markers, with the version's own code in `ours` and the ported change in `theirs`. Adapt the change to that version's API and resolve.
|
- **CONFLICTS**: that version's code really differs. The file gets normal conflict markers, with the version's own code in `ours` and the ported change in `theirs`. Adapt the change to that version's API and resolve.
|
||||||
- **already has this change**: nothing to do, which is safe to see when re-running.
|
- **already has this change**: nothing to do, which is safe to see when re-running.
|
||||||
|
|
||||||
Only `src/` is ported. `build.gradle` and `gradle.properties` are version-specific on purpose. Then build everything:
|
Only source is ported. `build.gradle` and `gradle.properties` are version-specific on purpose. Then build everything:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./gradlew compileJava
|
./gradlew compileJava
|
||||||
@@ -38,7 +56,9 @@ The **Check** workflow runs the same compile on every pull request, so a version
|
|||||||
|
|
||||||
## Adding a Minecraft version
|
## Adding a Minecraft version
|
||||||
|
|
||||||
1. Copy the closest existing version: `cp -r versions/1.21.11 versions/<new>`. Delete its `build/`, `.gradle/` and `run/` folders if present.
|
Add new versions to Stonecutter rather than copying a folder:
|
||||||
2. In `versions/<new>/gradle.properties`, set `minecraft_version`, `yarn_mappings`, `loader_version` and `fabric_api_version`. The right values are listed at <https://fabricmc.net/develop>.
|
|
||||||
3. Build it with `./gradlew :mc-<new>:compileJava` and fix what Minecraft changed. Check the mixin configs in `src/main/resources/*.mixins.json` as well: a mixin whose target changed fails at startup, not at compile time, so launch it with `./gradlew :mc-<new>:runClient`.
|
1. Create `versions/<new>/gradle.properties` with `minecraft_version`, `yarn_mappings`, `loader_version` and `fabric_api_version` (copy 1.21.11's and change the values; they're listed at <https://fabricmc.net/develop>). Loom's version is shared, in the root `gradle.properties`.
|
||||||
4. The release workflow builds every folder under `versions/`, and "Publish to Modrinth" takes the game version from each jar's name, so neither needs changing.
|
2. Add `<new>` to `stonecutterVersions` in `settings.gradle.kts`.
|
||||||
|
3. Build it with `./gradlew :<new>:compileJava` and put what Minecraft changed behind version comments. Check the mixin configs in `src/main/resources/*.mixins.json` as well: a mixin whose target changed fails at startup, not at compile time, so launch it with `./gradlew :<new>:runClient`.
|
||||||
|
4. The release workflow builds everything through `buildAll`, and "Publish to Modrinth" takes the game version from each jar's name, so neither needs changing.
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
subprojects {
|
|
||||||
apply plugin: "java"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { url "https://maven.fabricmc.net/" }
|
|
||||||
maven { url "https://git.selimaj.dev/api/packages/selimaj-dev/maven" }
|
|
||||||
maven { url "https://git.selimaj.dev/api/packages/saturnclientmc/maven" }
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "de.javagl:obj:0.4.0"
|
|
||||||
implementation "com.formdev:svgSalamander:1.1.4"
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.17.0'
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.17.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configure(subprojects.findAll { it.name != "common" }) {
|
|
||||||
dependencies {
|
|
||||||
implementation project(":common")
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
resources {
|
|
||||||
srcDir project(":common").file("src/main/resources")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("buildAll") {
|
|
||||||
group = "build"
|
|
||||||
description = "Builds all subprojects and collects their remapped jars"
|
|
||||||
|
|
||||||
// Only build remapped jars (not full build)
|
|
||||||
dependsOn subprojects.collect { proj ->
|
|
||||||
proj.tasks.matching { it.name == "remapJar" }
|
|
||||||
}
|
|
||||||
|
|
||||||
doLast {
|
|
||||||
def outputDir = file("$buildDir/allJars")
|
|
||||||
outputDir.mkdirs()
|
|
||||||
|
|
||||||
subprojects.each { proj ->
|
|
||||||
def remapTask = proj.tasks.findByName("remapJar")
|
|
||||||
|
|
||||||
if (remapTask != null) {
|
|
||||||
def jarFile = remapTask.archiveFile.get().asFile
|
|
||||||
|
|
||||||
if (jarFile.exists() && !jarFile.name.contains("sources")) {
|
|
||||||
copy {
|
|
||||||
from jarFile
|
|
||||||
into outputDir
|
|
||||||
rename { "${jarFile.name}" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
println "All remapped jars collected in: $outputDir"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
// Builds one Minecraft version from the shared src/. Stonecutter runs this for each version in
|
||||||
|
// stonecutterVersions (settings.gradle.kts), with that version's versions/<v>/gradle.properties.
|
||||||
|
plugins {
|
||||||
|
id("net.fabricmc.fabric-loom-remap")
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
val minecraftVersion = property("minecraft_version") as String
|
||||||
|
val loaderVersion = property("loader_version") as String
|
||||||
|
|
||||||
|
version = "${property("mod_version")}+$minecraftVersion"
|
||||||
|
group = property("maven_group") as String
|
||||||
|
|
||||||
|
base {
|
||||||
|
archivesName = property("archives_base_name") as String
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
minecraft("com.mojang:minecraft:$minecraftVersion")
|
||||||
|
mappings("net.fabricmc:yarn:${property("yarn_mappings")}:v2")
|
||||||
|
modImplementation("net.fabricmc:fabric-loader:$loaderVersion")
|
||||||
|
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("fabric_api_version")}")
|
||||||
|
|
||||||
|
// Saturn's emote library (limb bending, Emotecraft emotes)
|
||||||
|
include(modImplementation("org.saturnclient:emotes-fabric:${property("emotes_version")}+$minecraftVersion")!!)
|
||||||
|
|
||||||
|
implementation(project(":common"))
|
||||||
|
|
||||||
|
for (library in listOf(
|
||||||
|
"dev.selimaj:session-java:0.2.0",
|
||||||
|
"de.javagl:obj:0.4.0",
|
||||||
|
"com.formdev:svgSalamander:1.1.4",
|
||||||
|
"com.fasterxml.jackson.core:jackson-databind:2.17.0",
|
||||||
|
"com.fasterxml.jackson.core:jackson-annotations:2.17.0",
|
||||||
|
"com.fasterxml.jackson.core:jackson-core:2.17.0",
|
||||||
|
)) {
|
||||||
|
include(implementation(library)!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Injects the version values into fabric.mod.json.
|
||||||
|
tasks.processResources {
|
||||||
|
val values = mapOf(
|
||||||
|
"version" to project.version.toString(),
|
||||||
|
"minecraft_version" to minecraftVersion,
|
||||||
|
"loader_version" to loaderVersion,
|
||||||
|
)
|
||||||
|
inputs.properties(values)
|
||||||
|
filteringCharset = "UTF-8"
|
||||||
|
filesMatching("fabric.mod.json") { expand(values) }
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
|
options.release = 21
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
// Loom attaches the sources jar to remapSourcesJar and build.
|
||||||
|
withSourcesJar()
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
val archivesName = base.archivesName
|
||||||
|
inputs.property("archivesName", archivesName)
|
||||||
|
from("LICENSE") {
|
||||||
|
rename { "${it}_${archivesName.get()}" }
|
||||||
|
}
|
||||||
|
from(project(":common").extensions.getByType<SourceSetContainer>()["main"].output)
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("mavenJava") {
|
||||||
|
artifactId = property("archives_base_name") as String
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,3 +10,6 @@ mod_version=0.1.1-beta
|
|||||||
|
|
||||||
# Saturn's emote library (git.selimaj.dev/saturnclientmc/emotes)
|
# Saturn's emote library (git.selimaj.dev/saturnclientmc/emotes)
|
||||||
emotes_version=0.1.0
|
emotes_version=0.1.0
|
||||||
|
|
||||||
|
# Loom, for the Stonecutter versions (settings.gradle.kts). Old mc-<v> projects set their own.
|
||||||
|
loom_version=1.17.21
|
||||||
|
|||||||
+46
-18
@@ -1,11 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Port a change made in one Minecraft version's code to the other versions.
|
# Port a change made in one Minecraft version's code to the other versions.
|
||||||
#
|
#
|
||||||
# Takes the diff under versions/<from>/src and applies it to versions/<to>/src
|
# Takes the diff under one version's source folder and applies it to the others
|
||||||
# with `git apply --3way`: it applies cleanly where the files match, and leaves
|
# with `git apply --3way`: it applies cleanly where the files match, and leaves
|
||||||
# normal merge conflicts only where a version really differs. Only src/ is
|
# normal merge conflicts only where a version really differs. Only source is
|
||||||
# ported; build.gradle and gradle.properties are version-specific on purpose.
|
# ported; build.gradle and gradle.properties are version-specific on purpose.
|
||||||
#
|
#
|
||||||
|
# Versions moved to Stonecutter (stonecutterVersions in settings.gradle.kts)
|
||||||
|
# share the top-level src/, which counts as one version: the active one set in
|
||||||
|
# stonecutter.gradle.kts. The others keep their own copy in versions/<v>/src.
|
||||||
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# scripts/port.sh [--from VERSION] [--to V1,V2,...] [--commit REV] [--dry-run]
|
# scripts/port.sh [--from VERSION] [--to V1,V2,...] [--commit REV] [--dry-run]
|
||||||
#
|
#
|
||||||
@@ -33,25 +37,39 @@ while [ $# -gt 0 ]; do
|
|||||||
--to) to="$2"; shift 2 ;;
|
--to) to="$2"; shift 2 ;;
|
||||||
--commit) commit="$2"; shift 2 ;;
|
--commit) commit="$2"; shift 2 ;;
|
||||||
--dry-run) dry_run=true; shift ;;
|
--dry-run) dry_run=true; shift ;;
|
||||||
-h|--help) sed -n '2,20p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
-h|--help) sed -n '2,23p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
||||||
*) echo "Unknown option: $1 (see --help)" >&2; exit 2 ;;
|
*) echo "Unknown option: $1 (see --help)" >&2; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
all_versions=$(ls -d versions/*/ | xargs -n1 basename | sort -t. -k1,1n -k2,2n -k3,3n)
|
# Versions sharing the Stonecutter src/, and the one that stands for them.
|
||||||
|
stonecutter_versions=$(sed -n 's/^val stonecutterVersions = listOf(\(.*\))/\1/p' settings.gradle.kts | tr -d '" ' | tr ',' ' ')
|
||||||
|
stonecutter_active=$(sed -n 's/^stonecutter active "\(.*\)"/\1/p' stonecutter.gradle.kts 2>/dev/null || true)
|
||||||
|
|
||||||
|
is_stonecutter() {
|
||||||
|
printf '%s\n' $stonecutter_versions | grep -qx "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Where a version's source lives.
|
||||||
|
src_of() {
|
||||||
|
if is_stonecutter "$1"; then echo "src"; else echo "versions/$1/src"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
old_versions=$(for d in versions/*/; do [ -d "$d/src" ] && basename "$d"; done)
|
||||||
|
all_versions=$(printf '%s\n' $old_versions $stonecutter_active | grep . | sort -t. -k1,1n -k2,2n -k3,3n)
|
||||||
|
|
||||||
version_exists() {
|
version_exists() {
|
||||||
[ -d "versions/$1/src" ]
|
[ -d "$(src_of "$1")" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Versions with changes, from the working tree or from the given commit.
|
# Versions with changes, from the working tree or from the given commit.
|
||||||
changed_versions() {
|
changed_versions() {
|
||||||
if [ -n "$commit" ]; then
|
if [ -n "$commit" ]; then
|
||||||
git show --name-only --format= "$commit" -- versions/
|
git show --name-only --format= "$commit" -- versions/ src/
|
||||||
else
|
else
|
||||||
git diff HEAD --name-only -- versions/
|
git diff HEAD --name-only -- versions/ src/
|
||||||
git ls-files --others --exclude-standard -- versions/
|
git ls-files --others --exclude-standard -- versions/ src/
|
||||||
fi | sed -n 's#^versions/\([^/]*\)/src/.*#\1#p' | sort -u
|
fi | sed -n -e 's#^versions/\([^/]*\)/src/.*#\1#p' -e "s#^src/.*#${stonecutter_active}#p" | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$from" ]; then
|
if [ -z "$from" ]; then
|
||||||
@@ -65,6 +83,10 @@ if [ -z "$from" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
version_exists "$from" || { echo "No such version: $from" >&2; exit 2; }
|
version_exists "$from" || { echo "No such version: $from" >&2; exit 2; }
|
||||||
|
if is_stonecutter "$from"; then
|
||||||
|
from="$stonecutter_active"
|
||||||
|
fi
|
||||||
|
from_src=$(src_of "$from")
|
||||||
|
|
||||||
if [ -z "$to" ]; then
|
if [ -z "$to" ]; then
|
||||||
to=$(printf '%s\n' $all_versions | grep -vx "$from" | paste -sd, -)
|
to=$(printf '%s\n' $all_versions | grep -vx "$from" | paste -sd, -)
|
||||||
@@ -72,10 +94,10 @@ fi
|
|||||||
|
|
||||||
# New files are only included in `git diff HEAD` once git knows about them.
|
# New files are only included in `git diff HEAD` once git knows about them.
|
||||||
if [ -z "$commit" ]; then
|
if [ -z "$commit" ]; then
|
||||||
untracked=$(git ls-files --others --exclude-standard -- "versions/$from/src")
|
untracked=$(git ls-files --others --exclude-standard -- "$from_src")
|
||||||
if [ -n "$untracked" ]; then
|
if [ -n "$untracked" ]; then
|
||||||
if $dry_run; then
|
if $dry_run; then
|
||||||
echo "note: new files in versions/$from/src are untracked and won't be ported in a dry run:" >&2
|
echo "note: new files in $from_src are untracked and won't be ported in a dry run:" >&2
|
||||||
printf ' %s\n' $untracked >&2
|
printf ' %s\n' $untracked >&2
|
||||||
else
|
else
|
||||||
printf '%s\n' "$untracked" | xargs git add --intent-to-add --
|
printf '%s\n' "$untracked" | xargs git add --intent-to-add --
|
||||||
@@ -85,20 +107,20 @@ fi
|
|||||||
|
|
||||||
# --full-index gives --3way the real blob ids to merge against.
|
# --full-index gives --3way the real blob ids to merge against.
|
||||||
if [ -n "$commit" ]; then
|
if [ -n "$commit" ]; then
|
||||||
patch=$(git show --full-index --binary --format= "$commit" -- "versions/$from/src")
|
patch=$(git show --full-index --binary --format= "$commit" -- "$from_src")
|
||||||
else
|
else
|
||||||
patch=$(git diff HEAD --full-index --binary -- "versions/$from/src")
|
patch=$(git diff HEAD --full-index --binary -- "$from_src")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$patch" ]; then
|
if [ -z "$patch" ]; then
|
||||||
echo "No changes under versions/$from/src to port." >&2
|
echo "No changes under $from_src to port." >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files=$(printf '%s\n' "$patch" | grep -c '^diff --git' || true)
|
files=$(printf '%s\n' "$patch" | grep -c '^diff --git' || true)
|
||||||
echo "Porting $files file(s) from $from${commit:+ (commit $commit)}"
|
echo "Porting $files file(s) from $from${commit:+ (commit $commit)}"
|
||||||
|
|
||||||
from_re=$(printf '%s' "$from" | sed 's/\./\\./g')
|
from_re=$(printf '%s' "$from_src" | sed 's/\./\\./g')
|
||||||
tmp=$(mktemp -d)
|
tmp=$(mktemp -d)
|
||||||
trap 'rm -rf "$tmp"' EXIT
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
|
|
||||||
@@ -109,14 +131,20 @@ for target in "${targets[@]}"; do
|
|||||||
if [ "$target" = "$from" ]; then
|
if [ "$target" = "$from" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
if is_stonecutter "$target" && [ "$target" != "$stonecutter_active" ]; then
|
||||||
|
printf ' %-8s skipped: shares src/ with %s\n' "$target" "$stonecutter_active"
|
||||||
|
[ "$from" = "$stonecutter_active" ] || status=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
if ! version_exists "$target"; then
|
if ! version_exists "$target"; then
|
||||||
printf ' %-8s skipped: no such version\n' "$target"
|
printf ' %-8s skipped: no such version\n' "$target"
|
||||||
status=1
|
status=1
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Point the patch's file headers at the target version.
|
# Point the patch's file headers at the target version's source folder.
|
||||||
printf '%s\n' "$patch" | sed -E "/^(diff --git |--- |\+\+\+ |rename (from|to) |copy (from|to) )/ s#versions/${from_re}/#versions/${target}/#g" > "$tmp/$target.patch"
|
target_src=$(src_of "$target")
|
||||||
|
printf '%s\n' "$patch" | sed -E "/^(diff --git |--- |\+\+\+ |rename (from|to) |copy (from|to) )/ s#([ab]/|(from|to) )${from_re}/#\1${target_src}/#g" > "$tmp/$target.patch"
|
||||||
|
|
||||||
if git apply --check --reverse "$tmp/$target.patch" 2>/dev/null; then
|
if git apply --check --reverse "$tmp/$target.patch" 2>/dev/null; then
|
||||||
printf ' %-8s already has this change\n' "$target"
|
printf ' %-8s already has this change\n' "$target"
|
||||||
@@ -135,7 +163,7 @@ for target in "${targets[@]}"; do
|
|||||||
if output=$(git apply --3way "$tmp/$target.patch" 2>&1); then
|
if output=$(git apply --3way "$tmp/$target.patch" 2>&1); then
|
||||||
printf ' %-8s applied\n' "$target"
|
printf ' %-8s applied\n' "$target"
|
||||||
else
|
else
|
||||||
conflicts=$(git diff --name-only --diff-filter=U -- "versions/$target")
|
conflicts=$(git diff --name-only --diff-filter=U -- "$target_src")
|
||||||
if [ -n "$conflicts" ]; then
|
if [ -n "$conflicts" ]; then
|
||||||
printf ' %-8s CONFLICTS in:\n' "$target"
|
printf ' %-8s CONFLICTS in:\n' "$target"
|
||||||
printf '%s\n' "$conflicts" | sed 's/^/ /'
|
printf '%s\n' "$conflicts" | sed 's/^/ /'
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
maven { url "https://maven.fabricmc.net/" }
|
|
||||||
gradlePluginPortal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = "saturn-client"
|
|
||||||
|
|
||||||
include("common")
|
|
||||||
|
|
||||||
def versionsDir = file("versions")
|
|
||||||
|
|
||||||
versionsDir.eachDir { dir ->
|
|
||||||
def version = dir.name
|
|
||||||
def projectName = "mc-${version}"
|
|
||||||
|
|
||||||
include(projectName)
|
|
||||||
project(":${projectName}").projectDir = dir
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven("https://maven.fabricmc.net/")
|
||||||
|
maven("https://maven.kikugie.dev/releases")
|
||||||
|
gradlePluginPortal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loom's version, for the Stonecutter versions' build.gradle.kts (the old mc-<v> projects set
|
||||||
|
// their own in versions/<v>/gradle.properties).
|
||||||
|
val loom_version: String by settings
|
||||||
|
plugins {
|
||||||
|
id("net.fabricmc.fabric-loom-remap") version loom_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("dev.kikugie.stonecutter") version "0.9.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "saturn-client"
|
||||||
|
|
||||||
|
include("common")
|
||||||
|
|
||||||
|
// Versions built by Stonecutter from the shared src/ (see stonecutter.gradle.kts). Each one's
|
||||||
|
// versions/<v>/gradle.properties holds its Minecraft, Yarn and Fabric API versions.
|
||||||
|
val stonecutterVersions = listOf("1.21.11")
|
||||||
|
|
||||||
|
stonecutter {
|
||||||
|
create(rootProject) {
|
||||||
|
versions(stonecutterVersions)
|
||||||
|
vcsVersion = "1.21.11"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Versions not moved to Stonecutter yet still build from their own copy in versions/<v>/src,
|
||||||
|
// as projects named mc-<v>.
|
||||||
|
file("versions").listFiles { file -> file.isDirectory && file.name !in stonecutterVersions }!!
|
||||||
|
.sortedBy { it.name }
|
||||||
|
.forEach { dir ->
|
||||||
|
include("mc-${dir.name}")
|
||||||
|
project(":mc-${dir.name}").projectDir = dir
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
plugins {
|
||||||
|
id("dev.kikugie.stonecutter")
|
||||||
|
}
|
||||||
|
|
||||||
|
// The version whose code is uncommented in src/. Switch with "Set active project to <v>", and run
|
||||||
|
// "Reset active project" before committing.
|
||||||
|
stonecutter active "1.21.11"
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
apply(plugin = "java")
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://maven.fabricmc.net/")
|
||||||
|
maven("https://git.selimaj.dev/api/packages/selimaj-dev/maven")
|
||||||
|
maven("https://git.selimaj.dev/api/packages/saturnclientmc/maven")
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
"implementation"("de.javagl:obj:0.4.0")
|
||||||
|
"implementation"("com.formdev:svgSalamander:1.1.4")
|
||||||
|
"implementation"("com.fasterxml.jackson.core:jackson-databind:2.17.0")
|
||||||
|
"implementation"("com.fasterxml.jackson.core:jackson-annotations:2.17.0")
|
||||||
|
"implementation"("com.fasterxml.jackson.core:jackson-core:2.17.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every Minecraft version builds on common and ships its resources.
|
||||||
|
configure(subprojects.filter { it.name != "common" }) {
|
||||||
|
dependencies {
|
||||||
|
"implementation"(project(":common"))
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.configure<SourceSetContainer> {
|
||||||
|
named("main") {
|
||||||
|
resources.srcDir(project(":common").file("src/main/resources"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remapJar loads a whole Minecraft classpath and remaps a ~50 MB jar. Eight at once don't fit in the
|
||||||
|
// daemon's heap (org.gradle.jvmargs) and the build stalls in garbage collection, so only two run
|
||||||
|
// together. Everything else still builds in parallel.
|
||||||
|
abstract class RemapLimit : BuildService<BuildServiceParameters.None>
|
||||||
|
|
||||||
|
val remapLimit = gradle.sharedServices.registerIfAbsent("remapLimit", RemapLimit::class) {
|
||||||
|
maxParallelUsages = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
tasks.matching { it.name == "remapJar" }.configureEach {
|
||||||
|
usesService(remapLimit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("buildAll") {
|
||||||
|
group = "build"
|
||||||
|
description = "Builds every Minecraft version's remapped jar and collects them in build/allJars"
|
||||||
|
|
||||||
|
val remapJars = subprojects.flatMap { it.tasks.matching { task -> task.name == "remapJar" } }
|
||||||
|
dependsOn(remapJars)
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
val outputDir = layout.buildDirectory.dir("allJars").get().asFile
|
||||||
|
outputDir.mkdirs()
|
||||||
|
remapJars.map { (it as AbstractArchiveTask).archiveFile.get().asFile }
|
||||||
|
.filter { it.exists() && !it.name.contains("sources") }
|
||||||
|
.forEach { it.copyTo(outputDir.resolve(it.name), overwrite = true) }
|
||||||
|
println("All remapped jars collected in: $outputDir")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'net.fabricmc.fabric-loom-remap' version "${loom_version}"
|
|
||||||
id 'maven-publish'
|
|
||||||
}
|
|
||||||
|
|
||||||
version = "${project.mod_version}+${project.minecraft_version}"
|
|
||||||
group = project.maven_group
|
|
||||||
|
|
||||||
base {
|
|
||||||
archivesName = project.archives_base_name
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { name = "Selimaj"; url = 'https://git.selimaj.dev/api/packages/selimaj-dev/maven' }
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
// To change the versions see the gradle.properties file
|
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
|
|
||||||
|
|
||||||
// Saturn's emote library (limb bending, Emotecraft emotes)
|
|
||||||
include modImplementation("org.saturnclient:emotes-fabric:${project.emotes_version}+${project.minecraft_version}")
|
|
||||||
|
|
||||||
implementation project(":common")
|
|
||||||
|
|
||||||
include implementation("dev.selimaj:session-java:0.2.0")
|
|
||||||
include implementation("de.javagl:obj:0.4.0")
|
|
||||||
include implementation("com.formdev:svgSalamander:1.1.4")
|
|
||||||
include implementation("com.fasterxml.jackson.core:jackson-databind:2.17.0")
|
|
||||||
include implementation("com.fasterxml.jackson.core:jackson-annotations:2.17.0")
|
|
||||||
include implementation("com.fasterxml.jackson.core:jackson-core:2.17.0")
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ================================================================
|
|
||||||
* Resource Processing
|
|
||||||
* ================================================================
|
|
||||||
* Injects version values into fabric.mod.json.
|
|
||||||
*/
|
|
||||||
processResources {
|
|
||||||
inputs.property "version", project.version
|
|
||||||
inputs.property "minecraft_version", project.minecraft_version
|
|
||||||
inputs.property "loader_version", project.loader_version
|
|
||||||
filteringCharset "UTF-8"
|
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
|
||||||
expand(
|
|
||||||
"version": project.version,
|
|
||||||
"minecraft_version": project.minecraft_version,
|
|
||||||
"loader_version": project.loader_version
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
it.options.release = 21
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
|
||||||
// if it is present.
|
|
||||||
// If you remove this line, sources will not be generated.
|
|
||||||
withSourcesJar()
|
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
inputs.property "archivesName", project.base.archivesName
|
|
||||||
|
|
||||||
from("LICENSE") {
|
|
||||||
rename { "${it}_${inputs.properties.archivesName}"}
|
|
||||||
}
|
|
||||||
|
|
||||||
from project(":common").sourceSets.main.output
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure the maven publication
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create("mavenJava", MavenPublication) {
|
|
||||||
artifactId = project.archives_base_name
|
|
||||||
from components.java
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
|
||||||
repositories {
|
|
||||||
// Add repositories to publish to here.
|
|
||||||
// Notice: This block does NOT have the same function as the block in the top level.
|
|
||||||
// The repositories here will be used for publishing your artifact, not for
|
|
||||||
// retrieving dependencies.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ org.gradle.configuration-cache=false
|
|||||||
minecraft_version=1.21.11
|
minecraft_version=1.21.11
|
||||||
yarn_mappings=1.21.11+build.4
|
yarn_mappings=1.21.11+build.4
|
||||||
loader_version=0.19.0
|
loader_version=0.19.0
|
||||||
loom_version=1.17.21
|
|
||||||
|
|
||||||
fabric_api_version=0.141.3+1.21.11
|
fabric_api_version=0.141.3+1.21.11
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = 'Fabric'
|
|
||||||
url = 'https://maven.fabricmc.net/'
|
|
||||||
}
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user