Clean up code to transfer to QuiltMC
parent
67c4d738d0
commit
e21ba90d9f
|
@ -22,7 +22,7 @@ Currently, 1.17.1+ is only has support, with no plans of backporting to earlier
|
|||
```groovy
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven { url = "https://maven.oroarmor.com" }
|
||||
maven { url = "https://maven.quiltmc.org/repository/release" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -30,14 +30,14 @@ pluginManagement {
|
|||
```groovy
|
||||
plugins {
|
||||
// ...
|
||||
id "quilt-mappings-on-loom" version "2.0.0"
|
||||
id "quilt-mappings-on-loom" version "3.0.0"
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
dependencies {
|
||||
mappings(loom.layered {
|
||||
addLayer(quiltmappings.mappings("org.quiltmc:quilt-mappings:${minecraft_version}+build.${project.quilt_mappings}:v2", true))
|
||||
addLayer(quiltmappings.mappings("org.quiltmc:quilt-mappings:${minecraft_version}+build.${project.quilt_mappings}:v2"))
|
||||
})
|
||||
}
|
||||
```
|
||||
|
|
|
@ -4,8 +4,8 @@ plugins {
|
|||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "com.oroarmor"
|
||||
version = "2.0.0"
|
||||
group = "org.quiltmc"
|
||||
version = "3.0.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -19,14 +19,13 @@ dependencies {
|
|||
implementation("net.fabricmc:mapping-io:0.2.1")
|
||||
implementation("net.fabricmc:lorenz-tiny:4.0.2")
|
||||
implementation("net.fabricmc:tiny-mappings-parser:0.2.2.14")
|
||||
implementation("net.fabricmc:stitch:0.6.1")
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("quiltMappingsLoom") {
|
||||
id = "quilt-mappings-on-loom"
|
||||
implementationClass = "com.oroarmor.quiltmappings.loom.QuiltMappingsOnLoomPlugin"
|
||||
implementationClass = "org.quiltmc.quiltmappings.loom.QuiltMappingsOnLoomPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +46,7 @@ publishing {
|
|||
username = System.getenv("MAVEN_USERNAME")
|
||||
password = System.getenv("MAVEN_PASSWORD")
|
||||
}
|
||||
name = "OroArmorMaven"
|
||||
name = "Maven"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package com.oroarmor.quiltmappings.loom;
|
||||
package org.quiltmc.quiltmappings.loom;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
|
@ -21,9 +18,6 @@ import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
|||
import net.fabricmc.loom.api.mappings.layered.spec.MappingsSpec;
|
||||
import net.fabricmc.mappingio.MappingVisitor;
|
||||
import net.fabricmc.mappingio.MappingWriter;
|
||||
import net.fabricmc.mappingio.adapter.MappingDstNsReorder;
|
||||
import net.fabricmc.mappingio.adapter.MappingNsRenamer;
|
||||
import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch;
|
||||
import net.fabricmc.mappingio.format.MappingFormat;
|
||||
import net.fabricmc.mappingio.format.Tiny2Reader;
|
||||
import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
||||
|
@ -32,7 +26,7 @@ import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
|||
public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project target) {
|
||||
target.getExtensions().create("quiltmappings", QuiltMappingsOnLoomExtension.class, target);
|
||||
target.getExtensions().create("quiltMappings", QuiltMappingsOnLoomExtension.class);
|
||||
|
||||
target.getRepositories().maven(repo -> {
|
||||
repo.setName("Quilt Releases");
|
||||
|
@ -52,48 +46,54 @@ public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
|||
this.project = project;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public MappingsSpec<?> mappings(String quiltMappings, boolean snapshot) {
|
||||
return new MappingsSpec<>() {
|
||||
@Override
|
||||
public MappingLayer createLayer(MappingContext context) {
|
||||
return new QuiltMappingsLayer(context, project, quiltMappings, snapshot);
|
||||
}
|
||||
return mappings(quiltMappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(quiltMappings, snapshot);
|
||||
}
|
||||
};
|
||||
public MappingsSpec<?> mappings(String quiltMappings) {
|
||||
return new MappingLayerMappingsSpec(project, quiltMappings);
|
||||
}
|
||||
|
||||
private record MappingLayerMappingsSpec(Project project, String quiltMappings)
|
||||
implements MappingsSpec<MappingLayer> {
|
||||
@Override
|
||||
public MappingLayer createLayer(MappingContext context) {
|
||||
return new QuiltMappingsLayer(context, project, quiltMappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(quiltMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record QuiltMappingsLayer(MappingContext context, Project project, String quiltMappings,
|
||||
boolean snapshot) implements MappingLayer {
|
||||
|
||||
private record QuiltMappingsLayer(MappingContext context, Project project, String quiltMappings)
|
||||
implements MappingLayer {
|
||||
@Override
|
||||
public void visit(MappingVisitor mappingVisitor) throws IOException {
|
||||
String minecraftVersion = context.minecraftProvider().minecraftVersion();
|
||||
|
||||
File intermediaryToQm = project.file(".gradle/qm/qm_to_intermediary_" + quiltMappings.split(':')[2] + ".tiny");
|
||||
String quiltMappingsBuild = "+build" + quiltMappings.substring(quiltMappings.lastIndexOf("."), quiltMappings.lastIndexOf(":"));
|
||||
File intermediaryToQm = project.file(".gradle/qm/qm_to_intermediary_" + minecraftVersion + quiltMappingsBuild + ".tiny");
|
||||
|
||||
if (!intermediaryToQm.exists()) {
|
||||
Set<File> quiltmappings = project.getConfigurations().detachedConfiguration(project.getDependencies().create(quiltMappings)).resolve();
|
||||
Set<File> hashedFiles = project.getConfigurations().detachedConfiguration(project.getDependencies().create("org.quiltmc:hashed:" + minecraftVersion + (snapshot ? "-SNAPSHOT" : ""))).resolve();
|
||||
List<File> quiltMappings = new ArrayList<>(project.getConfigurations().detachedConfiguration(project.getDependencies().create(this.quiltMappings)).resolve());
|
||||
|
||||
File hashedFile = project.file(".gradle/qm/hashed_" + minecraftVersion + ".tiny");
|
||||
downloadFile(hashedFiles, hashedFile);
|
||||
File hashedFile = project.file(".gradle/qm/hashed_" + minecraftVersion + quiltMappingsBuild + ".tiny");
|
||||
downloadFile(quiltMappings.get(1), hashedFile);
|
||||
|
||||
File quiltMappingsFile = project.file(".gradle/qm/qm_" + minecraftVersion + ".tiny");
|
||||
downloadFile(quiltmappings, quiltMappingsFile);
|
||||
File quiltMappingsFile = project.file(".gradle/qm/qm_" + minecraftVersion + quiltMappingsBuild + ".tiny");
|
||||
downloadFile(quiltMappings.get(0), quiltMappingsFile);
|
||||
|
||||
MemoryMappingTree mappings = new MemoryMappingTree();
|
||||
MappingSourceNsSwitch sourceNsSwitch = new MappingSourceNsSwitch(mappings, MappingsNamespace.OFFICIAL.toString());
|
||||
|
||||
MemoryMappingTree hashed = new MemoryMappingTree();
|
||||
try (FileReader reader = new FileReader(hashedFile)) {
|
||||
Tiny2Reader.read(reader, hashed);
|
||||
}
|
||||
hashed.accept(sourceNsSwitch);
|
||||
hashed.accept(mappings);
|
||||
|
||||
try (FileReader reader = new FileReader(quiltMappingsFile)) {
|
||||
Tiny2Reader.read(reader, mappings);
|
||||
|
@ -107,10 +107,10 @@ public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
|||
Tiny2Reader.read(new FileReader(intermediaryToQm), mappingVisitor);
|
||||
}
|
||||
|
||||
private void downloadFile(Set<File> dependency, File output) {
|
||||
private void downloadFile(File dependency, File output) {
|
||||
if (!output.exists()) {
|
||||
GFileUtils.copyFile(project
|
||||
.zipTree(dependency.stream().iterator().next())
|
||||
.zipTree(dependency)
|
||||
.getFiles()
|
||||
.stream()
|
||||
.filter(file -> file.getName().endsWith("mappings.tiny"))
|
||||
|
@ -123,10 +123,5 @@ public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
|||
public MappingsNamespace getSourceNamespace() {
|
||||
return MappingsNamespace.OFFICIAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return quiltMappings.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
plugins {
|
||||
java
|
||||
id("fabric-loom") version "0.10-SNAPSHOT"
|
||||
id("quilt-mappings-on-loom") version "1.0.0"
|
||||
id("quilt-mappings-on-loom") version "3.0.0"
|
||||
}
|
||||
|
||||
group = "com.oroarmor"
|
||||
group = "org.quiltmc"
|
||||
version = "1.0.0"
|
||||
|
||||
repositories {
|
||||
|
@ -14,14 +14,14 @@ repositories {
|
|||
}
|
||||
}
|
||||
|
||||
var minecraft_version = "21w42a"
|
||||
var quilt_mappings = "21w42a+build.1"
|
||||
var minecraft_version = "1.18-pre2"
|
||||
var quilt_mappings = "1.18-pre2+build.3"
|
||||
var loader_version = "0.12.2"
|
||||
|
||||
dependencies {
|
||||
minecraft("com.mojang:minecraft:${minecraft_version}")
|
||||
mappings(loom.layered {
|
||||
addLayer(quiltmappings.mappings("org.quiltmc:quilt-mappings:${quilt_mappings}:v2", true))
|
||||
addLayer(quiltMappings.mappings("org.quiltmc:quilt-mappings:${quilt_mappings}:v2"))
|
||||
})
|
||||
modImplementation("net.fabricmc:fabric-loader:${loader_version}")
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ pluginManagement {
|
|||
maven {
|
||||
url = uri("https://maven.fabricmc.net/")
|
||||
}
|
||||
maven { url = uri("https://maven.oroarmor.com") }
|
||||
maven { url = uri("https://maven.quiltmc.org/repository/release") }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue