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
|
```groovy
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = "https://maven.oroarmor.com" }
|
maven { url = "https://maven.quiltmc.org/repository/release" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -30,14 +30,14 @@ pluginManagement {
|
||||||
```groovy
|
```groovy
|
||||||
plugins {
|
plugins {
|
||||||
// ...
|
// ...
|
||||||
id "quilt-mappings-on-loom" version "2.0.0"
|
id "quilt-mappings-on-loom" version "3.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
mappings(loom.layered {
|
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`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.oroarmor"
|
group = "org.quiltmc"
|
||||||
version = "2.0.0"
|
version = "3.0.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -19,14 +19,13 @@ dependencies {
|
||||||
implementation("net.fabricmc:mapping-io:0.2.1")
|
implementation("net.fabricmc:mapping-io:0.2.1")
|
||||||
implementation("net.fabricmc:lorenz-tiny:4.0.2")
|
implementation("net.fabricmc:lorenz-tiny:4.0.2")
|
||||||
implementation("net.fabricmc:tiny-mappings-parser:0.2.2.14")
|
implementation("net.fabricmc:tiny-mappings-parser:0.2.2.14")
|
||||||
implementation("net.fabricmc:stitch:0.6.1")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
plugins {
|
||||||
create("quiltMappingsLoom") {
|
create("quiltMappingsLoom") {
|
||||||
id = "quilt-mappings-on-loom"
|
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")
|
username = System.getenv("MAVEN_USERNAME")
|
||||||
password = System.getenv("MAVEN_PASSWORD")
|
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.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.util.ArrayList;
|
||||||
import java.nio.file.Files;
|
import java.util.List;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.gradle.api.Plugin;
|
import org.gradle.api.Plugin;
|
||||||
import org.gradle.api.Project;
|
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.loom.api.mappings.layered.spec.MappingsSpec;
|
||||||
import net.fabricmc.mappingio.MappingVisitor;
|
import net.fabricmc.mappingio.MappingVisitor;
|
||||||
import net.fabricmc.mappingio.MappingWriter;
|
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.MappingFormat;
|
||||||
import net.fabricmc.mappingio.format.Tiny2Reader;
|
import net.fabricmc.mappingio.format.Tiny2Reader;
|
||||||
import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
||||||
|
@ -32,7 +26,7 @@ import net.fabricmc.mappingio.tree.MemoryMappingTree;
|
||||||
public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
||||||
@Override
|
@Override
|
||||||
public void apply(Project target) {
|
public void apply(Project target) {
|
||||||
target.getExtensions().create("quiltmappings", QuiltMappingsOnLoomExtension.class, target);
|
target.getExtensions().create("quiltMappings", QuiltMappingsOnLoomExtension.class);
|
||||||
|
|
||||||
target.getRepositories().maven(repo -> {
|
target.getRepositories().maven(repo -> {
|
||||||
repo.setName("Quilt Releases");
|
repo.setName("Quilt Releases");
|
||||||
|
@ -52,48 +46,54 @@ public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public MappingsSpec<?> mappings(String quiltMappings, boolean snapshot) {
|
public MappingsSpec<?> mappings(String quiltMappings, boolean snapshot) {
|
||||||
return new MappingsSpec<>() {
|
return mappings(quiltMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MappingsSpec<?> mappings(String quiltMappings) {
|
||||||
|
return new MappingLayerMappingsSpec(project, quiltMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private record MappingLayerMappingsSpec(Project project, String quiltMappings)
|
||||||
|
implements MappingsSpec<MappingLayer> {
|
||||||
@Override
|
@Override
|
||||||
public MappingLayer createLayer(MappingContext context) {
|
public MappingLayer createLayer(MappingContext context) {
|
||||||
return new QuiltMappingsLayer(context, project, quiltMappings, snapshot);
|
return new QuiltMappingsLayer(context, project, quiltMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(quiltMappings, snapshot);
|
return Objects.hash(quiltMappings);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record QuiltMappingsLayer(MappingContext context, Project project, String quiltMappings,
|
private record QuiltMappingsLayer(MappingContext context, Project project, String quiltMappings)
|
||||||
boolean snapshot) implements MappingLayer {
|
implements MappingLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(MappingVisitor mappingVisitor) throws IOException {
|
public void visit(MappingVisitor mappingVisitor) throws IOException {
|
||||||
String minecraftVersion = context.minecraftProvider().minecraftVersion();
|
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()) {
|
if (!intermediaryToQm.exists()) {
|
||||||
Set<File> quiltmappings = project.getConfigurations().detachedConfiguration(project.getDependencies().create(quiltMappings)).resolve();
|
List<File> quiltMappings = new ArrayList<>(project.getConfigurations().detachedConfiguration(project.getDependencies().create(this.quiltMappings)).resolve());
|
||||||
Set<File> hashedFiles = project.getConfigurations().detachedConfiguration(project.getDependencies().create("org.quiltmc:hashed:" + minecraftVersion + (snapshot ? "-SNAPSHOT" : ""))).resolve();
|
|
||||||
|
|
||||||
File hashedFile = project.file(".gradle/qm/hashed_" + minecraftVersion + ".tiny");
|
File hashedFile = project.file(".gradle/qm/hashed_" + minecraftVersion + quiltMappingsBuild + ".tiny");
|
||||||
downloadFile(hashedFiles, hashedFile);
|
downloadFile(quiltMappings.get(1), hashedFile);
|
||||||
|
|
||||||
File quiltMappingsFile = project.file(".gradle/qm/qm_" + minecraftVersion + ".tiny");
|
File quiltMappingsFile = project.file(".gradle/qm/qm_" + minecraftVersion + quiltMappingsBuild + ".tiny");
|
||||||
downloadFile(quiltmappings, quiltMappingsFile);
|
downloadFile(quiltMappings.get(0), quiltMappingsFile);
|
||||||
|
|
||||||
MemoryMappingTree mappings = new MemoryMappingTree();
|
MemoryMappingTree mappings = new MemoryMappingTree();
|
||||||
MappingSourceNsSwitch sourceNsSwitch = new MappingSourceNsSwitch(mappings, MappingsNamespace.OFFICIAL.toString());
|
|
||||||
|
|
||||||
MemoryMappingTree hashed = new MemoryMappingTree();
|
MemoryMappingTree hashed = new MemoryMappingTree();
|
||||||
try (FileReader reader = new FileReader(hashedFile)) {
|
try (FileReader reader = new FileReader(hashedFile)) {
|
||||||
Tiny2Reader.read(reader, hashed);
|
Tiny2Reader.read(reader, hashed);
|
||||||
}
|
}
|
||||||
hashed.accept(sourceNsSwitch);
|
hashed.accept(mappings);
|
||||||
|
|
||||||
try (FileReader reader = new FileReader(quiltMappingsFile)) {
|
try (FileReader reader = new FileReader(quiltMappingsFile)) {
|
||||||
Tiny2Reader.read(reader, mappings);
|
Tiny2Reader.read(reader, mappings);
|
||||||
|
@ -107,10 +107,10 @@ public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
||||||
Tiny2Reader.read(new FileReader(intermediaryToQm), mappingVisitor);
|
Tiny2Reader.read(new FileReader(intermediaryToQm), mappingVisitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFile(Set<File> dependency, File output) {
|
private void downloadFile(File dependency, File output) {
|
||||||
if (!output.exists()) {
|
if (!output.exists()) {
|
||||||
GFileUtils.copyFile(project
|
GFileUtils.copyFile(project
|
||||||
.zipTree(dependency.stream().iterator().next())
|
.zipTree(dependency)
|
||||||
.getFiles()
|
.getFiles()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(file -> file.getName().endsWith("mappings.tiny"))
|
.filter(file -> file.getName().endsWith("mappings.tiny"))
|
||||||
|
@ -123,10 +123,5 @@ public class QuiltMappingsOnLoomPlugin implements Plugin<Project> {
|
||||||
public MappingsNamespace getSourceNamespace() {
|
public MappingsNamespace getSourceNamespace() {
|
||||||
return MappingsNamespace.OFFICIAL;
|
return MappingsNamespace.OFFICIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return quiltMappings.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
id("fabric-loom") version "0.10-SNAPSHOT"
|
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"
|
version = "1.0.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -14,14 +14,14 @@ repositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var minecraft_version = "21w42a"
|
var minecraft_version = "1.18-pre2"
|
||||||
var quilt_mappings = "21w42a+build.1"
|
var quilt_mappings = "1.18-pre2+build.3"
|
||||||
var loader_version = "0.12.2"
|
var loader_version = "0.12.2"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft("com.mojang:minecraft:${minecraft_version}")
|
minecraft("com.mojang:minecraft:${minecraft_version}")
|
||||||
mappings(loom.layered {
|
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}")
|
modImplementation("net.fabricmc:fabric-loader:${loader_version}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ pluginManagement {
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://maven.fabricmc.net/")
|
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