Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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 @@ -15,7 +15,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Build with Gradle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy Snapshot
on:
push:
branches: ['main']
branches: ['main', 'dev/v2']
paths-ignore:
- '.idea/**'
- 'license.txt'
Expand All @@ -19,7 +19,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Get project version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Deploy
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ build/
### IntelliJ IDEA ###
.idea/**
# Need to first allow the directory
!.idea/inspectionProfiles/
# Then the specific file
!.idea/inspectionProfiles/Project_Default.xml
!.idea/misc.xml
*.iws
*.iml
*.ipr
Expand Down Expand Up @@ -45,3 +42,4 @@ bin/
.DS_Store

run/
.kotlin/
63 changes: 0 additions & 63 deletions .idea/misc.xml

This file was deleted.

114 changes: 0 additions & 114 deletions codebook-cli/src/main/java/io/papermc/codebook/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,81 +96,6 @@ static final class SelectedReports {
}
}

@CommandLine.ArgGroup(
multiplicity = "1",
heading = "%n%nThe remapper must be an executable tiny-remapper jar. "
+ "This is the 'fat' classifier when downloading from Maven. It can be provided several different ways, the simplest being to just "
+ "specify the Maven coordinates (with no classifier).%n")
private RemapperOptions remapper;

static final class RemapperOptions {
@CommandLine.Option(
names = {"-r", "--remapper-coords"},
paramLabel = "<art-coords>",
description =
"The Maven coordinates for the executable AutoRenamingTool jar to use for the remapping process.")
private @Nullable String remapperCoords;

@CommandLine.Option(
names = {"--remapper-file"},
paramLabel = "<art-file>",
description = "The executable AutoRenamingTool jar to use for the remapping process.")
private @Nullable Path remapperFile;

@CommandLine.Option(
names = "--remapper-uri",
paramLabel = "<art-uri>",
description =
"A download URL for the executable AutoRenamingTool jar to use for the remapping process.")
private @Nullable URI remapperUri;
}

@CommandLine.ArgGroup(
heading =
"%n%nMappings are required when not using the --mc-version option to automatically download a version. "
+ "They can still be optionally provided using one of the 2 mappings options below, "
+ "but one of either --mappings-file or --mappings-uri is required when using --input to manually specify a jar file.%n")
private @Nullable MappingsOptions mappings;

static final class MappingsOptions {
@CommandLine.Option(
names = {"-m", "--mappings-file"},
paramLabel = "<mappings-file>",
description = "The ProGuard mojmap mappings to use for base remapping.")
private @Nullable Path mappingsFile;

@CommandLine.Option(
names = "--mappings-uri",
paramLabel = "<mappings-uri>",
description = "A download URL for the ProGuard mojmap mappings to use for base remapping.")
private @Nullable URI mappingsUri;
}

@CommandLine.ArgGroup(
heading = "%n%nParameter mappings are always optional, and can be specified several different ways.%n")
private @Nullable ParamMappingsOptions paramMappings;

static final class ParamMappingsOptions {
@CommandLine.Option(
names = {"-p", "--params-coords"},
paramLabel = "<param-mappings-coords>",
description =
"The Maven coordinates for TinyV2 mappings to use for parameter remapping. This is the preferred option, as it allows omitting other details.")
private @Nullable String paramsCoords;

@CommandLine.Option(
names = {"--params-file"},
paramLabel = "<param-mappings-file>",
description = "The TinyV2 mappings to use for parameter remapping.")
private @Nullable Path paramsFile;

@CommandLine.Option(
names = "--params-uri",
paramLabel = "<param-mappings-uri>",
description = "A download URL for the TinyV2 mappings to use for parameter remapping.")
private @Nullable URI paramsUri;
}

@CommandLine.ArgGroup(exclusive = false)
private @Nullable UnpickOptions unpick;

Expand Down Expand Up @@ -348,10 +273,6 @@ public Integer call() {
}

private CodeBookContext createContext() {
if (this.remapper.remapperFile != null) {
this.verifyJarFile("Remapper", this.remapper.remapperFile);
}

if (this.inputs.inputFile != null) {
this.verifyJarFile("Input", this.inputs.inputFile.inputJar);

Expand All @@ -362,18 +283,6 @@ private CodeBookContext createContext() {
}
}

if (this.mappings == null && this.inputs.mcVersion == null) {
throw new UserErrorException("No base mappings file was provided, and no MC version was provided. "
+ "When not specifying an MC version, the base mappings file must be manually specified.");
}
if (this.mappings != null && this.mappings.mappingsFile != null) {
this.verifyFileExists("Mappings file", this.mappings.mappingsFile);
}

if (this.paramMappings != null && this.paramMappings.paramsFile != null) {
this.verifyFileExists("Param mappings file", this.paramMappings.paramsFile);
}

if (Files.isRegularFile(this.outputJar) && !this.forceWrite) {
throw new UserErrorException(
"Output jar file exists, will not overwrite because --force option was not provided: "
Expand All @@ -390,26 +299,6 @@ private CodeBookContext createContext() {
input = new CodeBookJarInput(this.inputs.inputFile.inputJar, classpath);
}

final @Nullable CodeBookResource remapper = this.getResource(
"AutoRenamingTool.jar",
this.remapper,
r -> r.remapperFile,
r -> r.remapperUri,
r -> new Coords(r.remapperCoords, "all", null, this.remapperMavenBaseUrl));
if (remapper == null) {
throw new UserErrorException("No remapper provided");
}

final @Nullable CodeBookResource mappings =
this.getResource("server_mappings.txt", this.mappings, m -> m.mappingsFile, m -> m.mappingsUri, null);

final @Nullable CodeBookResource paramMappings = this.getResource(
"parchment.zip",
this.paramMappings,
p -> p.paramsFile,
p -> p.paramsUri,
p -> new Coords(p.paramsCoords, null, "zip", this.paramsMavenBaseUrl));

final @Nullable CodeBookResource unpickDefinitions = this.getResource(
"definitions.unpick",
this.unpick != null ? this.unpick.unpickDefinitions : null,
Expand Down Expand Up @@ -442,9 +331,6 @@ private CodeBookContext createContext() {

return CodeBookContext.builder()
.tempDir(this.tempDir)
.remapperJar(remapper)
.mappings(mappings)
.paramMappings(paramMappings)
.unpickDefinitions(unpickDefinitions)
.outputJar(this.outputJar)
.overwrite(this.forceWrite)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group = io.papermc.codebook
version = 1.0.19-SNAPSHOT
version = 2.0.0-SNAPSHOT
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ There are 2 methods of providing inputs, and they are mutually exclusive:
Building
========

Java 17 is required.
Java 21 is required.

```sh
./gradlew build
Expand Down
42 changes: 5 additions & 37 deletions src/main/java/io/papermc/codebook/CodeBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@
import dev.denwav.hypo.asm.AsmOutputWriter;
import dev.denwav.hypo.core.HypoConfig;
import dev.denwav.hypo.core.HypoContext;
import io.papermc.codebook.config.CodeBookClasspathResource;
import io.papermc.codebook.config.CodeBookContext;
import io.papermc.codebook.config.CodeBookJarInput;
import io.papermc.codebook.config.CodeBookResource;
import io.papermc.codebook.exceptions.UnexpectedException;
import io.papermc.codebook.exceptions.UserErrorException;
import io.papermc.codebook.pages.CodeBookPage;
import io.papermc.codebook.pages.ExtractVanillaJarPage;
import io.papermc.codebook.pages.FixJarPage;
import io.papermc.codebook.pages.InspectJarPage;
import io.papermc.codebook.pages.RemapJarPage;
import io.papermc.codebook.pages.RemapLvtPage;
import io.papermc.codebook.pages.StripSignaturesPage;
import io.papermc.codebook.pages.UnpickPage;
import io.papermc.codebook.report.Reports;
import io.papermc.codebook.util.IOUtil;
Expand Down Expand Up @@ -75,14 +72,14 @@ public void exec() {

private void exec(final Path tempDir) {
this.deleteOutputFile();
IOUtil.createDirectories(tempDir);

final var book = List.of(
ExtractVanillaJarPage.class,
RemapJarPage.class,
StripSignaturesPage.class,
InspectJarPage.class,
UnpickPage.class,
FixJarPage.class,
RemapLvtPage.class);
FixJarPage.class);

Module module = this.createInitialModule(tempDir);
for (final var page : book) {
Expand Down Expand Up @@ -113,11 +110,6 @@ private static Injector injector(final Module module) {
}

private Module createInitialModule(final Path tempDir) {
final @Nullable CodeBookResource mappings = this.ctx.input().resolveMappings(this.ctx, tempDir);
if (mappings == null) {
throw new IllegalStateException("No mappings file could be determined for the given configuration");
}

final Path inputJar = this.ctx.input().resolveInputFile(tempDir);
final @Nullable List<Path> classpathJars;
if (this.ctx.input() instanceof final CodeBookJarInput input) {
Expand All @@ -126,30 +118,9 @@ private Module createInitialModule(final Path tempDir) {
classpathJars = null;
}

final Path mappingsFile = mappings.resolveResourceFile(tempDir);
final @Nullable Path paramMappingsFile;
if (this.ctx.paramMappings() != null) {
paramMappingsFile = this.ctx.paramMappings().resolveResourceFile(tempDir);
} else {
paramMappingsFile = null;
}

final List<Path> remapperJars;
if (this.ctx.remapperJar() instanceof final CodeBookResource resource) {
remapperJars = List.of(resource.resolveResourceFile(tempDir));
} else if (this.ctx.remapperJar() instanceof final CodeBookClasspathResource resource) {
remapperJars = resource.jars();
} else {
throw new LinkageError();
}

final @Nullable Path unpickDefinitions;
if (this.ctx.unpickDefinitions() != null) {
if (this.ctx.unpickDefinitions().equals(this.ctx.paramMappings())) {
unpickDefinitions = paramMappingsFile;
} else {
unpickDefinitions = this.ctx.unpickDefinitions().resolveResourceFile(tempDir);
}
unpickDefinitions = this.ctx.unpickDefinitions().resolveResourceFile(tempDir);
} else {
unpickDefinitions = null;
}
Expand All @@ -165,9 +136,6 @@ protected void configure() {
this.bind(CodeBookPage.ClasspathJars.KEY).toProvider(Providers.of(null));
}
this.bind(CodeBookPage.TempDir.KEY).toInstance(tempDir);
this.bind(CodeBookPage.MojangMappings.PATH_KEY).toInstance(mappingsFile);
this.bind(CodeBookPage.ParamMappings.PATH_KEY).toProvider(Providers.of(paramMappingsFile));
this.bind(CodeBookPage.RemapperJar.KEY).toInstance(remapperJars);

if (unpickDefinitions != null) {
this.bind(CodeBookPage.UnpickDefinitions.KEY).toInstance(unpickDefinitions);
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/io/papermc/codebook/config/CodeBookContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
@RecordBuilder.Options(interpretNotNulls = true)
public record CodeBookContext(
@Nullable @org.jetbrains.annotations.Nullable Path tempDir,
@NotNull CodeBookRemapper remapperJar,
@Nullable @org.jetbrains.annotations.Nullable CodeBookResource mappings,
@Nullable @org.jetbrains.annotations.Nullable CodeBookResource paramMappings,
@Nullable @org.jetbrains.annotations.Nullable CodeBookResource unpickDefinitions,
@NotNull Path outputJar,
boolean overwrite,
Expand Down
Loading