Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceWalkerRS committed Jun 15, 2024
2 parents cc7e846 + dc0ea16 commit 589aab1
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 28 deletions.
8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
it.options.release = 21
}

application {
Expand Down Expand Up @@ -66,17 +66,15 @@ dependencies {
implementation "net.ornithemc:mapping-utils:${mapping_utils_version}"

// Testing
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
testImplementation(platform("org.junit:junit-bom:5.10.+"))
testImplementation("org.junit.jupiter:junit-jupiter:5.10.+")
}

// if not working: run ./gradlew run --refresh-dependencies
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 15, 'minutes'
}



test {
maxHeapSize = "4G"
useJUnitPlatform()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = 0.2.0-SNAPSHOT
# GitCraft Dependencies
groovy_version = 4.0.21
gson_version = 2.11.0
fabric_loader_version = 0.15.10
fabric_loader_version = 0.15.11
asm_version = 9.7
stitch_version = 0.15.9
tiny_remapper_version = 0.10.2
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_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" \
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Options:
Creates a separate branch for each version,
including linear versions. This may be useful
for quickly switching between multiple versions.
--create-stable-version-branches
Creates a separate branch for each stable linear
versions. This may be useful for quickly switching
between multiple versions.
--exclude-version[=<version>[,<version>]...]
Specify version(s) to exclude from decompilation.
The exclusion info will be added to the
Expand Down
23 changes: 23 additions & 0 deletions semver-cache-mojang-launcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@
"1.20.3-rc1": "1.20.3-rc.1",
"1.20.4": "1.20.4",
"1.20.4-rc1": "1.20.4-rc.1",
"1.20.5": "1.20.5",
"1.20.5-pre1": "1.20.5-beta.1",
"1.20.5-pre2": "1.20.5-beta.2",
"1.20.5-pre3": "1.20.5-beta.3",
"1.20.5-pre4": "1.20.5-beta.4",
"1.20.5-rc1": "1.20.5-rc.1",
"1.20.5-rc2": "1.20.5-rc.2",
"1.20.5-rc3": "1.20.5-rc.3",
"1.20.6": "1.20.6",
"1.20.6-rc1": "1.20.6-rc.1",
"1.3": "1.3",
"1.3.1": "1.3.1",
"1.3.2": "1.3.2",
Expand Down Expand Up @@ -687,6 +697,19 @@
"24w03a": "1.20.5-alpha.24.3.a",
"24w03b": "1.20.5-alpha.24.3.b",
"24w04a": "1.20.5-alpha.24.4.a",
"24w05a": "1.20.5-alpha.24.5.a",
"24w05b": "1.20.5-alpha.24.5.b",
"24w06a": "1.20.5-alpha.24.6.a",
"24w07a": "1.20.5-alpha.24.7.a",
"24w09a": "1.20.5-alpha.24.9.a",
"24w10a": "1.20.5-alpha.24.10.a",
"24w11a": "1.20.5-alpha.24.11.a",
"24w12a": "1.20.5-alpha.24.12.a",
"24w13a": "1.20.5-alpha.24.13.a",
"24w14a": "1.20.5-alpha.24.14.a",
"24w14potato": "1.20.5-alpha.24.12.potato",
"24w14potato_original": "1.20.5-alpha.24.12.potato.original",
"24w18a": "1.21-alpha.24.18.a",
"3D Shareware v1.34": "1.14-alpha.19.13.shareware",
"a1.0.11": "1.0.0-alpha.0.11",
"a1.0.14": "1.0.0-alpha.0.14",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class GitCraftCli {
cli_args._(longOpt: 'override-repo-target', args: 1, argName: 'path', type: Path,
'Changes the location of the target repository, as repo names may get quite long and unintuitive. If not used carefully, this can lead to repositories with unwanted mixed mappings or straight up refuse to work as some versions in the target repository may be missing.');
cli_args._(longOpt: 'create-version-branches', 'Creates a separate branch for each version, including linear versions. This may be useful for quickly switching between multiple versions.')
cli_args._(longOpt: 'create-stable-version-branches', 'Creates a separate branch for each stable linear version. This may be useful for quickly switching between multiple versions.')
cli_args._(longOpt: 'sort-json', 'Sorts JSON objects contained in JSON files (e.g. models, language files, ...) in natural order. This is disabled by default as it modifies original data.')
cli_args.h(longOpt: 'help', 'Displays this help screen');
return cli_args;
Expand All @@ -71,6 +72,7 @@ class GitCraftCli {
config.loadDatagenRegistry = !cli_args_parsed.hasOption("no-datagen-report");
config.refreshDecompilation = cli_args_parsed.hasOption("refresh");
config.createVersionBranches = cli_args_parsed.hasOption("create-version-branches");
config.createStableVersionBranches = cli_args_parsed.hasOption("create-stable-version-branches");
config.sortJsonObjects = cli_args_parsed.hasOption("sort-json");
if (cli_args_parsed.hasOption("help")) {
cli_args.usage();
Expand Down
14 changes: 10 additions & 4 deletions src/main/groovy/com/github/winplay02/gitcraft/GitCraftConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class GitCraftConfig {
public String gitMail = "[email protected]";
public String gitMainlineLinearBranch = "master";
public boolean createVersionBranches = false;
public boolean createStableVersionBranches = false;

/// Refresh settings
public boolean refreshDecompilation = false;
Expand All @@ -67,7 +68,7 @@ public class GitCraftConfig {
public String[] excludedVersion = null;

/// Mapping quirks
public static final String MIN_SUPPORTED_FABRIC_LOADER = "0.15.6";
public static final String MIN_SUPPORTED_FABRIC_LOADER = "0.15.11";
public static final int ORNITHE_INTERMEDIARY_GEN = 2;
public static final SemanticVersion CALAMUS_MAPPINGS_START_VERSION, CALAMUS_MAPPINGS_END_VERSION, FEATHER_MAPPINGS_START_VERSION, FEATHER_MAPPINGS_END_VERSION;
public static final SemanticVersion INTERMEDIARY_MAPPINGS_START_VERSION, YARN_MAPPINGS_START_VERSION, YARN_CORRECTLY_ORIENTATED_MAPPINGS_VERSION, PARCHMENT_START_VERSION;
Expand Down Expand Up @@ -102,7 +103,7 @@ public class GitCraftConfig {

public static List<String> yarnMissingVersions = List.of("1.16_combat-1", "1.16_combat-2", "1.16_combat-4", "1.16_combat-5", "1.16_combat-6");

public static List<String> yarnMissingReuploadedVersions = List.of("23w13a_or_b_original");
public static List<String> yarnMissingReuploadedVersions = List.of("23w13a_or_b_original", "24w14potato_original");

// Maps (version, [broken] build) -> [working] build or -1
public static Map<Tuple2<String, Integer>, Integer> yarnBrokenBuildOverride = Map.of(
Expand All @@ -128,14 +129,16 @@ public class GitCraftConfig {
);

// There are no releases for these parchment versions (yet)
public static List<String> parchmentMissingVersions = List.of("1.18", "1.19", "1.19.1", "1.20", "1.20.3");
public static List<String> parchmentMissingVersions = List.of("1.18", "1.19", "1.19.1", "1.20", "1.20.5");

// Version Override
public static Map<String, String> minecraftVersionSemVerOverride = Map.of(
// wrongly ordered 1.16 snapshots (pre gets mapped to rc for version 1.16, so there would be to rc1 versions)
"1.16-rc1", "1.16-rc.9",
// support extra original for 23w13a_or_b
"23w13a_or_b_original", "1.20-alpha.23.13.ab.original"
"23w13a_or_b_original", "1.20-alpha.23.13.ab.original",
// support extra original for 24w14potato...
"24w14potato_original", "1.20.5-alpha.24.12.potato.original"
// FIX until fabric-loader is updated
// END FIX
);
Expand Down Expand Up @@ -186,6 +189,9 @@ public void printConfigInformation() {
}
if (createVersionBranches) {
MiscHelper.println("A seperate branch will be created for each version.");
}
else if (createStableVersionBranches) {
MiscHelper.println("A seperate branch will be created for each stable version.");
}
if (sortJsonObjects) {
MiscHelper.println("JSON files (JSON objects) will be sorted in natural order.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public MinecraftLauncherManifest() throws IOException {
// Combat Test 7c
Artifact.fromURL("https://piston-data.mojang.com/experiments/combat/2557b99d95588505e988886220779087d7d6b1e9/1_16_combat-3.zip", "2557b99d95588505e988886220779087d7d6b1e9"),
// Combat Test 8 - From Minecraft Wiki
Artifact.fromURL("https://cdn.discordapp.com/attachments/369990015096455168/947864881028272198/1_16_combat-4.zip", "b4306b421183bd084b2831bd8d33a5db05ae9f9c"),
Artifact.fromURL("https://archive.org/download/1-16-combat-4/1_16_combat-4.zip", "b4306b421183bd084b2831bd8d33a5db05ae9f9c"),
// Combat Test 8b
Artifact.fromURL("https://piston-data.mojang.com/experiments/combat/9b2b984d635d373564b50803807225c75d7fd447/1_16_combat-5.zip", "9b2b984d635d373564b50803807225c75d7fd447"),
// Combat Test 8c
Expand All @@ -63,7 +63,9 @@ public MinecraftLauncherManifest() throws IOException {
// 1.19 Deep Dark Experimental Snapshot 1
Artifact.fromURL("https://piston-data.mojang.com/v1/objects/b1e589c1d6ed73519797214bc796e53f5429ac46/1_19_deep_dark_experimental_snapshot-1.zip", "b1e589c1d6ed73519797214bc796e53f5429ac46"),
// Before Reupload of 23w13a_or_b: 23w13a_or_b_original
Artifact.fromURL("https://maven.fabricmc.net/net/minecraft/23w13a_or_b_original.json", "469f0d1416f2b25a8829d7991c11be3411813bf1")
Artifact.fromURL("https://maven.fabricmc.net/net/minecraft/23w13a_or_b_original.json", "469f0d1416f2b25a8829d7991c11be3411813bf1"),
// Before Reupload of 24w14potato: 24w14potato_original
Artifact.fromURL("https://maven.fabricmc.net/net/minecraft/24w14potato_original.json", "4e54c25e6eafdf0a2f1f6e86fb1b8c1d239dd8d5")
}
);
}
Expand Down Expand Up @@ -257,6 +259,12 @@ public List<String> getParentVersion(OrderedVersion mcVersion) {
case "1.20-alpha.23.13.ab.original" -> {
return List.of("1.20-alpha.23.13.a");
}
case "1.20.5-alpha.24.12.potato" -> {
return List.of("1.20.5-alpha.24.12.potato.original", "1.20.5-alpha.24.12.a");
}
case "1.20.5-alpha.24.12.potato.original" -> {
return List.of("1.20.5-alpha.24.12.a");
}
default -> {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ protected static String mappingsIntermediaryPathQuirkVersion(String version) {
@Override
public Step.StepResult prepareMappings(OrderedVersion mcVersion) throws IOException {
Path mappingsFile = getMappingsPathInternal(mcVersion);
if (Files.exists(mappingsFile)) {
if (Files.exists(mappingsFile) && validateMappings(mappingsFile)) {
return Step.StepResult.UP_TO_DATE;
}
Files.deleteIfExists(mappingsFile);
Path mappingsV1 = getMappingsPathInternalV1(mcVersion);
Step.StepResult downloadResult = RemoteHelper.downloadToFileWithChecksumIfNotExistsNoRetryGitHub("FabricMC/intermediary", "master", String.format("mappings/%s.tiny", mappingsIntermediaryPathQuirkVersion(mcVersion.launcherFriendlyVersionName())), new RemoteHelper.LocalFileInfo(mappingsV1, null, "intermediary mapping", mcVersion.launcherFriendlyVersionName()));
MemoryMappingTree mappingTree = new MemoryMappingTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.github.winplay02.gitcraft.types.OrderedVersion;
import com.github.winplay02.gitcraft.util.MiscHelper;
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.tree.MemoryMappingTree;
import net.fabricmc.tinyremapper.IMappingProvider;
import net.fabricmc.tinyremapper.TinyUtils;

Expand Down Expand Up @@ -77,4 +79,13 @@ public final IMappingProvider getMappingsProvider(OrderedVersion mcVersion) {
}
return TinyUtils.createTinyMappingProvider(mappingsPath.get(), getSourceNS(), getDestinationNS());
}

protected static boolean validateMappings(Path mappingsTinyPath) {
try {
MappingReader.read(mappingsTinyPath, new MemoryMappingTree());
return true;
} catch (IOException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ public boolean doMappingsExist(OrderedVersion mcVersion) {
public Step.StepResult prepareMappings(OrderedVersion mcVersion) throws IOException {
Path mojmapPath = getMappingsPathInternal(mcVersion);
Path artifactTargetPath = GitCraftPaths.MC_VERSION_STORE.resolve(mcVersion.launcherFriendlyVersionName());
if (Files.exists(mojmapPath)) {
if (Files.exists(mojmapPath) && validateMappings(mojmapPath)) {
return Step.StepResult.UP_TO_DATE;
}
Files.deleteIfExists(mojmapPath);
Step.StepResult clientMappings = null;
Step.StepResult serverMappings = null;
if (mcVersion.hasClientMojMaps()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ public boolean doMappingsExist(OrderedVersion mcVersion) {
@Override
public Step.StepResult prepareMappings(OrderedVersion mcVersion) throws IOException {
Path mappingsPath = getMappingsPathInternal(mcVersion);
if (Files.exists(mappingsPath)) {
if (Files.exists(mappingsPath) && validateMappings(mappingsPath)) {
return Step.StepResult.UP_TO_DATE;
}
Files.deleteIfExists(mappingsPath);
String parchmentLatestReleaseVersionBuild = getLatestReleaseVersionParchmentBuild(mcVersion);
Path mappingsFileJson = GitCraftPaths.MAPPINGS.resolve(String.format("%s-parchment-%s-%s.json", mcVersion.launcherFriendlyVersionName(), mcVersion.launcherFriendlyVersionName(), parchmentLatestReleaseVersionBuild));
Step.StepResult downloadResult = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ public Step.StepResult prepareMappings(OrderedVersion mcVersion) throws IOExcept
Path mappingsFile = getMappingsPathInternal(mcVersion);
Path unpickDefinitionsFile = getUnpickDefinitionsPath(mcVersion);
// Try existing
if (Files.exists(mappingsFile)) {
if (Files.exists(mappingsFile) && validateMappings(mappingsFile)) {
return Step.StepResult.UP_TO_DATE;
}
Files.deleteIfExists(mappingsFile);
// Get latest build info
FabricYarnVersionMeta yarnVersion = getYarnLatestBuild(mcVersion);
if (yarnVersion == null) {
Expand All @@ -114,11 +115,11 @@ public Step.StepResult prepareMappings(OrderedVersion mcVersion) throws IOExcept
try (FileSystem fs = FileSystems.newFileSystem(mappingsFileJar)) {
Path mappingsPathInJar = fs.getPath("mappings", "mappings.tiny");
Path unpickDefinitions = fs.getPath("extras", "definitions.unpick");
Files.copy(mappingsPathInJar, mappingsFile, StandardCopyOption.REPLACE_EXISTING);
if (Files.exists(unpickDefinitions) && unpickDefinitionsFile != null) {
Files.copy(unpickDefinitions, unpickDefinitionsFile, StandardCopyOption.REPLACE_EXISTING);
fetchUnpickArtifacts(mcVersion); // ignore result for now
}
Files.copy(mappingsPathInJar, mappingsFile, StandardCopyOption.REPLACE_EXISTING);
}
return Step.StepResult.merge(result, Step.StepResult.SUCCESS);
} catch (IOException | RuntimeException ignored) {
Expand Down Expand Up @@ -224,7 +225,7 @@ private static boolean isYarnBrokenVersion(OrderedVersion mcVersion) {
private static Tuple2<Path, Step.StepResult> mappingsPathYarnUnmerged(OrderedVersion mcVersion, FabricYarnVersionMeta yarnVersion) {
try {
Path mappingsFileUnmerged = GitCraftPaths.MAPPINGS.resolve(String.format("%s-yarn-unmerged-build.%s.tiny", mcVersion.launcherFriendlyVersionName(), yarnVersion.build()));
if (Files.exists(mappingsFileUnmerged)) {
if (Files.exists(mappingsFileUnmerged) && validateMappings(mappingsFileUnmerged)) {
return Tuple2.tuple(mappingsFileUnmerged, Step.StepResult.UP_TO_DATE);
}
Path mappingsFileUnmergedJar = GitCraftPaths.MAPPINGS.resolve(String.format("%s-yarn-unmerged-build.%s.jar", mcVersion.launcherFriendlyVersionName(), yarnVersion.build()));
Expand All @@ -238,7 +239,7 @@ private static Tuple2<Path, Step.StepResult> mappingsPathYarnUnmerged(OrderedVer
MiscHelper.println("Yarn mappings in tiny-v2 format do not exist for %s, falling back to tiny-v1 mappings...", mcVersion.launcherFriendlyVersionName());
try {
Path mappingsFileUnmergedv1 = GitCraftPaths.MAPPINGS.resolve(String.format("%s-yarn-unmerged-build.%s-v1.tiny", mcVersion.launcherFriendlyVersionName(), yarnVersion.build()));
if (Files.exists(mappingsFileUnmergedv1)) {
if (Files.exists(mappingsFileUnmergedv1) && validateMappings(mappingsFileUnmergedv1)) {
return Tuple2.tuple(mappingsFileUnmergedv1, Step.StepResult.UP_TO_DATE);
}
Path mappingsFileUnmergedJarv1 = GitCraftPaths.MAPPINGS.resolve(String.format("%s-yarn-unmerged-build.%s-v1.jar", mcVersion.launcherFriendlyVersionName(), yarnVersion.build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public StepResult run(PipelineCache pipelineCache, OrderedVersion mcVersion, Map
MiscHelper.println("Created branch for linear version %s", mcVersion.launcherFriendlyVersionName());
}

// Create branch for stable linear version
if (GitCraft.config.createStableVersionBranches && !GitCraft.config.createVersionBranches && !mcVersion.isSnapshotOrPending()) {
MiscHelper.executeTimedStep("Creating branch for stable linear version...", () -> createBranchFromCurrentCommit(mcVersion, repo));
MiscHelper.println("Created branch for stable linear version %s", mcVersion.launcherFriendlyVersionName());
}

return StepResult.SUCCESS;
}

Expand Down

0 comments on commit 589aab1

Please sign in to comment.