Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to mapping-io (Glitch's Version) #432

Merged
merged 10 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
# needs: build
runs-on: ubuntu-22.04
container:
image: eclipse-temurin:17
image: eclipse-temurin:21
options: --user root
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
runs-on: ubuntu-22.04
container:
image: eclipse-temurin:17
image: eclipse-temurin:21
options: --user root
steps:
- uses: actions/checkout@v3
Expand Down
47 changes: 15 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.slf4j.LoggerFactory
buildscript {
dependencies {
classpath "org.kohsuke:github-api:${project.github_api}"
classpath "com.guardsquare:proguard-gradle:${project.proguard_gradle}"
}
}

Expand All @@ -14,7 +13,7 @@ plugins {
id 'eclipse'
id 'maven-publish'
id 'org.quiltmc.gradle.licenser' version '2.0.1'
id 'org.quiltmc.loom' version '1.3.3' apply false
id 'org.quiltmc.loom' version '1.6.7' apply false
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

Expand Down Expand Up @@ -129,10 +128,7 @@ processResources {

filesMatching(["quilt_installer.json", "fabric-installer.launchwrapper.json"]) {
expand(
"tiny_mappings_parser": project.tiny_mappings_parser,
"sponge_mixin": project.sponge_mixin,
"tiny_remapper": project.tiny_remapper,
"access_widener": project.access_widener,
"quilt_json5": project.quilt_json5,
"asm": project.asm,
"asm_analysis": project.asm,
Expand Down Expand Up @@ -180,6 +176,9 @@ task getSat4jAbout(type: Copy) {
into layout.buildDirectory.dir("sat4j")
}

File outputFile = file("build/libs/quilt-loader-${version}.jar")
evaluationDependsOnChildren()

task fatJar(type: ShadowJar, dependsOn: getSat4jAbout) {
from sourceSets.main.output
from project(":minecraft").sourceSets.main.output
Expand All @@ -196,17 +195,23 @@ task fatJar(type: ShadowJar, dependsOn: getSat4jAbout) {
)
}

archiveClassifier = "fat"
archiveClassifier = ""
configurations = [project.configurations.include]

relocate 'org.quiltmc.loader.util.sat4j', 'org.quiltmc.loader.impl.lib.sat4j'
relocate 'org.quiltmc.parsers', 'org.quiltmc.loader.impl.lib.parsers'
relocate 'com.electronwill', 'org.quiltmc.loader.impl.lib.electronwill'
relocate 'com.unascribed.flexver', 'org.quiltmc.loader.impl.lib.flexver'
//relocate 'org.quiltmc.json5', 'org.quiltmc.loader.impl.lib.json5'
relocate 'net.fabricmc.mappingio', 'org.quiltmc.loader.impl.lib.mappingio'
relocate 'net.fabricmc.tinyremapper', 'org.quiltmc.loader.impl.lib.tinyremapper'
relocate 'net.fabricmc.accesswidener', 'org.quiltmc.loader.impl.lib.accesswidener'

minimize()

exclude 'about.html'
exclude 'sat4j.version'
exclude 'META-INF/maven/org.ow2.sat4j/*/**'
exclude 'META-INF/FABRIC1.*'

doLast {
JarNester.nestJars(project.configurations.development.files, archiveFile.get().asFile, LoggerFactory.getLogger("JiJ"))
Expand All @@ -215,29 +220,7 @@ task fatJar(type: ShadowJar, dependsOn: getSat4jAbout) {
outputs.upToDateWhen { false }
}

File proguardFile = file("build/libs/quilt-loader-${version}.jar")

import proguard.gradle.ProGuardTask
task proguardJar(type: ProGuardTask, dependsOn: fatJar) {
def classpath = project(":minecraft").configurations.compileClasspath

inputs.files(fatJar, classpath)
outputs.files(proguardFile)
outputs.upToDateWhen { false }

doFirst {
classpath.resolve().forEach {
libraryjars it
}
}

libraryjars JavaVersion.current().java9Compatible ? "${System.getProperty('java.home')}/jmods" : "${System.getProperty('java.home')}/lib/rt.jar"

injars fatJar.archiveFile
outjars proguardFile
configuration file("proguard.conf")
}
build.dependsOn proguardJar
build.dependsOn("fatJar")

jar {
enabled = false
Expand Down Expand Up @@ -334,8 +317,8 @@ allprojects {
[configurations.runtimeElements, configurations.apiElements].each { configuration ->
configuration.outgoing.artifacts.clear()
artifacts {
add(configuration.name, proguardFile) {
builtBy proguardJar
add(configuration.name, outputFile) {
builtBy fatJar
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ dependencies {
exclude module: 'launchwrapper'
exclude module: 'guava'
}
published "net.fabricmc:tiny-mappings-parser:${project.tiny_mappings_parser}"
published "net.fabricmc:tiny-remapper:${project.tiny_remapper}"
published "net.fabricmc:access-widener:${project.access_widener}"

/*include*/ published "org.quiltmc:quilt-json5:${project.quilt_json5}"
published "org.quiltmc:quilt-config:${project.quilt_config}"
Expand All @@ -78,6 +75,13 @@ dependencies {

include "org.quiltmc.parsers:json:${project.quilt_parsers}"
include "com.unascribed:flexver-java:${project.flexver}"

include "net.fabricmc:tiny-remapper:${project.tiny_remapper}"
include "net.fabricmc:access-widener:${project.access_widener}"
include ("net.fabricmc:mapping-io:${project.mapping_io}") {
// dont include asm
transitive = false
}
}

publishing {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ quilt_loader = 0.26.0-beta.2
asm = 9.6
sponge_mixin = 0.13.3+mixin.0.8.5
tiny_mappings_parser = 0.3.0+build.17
tiny_remapper = 0.10.1
tiny_remapper = 0.10.3
access_widener = 2.1.0
mapping_io = 0.6.1
quilt_json5 = 1.0.4+final
quilt_parsers = 0.2.0
quilt_loader_sat4j = 2.3.5.1
Expand All @@ -24,7 +25,6 @@ quilt_chasm = 0.1.0-20230126.045734-27
night_config = 3.6.6
annotations = 24.0.1
junit_bom = 5.9.3
proguard_gradle = 7.4.2
github_api = 1.315
flexver = 1.1.0
mixin_extras = 0.3.5
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 0 additions & 5 deletions minecraft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ dependencies {
compileOnly 'org.apache.logging.log4j:log4j-api:2.8.1'
// slf4j wrapper
compileOnly 'org.slf4j:slf4j-api:1.8.0-beta4'
// HACK: work around proguard only seeing dependencies on the minecraft compile classpath
compileOnly "org.quiltmc.chasm:chassembly:${project.quilt_chasm}"
compileOnly "org.quiltmc.chasm:chasm:${project.quilt_chasm}"
// compileOnly 'org.quiltmc:quilt-json5:1.0.1'
// testCompileOnly 'org.quiltmc:quilt-json5:1.0.1'
// launchwrapper + dependencies
compileOnly ('net.minecraft:launchwrapper:1.12') {
transitive = false
Expand Down
4 changes: 2 additions & 2 deletions minecraft/minecraft-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ repositories {

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
minecraft "com.mojang:minecraft:1.20.2"
mappings "org.quiltmc:quilt-mappings:1.20.2+build.1:intermediary-v2"
minecraft "com.mojang:minecraft:1.20.6"
mappings "org.quiltmc:quilt-mappings:1.20.6+build.6:intermediary-v2"

implementation project(":minecraft")
implementation project(":dependencies")
Expand Down
61 changes: 61 additions & 0 deletions minecraft/minecraft-test/src/test/java/MappingResolverTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2016 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.quiltmc.loader.api.MappingResolver;
import org.quiltmc.loader.api.QuiltLoader;


public class MappingResolverTest {
final MappingResolver mappingResolver = QuiltLoader.getMappingResolver();

@Test
void getNamespaces() {
assertIterableEquals(List.of( "official", "intermediary", "named"), mappingResolver.getNamespaces());
}

@Test
void getCurrentRuntimeNamespace() {
assertEquals("named", mappingResolver.getCurrentRuntimeNamespace());
}

@Test
void mapClassName() {
assertEquals("net.minecraft.client.MinecraftClient", mappingResolver.mapClassName("intermediary", "net.minecraft.class_310"));
assertEquals("net.minecraft.client.MinecraftClient$ChatRestriction", mappingResolver.mapClassName("intermediary", "net.minecraft.class_310$class_5859"));
assertEquals("net.minecraft.Unknown", mappingResolver.mapClassName("intermediary", "net.minecraft.Unknown"));
}

@Test
void unmapClassName() {
assertEquals("net.minecraft.class_6327", mappingResolver.unmapClassName("intermediary", "net.minecraft.server.command.DebugPathCommand"));
}

@Test
void mapFieldName() {
assertEquals("world", mappingResolver.mapFieldName("intermediary", "net.minecraft.class_2586", "field_11863", "Lnet/minecraft/class_1937;"));
}

@Test
void mapMethodName() {
assertEquals("getWorld", mappingResolver.mapMethodName("intermediary", "net.minecraft.class_2586", "method_10997", "()Lnet/minecraft/class_1937;"));
}
}
10 changes: 0 additions & 10 deletions proguard.conf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

@Deprecated
public interface FabricLauncher {
MappingConfiguration getMappingConfiguration();

void addToClassPath(Path path, String... allowedPrefixes);
void setAllowedPrefixes(Path path, String... prefixes);
// void setValidParentClassPath(Collection<Path> paths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public static Class<?> getClass(String className) throws ClassNotFoundException
return Class.forName(className, true, getLauncher().getTargetClassLoader());
}

@Override
public MappingConfiguration getMappingConfiguration() {
return mappingConfiguration;
}

@Override
public void addToClassPath(Path path, String... allowedPrefixes) {
delegate.addToClassPath(path, allowedPrefixes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package net.fabricmc.loader.impl.launch;

import net.fabricmc.mapping.tree.TinyTree;

@Deprecated
public final class MappingConfiguration {
private final org.quiltmc.loader.impl.launch.common.MappingConfiguration delegate;
Expand All @@ -38,9 +36,6 @@ public boolean matches(String gameId, String gameVersion) {
return delegate.matches(gameId, gameVersion);
}

public TinyTree getMappings() {
return delegate.getMappings();
}

public String getTargetNamespace() {
return delegate.getTargetNamespace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
@Deprecated
public interface FabricLauncher {
MappingConfiguration getMappingConfiguration();
void propose(URL url);
EnvType getEnvironmentType();
boolean isClassLoaded(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ public static FabricLauncher getLauncher() {
return new FabricLauncherBase();
}

@Override
public MappingConfiguration getMappingConfiguration() {
return new MappingConfiguration();
}

@Override
public void propose(URL url) {
parent.addToClassPath(UrlUtil.asPath(url));
Expand Down

This file was deleted.

Loading
Loading