Skip to content

Commit

Permalink
Quiltflower -> Vineflower (QuiltMC#468)
Browse files Browse the repository at this point in the history
* Quiltflower -> Vineflower

* Remove deprecated interface
  • Loading branch information
IotaBread authored Aug 2, 2023
1 parent 8f28aca commit 5e614c7
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
java-version: ${{ matrix.java }}
distribution: temurin
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew decompileQuiltflower decompileTargetQuiltflower --stacktrace
- run: ./gradlew decompileVineflower decompileTargetVineflower --stacktrace
if: ${{ matrix.java == 17 }}
- name: Check Target Decompiled
id: can-create-diff
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Build a GZip'd archive containing a tiny mapping between official (obfuscated),
### `mapNamedJar`
Builds a deobfuscated jar with Quilt mappings and automapped fields (enums, etc.). Unmapped names will be filled with [hashed-mojmap](https://github.com/QuiltMC/mappings-hasher) names.

### `decompileQuiltflower`
### `decompileVineflower`
Decompile the mapped source code. **Note:** This is not designed to be recompiled.

### `downloadMinecraftJars`
Expand Down
14 changes: 9 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ repositories {
name "Quilt Snapshot Repository"
url "https://maven.quiltmc.org/repository/snapshot"
}
maven {
// Vineflower snapshots
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
mavenLocal()
}

Expand Down Expand Up @@ -245,7 +249,7 @@ def fakeSourceDir = file(".gradle/temp/fakeSource")
task genFakeSource(type: DecompileTask, dependsOn: [mergeTinyV2, eraseBytecode]) {
input = eraseBytecode.output.asFile.get()
output = fakeSourceDir
decompiler = Decompilers.QUILTFLOWER
decompiler = Decompilers.VINEFLOWER
libraries = files(mappings.fileConstants.libraries)
decompilerOptions = [
"rsy": "1", // remove synthetics
Expand Down Expand Up @@ -280,10 +284,10 @@ task decompileCFR(type: DecompileTask, dependsOn: [mapNamedJar]) {
}
}

task decompileQuiltflower(type: DecompileTask, dependsOn: [mapNamedJar]) {
task decompileVineflower(type: DecompileTask, dependsOn: [mapNamedJar]) {
input.set mappings.fileConstants.namedJar
output.set file("namedSrc")
decompiler = Decompilers.QUILTFLOWER
decompiler = Decompilers.VINEFLOWER
libraries = configurations.decompileClasspath

doFirst {
Expand Down Expand Up @@ -320,10 +324,10 @@ task unpickTargetJar(type: UnpickJarTask) {
}
}

task decompileTargetQuiltflower(type: DecompileTask, dependsOn: [remapTargetMinecraftJar]) {
task decompileTargetVineflower(type: DecompileTask, dependsOn: [remapTargetMinecraftJar]) {
input.set remapTargetMinecraftJar.outputJar
output.set file("namedTargetSrc")
decompiler = Decompilers.QUILTFLOWER
decompiler = Decompilers.VINEFLOWER
libraries = configurations.decompileClasspath

doFirst {
Expand Down
6 changes: 5 additions & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ repositories {
name "Mojang"
url 'https://libraries.minecraft.net/'
}
maven {
// Vineflower snapshots
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
mavenLocal()
}

Expand All @@ -44,7 +48,7 @@ dependencies {

// Decompilers
implementation(libs.cfr)
implementation(libs.quiltflower)
implementation(libs.vineflower)

// Testing
testImplementation(libs.junit)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package quilt.internal.decompile;

import quilt.internal.decompile.cfr.CfrDecompiler;
import quilt.internal.decompile.quiltflower.QuiltflowerDecompiler;
import quilt.internal.decompile.vineflower.VineflowerDecompiler;

public enum Decompilers {
CFR(CfrDecompiler::new),
QUILTFLOWER(QuiltflowerDecompiler::new);
VINEFLOWER(VineflowerDecompiler::new);

private final DecompilerProvider provider;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package quilt.internal.decompile.quiltflower;
package quilt.internal.decompile.vineflower;

import net.fabricmc.fernflower.api.IFabricJavadocProvider;
import org.gradle.api.Project;
import org.gradle.api.logging.LogLevel;
import org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler;
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider;
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
import org.jetbrains.java.decompiler.main.extern.IResultSaver;
Expand All @@ -14,23 +13,17 @@
import quilt.internal.decompile.javadoc.MethodJavadocProvider;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class QuiltflowerDecompiler extends AbstractDecompiler implements IBytecodeProvider {
public class VineflowerDecompiler extends AbstractDecompiler {
private IFabricJavadocProvider javadocProvider;
private ClassJavadocProvider classJavadocProvider;
private FieldJavadocProvider fieldJavadocProvider;
private MethodJavadocProvider methodJavadocProvider;

public QuiltflowerDecompiler(Project project) {
public VineflowerDecompiler(Project project) {
super(project);
}

Expand All @@ -45,16 +38,16 @@ public void decompile(File file, File outputDir, Map<String, Object> options, Co
if (this.javadocProvider != null) {
javadocProvider = this.javadocProvider;
} else if (hasMemberJavadocProvider()) {
javadocProvider = new QuiltflowerJavadocProvider(this.classJavadocProvider, this.fieldJavadocProvider, this.methodJavadocProvider);
javadocProvider = new VineflowerJavadocProvider(this.classJavadocProvider, this.fieldJavadocProvider, this.methodJavadocProvider);
}

if (javadocProvider != null) {
options.put(IFabricJavadocProvider.PROPERTY_NAME, javadocProvider);
}

IResultSaver resultSaver = new QuiltflowerResultSaver(outputPath);
IResultSaver resultSaver = new VineflowerResultSaver(outputPath);

BaseDecompiler decompiler = new BaseDecompiler(this, resultSaver, options, new LoggerImpl());
BaseDecompiler decompiler = new BaseDecompiler(resultSaver, options, new LoggerImpl());

decompiler.addSource(file);
for (File library : libraries) {
Expand All @@ -64,27 +57,6 @@ public void decompile(File file, File outputDir, Map<String, Object> options, Co
decompiler.decompileContext();
}

@Override
public byte[] getBytecode(String externalPath, String internalPath) throws IOException {
File file = new File(externalPath);
if (internalPath == null) {
try (InputStream stream = new FileInputStream(file)) {
return stream.readAllBytes();
}
} else {
try (ZipFile zipFile = new ZipFile(file)) {
ZipEntry entry = zipFile.getEntry(internalPath);
if (entry == null) {
throw new FileNotFoundException("Entry " + internalPath + " not found in " + file);
}

try (InputStream stream = zipFile.getInputStream(entry)) {
return stream.readAllBytes();
}
}
}
}

private boolean hasMemberJavadocProvider() {
return this.classJavadocProvider != null || this.fieldJavadocProvider != null || this.methodJavadocProvider != null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package quilt.internal.decompile.quiltflower;
package quilt.internal.decompile.vineflower;

import net.fabricmc.fernflower.api.IFabricJavadocProvider;
import org.jetbrains.java.decompiler.struct.StructClass;
Expand All @@ -8,12 +8,12 @@
import quilt.internal.decompile.javadoc.FieldJavadocProvider;
import quilt.internal.decompile.javadoc.MethodJavadocProvider;

public class QuiltflowerJavadocProvider implements IFabricJavadocProvider {
public class VineflowerJavadocProvider implements IFabricJavadocProvider {
private final ClassJavadocProvider classJavadocProvider;
private final FieldJavadocProvider fieldJavadocProvider;
private final MethodJavadocProvider methodJavadocProvider;

public QuiltflowerJavadocProvider(ClassJavadocProvider classJavadocProvider, FieldJavadocProvider fieldJavadocProvider, MethodJavadocProvider methodJavadocProvider) {
public VineflowerJavadocProvider(ClassJavadocProvider classJavadocProvider, FieldJavadocProvider fieldJavadocProvider, MethodJavadocProvider methodJavadocProvider) {
this.classJavadocProvider = classJavadocProvider != null ? classJavadocProvider : ClassJavadocProvider.EMPTY;
this.fieldJavadocProvider = fieldJavadocProvider != null ? fieldJavadocProvider : FieldJavadocProvider.EMPTY;
this.methodJavadocProvider = methodJavadocProvider != null ? methodJavadocProvider : MethodJavadocProvider.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package quilt.internal.decompile.quiltflower;
package quilt.internal.decompile.vineflower;

import org.jetbrains.java.decompiler.main.extern.IResultSaver;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.jar.Manifest;

public class QuiltflowerResultSaver implements IResultSaver {
public class VineflowerResultSaver implements IResultSaver {
private final Path outputPath;

public QuiltflowerResultSaver(Path outputPath) {
public VineflowerResultSaver(Path outputPath) {
this.outputPath = outputPath;
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jsr305 = "3.0.2"
gson = "2.9.1"
netty = "4.1"

quiltflower = "1.10.0-20230120.185555-31"
vineflower = "1.10.0-20230713.053900-2"
cfr = "0.2.0"

junit = "5.9.1"
Expand Down Expand Up @@ -49,7 +49,7 @@ jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" }

# Decompilers
cfr = { module = "net.fabricmc:cfr", version.ref = "cfr" }
quiltflower = { module = "org.quiltmc:quiltflower", version.ref = "quiltflower" }
vineflower = { module = "org.vineflower:vineflower", version.ref = "vineflower" }

# Testing
junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
Expand Down

0 comments on commit 5e614c7

Please sign in to comment.