only publish on pushes to the main branch + clean up a bit
All checks were successful
Publish to snapshot maven / build (push) Successful in 14s
All checks were successful
Publish to snapshot maven / build (push) Successful in 14s
This commit is contained in:
parent
9728a83d3e
commit
a0a5f6cf2f
|
@ -1,6 +1,9 @@
|
||||||
name: Publish to snapshot maven
|
name: Publish to snapshot maven
|
||||||
|
|
||||||
on: push
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.ecorous.esnesnon.nonsense_remapper;
|
package org.ecorous.esnesnon.nonsense_remapper;
|
||||||
|
|
||||||
import java.io.IOError;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
@ -13,7 +12,6 @@ import java.util.concurrent.Executors;
|
||||||
import org.ecorous.esnesnon.nonsense_remapper.api.Mapper;
|
import org.ecorous.esnesnon.nonsense_remapper.api.Mapper;
|
||||||
import org.ecorous.esnesnon.nonsense_remapper.api.ParameterClassRemapper;
|
import org.ecorous.esnesnon.nonsense_remapper.api.ParameterClassRemapper;
|
||||||
import org.ecorous.esnesnon.nonsense_remapper.api.data.MappingData;
|
import org.ecorous.esnesnon.nonsense_remapper.api.data.MappingData;
|
||||||
import org.ecorous.esnesnon.nonsense_remapper.api.data.Member;
|
|
||||||
import org.ecorous.esnesnon.nonsense_remapper.api.data.Parchment;
|
import org.ecorous.esnesnon.nonsense_remapper.api.data.Parchment;
|
||||||
import org.ecorous.esnesnon.nonsense_remapper.parser.ProguardParser;
|
import org.ecorous.esnesnon.nonsense_remapper.parser.ProguardParser;
|
||||||
import org.ecorous.esnesnon.nonsense_remapper.provider.MojmapProvider;
|
import org.ecorous.esnesnon.nonsense_remapper.provider.MojmapProvider;
|
||||||
|
@ -27,7 +25,8 @@ import org.objectweb.asm.commons.ClassRemapper;
|
||||||
public class NonsenseRemapper {
|
public class NonsenseRemapper {
|
||||||
|
|
||||||
public static void run(String minecraftVersion, Path inputJar, Path outputJar, boolean skipMetaInf, boolean renameParameters) throws IOException, InterruptedException {
|
public static void run(String minecraftVersion, Path inputJar, Path outputJar, boolean skipMetaInf, boolean renameParameters) throws IOException, InterruptedException {
|
||||||
MappingData data = ProguardParser.read(MojmapProvider.get(minecraftVersion, outputJar.resolveSibling("client-" + minecraftVersion + ".txt")).orElseThrow()).reverse();
|
MappingData data = ProguardParser.read(MojmapProvider.get(minecraftVersion,
|
||||||
|
outputJar.resolveSibling("client-" + minecraftVersion + ".txt")).orElseThrow()).reverse();
|
||||||
|
|
||||||
Parchment paramMappings = null;
|
Parchment paramMappings = null;
|
||||||
if (renameParameters) {
|
if (renameParameters) {
|
||||||
|
@ -50,35 +49,20 @@ public class NonsenseRemapper {
|
||||||
List<Callable<Void>> tasks = new ArrayList<>();
|
List<Callable<Void>> tasks = new ArrayList<>();
|
||||||
|
|
||||||
Map<String, List<String>> lazyParents = new ConcurrentHashMap<>();
|
Map<String, List<String>> lazyParents = new ConcurrentHashMap<>();
|
||||||
Mapper mapper = new Mapper(data, className -> lazyParents.computeIfAbsent(className, ignored -> {
|
Mapper mapper = new Mapper(data, className -> lazyParents.computeIfAbsent(className, ignored ->
|
||||||
try {
|
NonsenseRemapper.computeInheritances(className, inFs)));
|
||||||
Path path = inFs.getPath("/" + className + ".class");
|
|
||||||
if (!Files.isRegularFile(path))
|
|
||||||
return List.of();
|
|
||||||
|
|
||||||
byte[] bytes = Files.readAllBytes(path);
|
|
||||||
ClassReader reader = new ClassReader(bytes);
|
|
||||||
List<String> superTypes = new ArrayList<>();
|
|
||||||
reader.accept(new ClassVisitor(Opcodes.ASM9) {
|
|
||||||
@Override
|
|
||||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
|
||||||
superTypes.add(superName);
|
|
||||||
superTypes.addAll(Arrays.asList(interfaces));
|
|
||||||
}
|
|
||||||
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
|
||||||
|
|
||||||
return superTypes;
|
|
||||||
} catch (IOException error) {
|
|
||||||
throw new Error(error); // not our problem :^) for now
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
Files.walkFileTree(inFs.getPath("/"), new SimpleFileVisitor<>() {
|
Files.walkFileTree(inFs.getPath("/"), new SimpleFileVisitor<>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes) {
|
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
|
||||||
if (skipMetaInf && path.startsWith("/META-INF"))
|
if (skipMetaInf && dir.startsWith("/META-INF")) {
|
||||||
return FileVisitResult.SKIP_SUBTREE;
|
return FileVisitResult.SKIP_SUBTREE;
|
||||||
|
}
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes) {
|
||||||
tasks.add(() -> {
|
tasks.add(() -> {
|
||||||
try {
|
try {
|
||||||
if (path.getFileName().toString().endsWith(".class")) {
|
if (path.getFileName().toString().endsWith(".class")) {
|
||||||
|
@ -149,4 +133,27 @@ public class NonsenseRemapper {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<String> computeInheritances(String className, FileSystem inFs){
|
||||||
|
try {
|
||||||
|
Path path = inFs.getPath("/" + className + ".class");
|
||||||
|
if (!Files.isRegularFile(path))
|
||||||
|
return List.of();
|
||||||
|
|
||||||
|
byte[] bytes = Files.readAllBytes(path);
|
||||||
|
ClassReader reader = new ClassReader(bytes);
|
||||||
|
List<String> superTypes = new ArrayList<>();
|
||||||
|
reader.accept(new ClassVisitor(Opcodes.ASM9) {
|
||||||
|
@Override
|
||||||
|
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||||
|
superTypes.add(superName);
|
||||||
|
superTypes.addAll(Arrays.asList(interfaces));
|
||||||
|
}
|
||||||
|
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||||
|
|
||||||
|
return superTypes;
|
||||||
|
} catch (IOException error) {
|
||||||
|
throw new Error(error); // not our problem :^) for now
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class ParchmentProvider {
|
||||||
parchment = new Gson().fromJson(mappings, Parchment.class);
|
parchment = new Gson().fromJson(mappings, Parchment.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.printf("Finished loading in (%.2fs)\n", (System.currentTimeMillis() - time) / 1000F);
|
System.out.printf("Finished loading (%.2fs)\n", (System.currentTimeMillis() - time) / 1000F);
|
||||||
return parchment;
|
return parchment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue