Skip to content

Commit

Permalink
convert Constants to an interface and move it to new constants package
Browse files Browse the repository at this point in the history
promote all inner Constants classes to the constants package
extract more classifiers and move all classifier constants to constants.Classifiers
extract more extensions and move all extension constants to constants.Extensions
  • Loading branch information
supersaiyansubtlety committed Oct 29, 2024
1 parent b78bf6e commit 263cfee
Show file tree
Hide file tree
Showing 61 changed files with 236 additions and 227 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.gradle.api.internal.file.FileOperations
import quilt.internal.Constants
import quilt.internal.constants.Constants
import quilt.internal.constants.Classifiers
import quilt.internal.plugin.MapIntermediaryPlugin
import quilt.internal.task.build.IntermediaryMappingsV2JarTask

import static org.gradle.api.plugins.JavaPlugin.JAVADOC_TASK_NAME

Expand Down Expand Up @@ -277,9 +277,9 @@ tasks.withType(AbstractPublishToMaven).configureEach {
}

// quilt-mappings-<version>-intermediary-v2.jar
addArtifact(intermediaryV2MappingsJar, IntermediaryMappingsV2JarTask.CLASSIFIER)
addArtifact(intermediaryV2MappingsJar, Classifiers.INTERMEDIARY_V2)
// quilt-mappings-<version>-intermediary-mergedv2.jar
addArtifact(intermediaryV2MergedMappingsJar, IntermediaryMappingsV2JarTask.MERGED_CLASSIFIER)
addArtifact(intermediaryV2MergedMappingsJar, Classifiers.INTERMEDIARY_V2_MERGED)
}
}
}
32 changes: 0 additions & 32 deletions buildSrc/src/main/java/quilt/internal/Constants.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.quiltmc.enigma.api.EnigmaProfile;
import quilt.internal.constants.Constants;
import quilt.internal.plugin.QuiltMappingsBasePlugin;
import quilt.internal.task.EnigmaProfileConsumingTask;
import quilt.internal.task.MappingsDirConsumingTask;
Expand Down
21 changes: 21 additions & 0 deletions buildSrc/src/main/java/quilt/internal/constants/Classifiers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package quilt.internal.constants;

public interface Classifiers {
String INTERMEDIARY = Namespaces.INTERMEDIARY;
String PER_VERSION = Namespaces.PER_VERSION;
String NAMED = Namespaces.NAMED;

String V2 = "v2";
String MERGED_V2 = "merged" + V2;
String INTERMEDIARY_V2 = INTERMEDIARY + "-" + V2;
String INTERMEDIARY_V2_MERGED = INTERMEDIARY + "-" + MERGED_V2;

String UNPICKED = "unpicked";
String PER_VERSION_UNPICKED = PER_VERSION + "-" + UNPICKED;

String TINY = Constants.TINY_NAME;

String CONSTANTS = "constants";
String JAVADOC = "javadoc";
String SOURCES = "sources";
}
13 changes: 13 additions & 0 deletions buildSrc/src/main/java/quilt/internal/constants/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package quilt.internal.constants;

public interface Constants {
String MAPPINGS_NAME = "quilt-mappings";

String PER_VERSION_MAPPINGS_NAME = "hashed";

String INTERMEDIARY_MAPPINGS_NAME = "intermediary";

String UNPICK_NAME = "unpick";

String TINY_NAME = "tiny";
}
11 changes: 11 additions & 0 deletions buildSrc/src/main/java/quilt/internal/constants/Extensions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package quilt.internal.constants;

import org.gradle.jvm.tasks.Jar;

public interface Extensions {
String JAR = Jar.DEFAULT_EXTENSION;
String TINY = Constants.TINY_NAME;
String UNPICK = Constants.UNPICK_NAME;
String GZ = "gz";
String JSON = "json";
}
15 changes: 15 additions & 0 deletions buildSrc/src/main/java/quilt/internal/constants/Groups.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package quilt.internal.constants;

public interface Groups {
String SETUP = "jar setup";
String MAPPINGS = Constants.MAPPINGS_NAME;
String BUILD_MAPPINGS = "build mappings";
String MAP_JAR = "jar mapping";
String DECOMPILE = "decompile";
String UNPICK = Constants.UNPICK_NAME;
String LINT = "lint";
String UNPICK_GEN = Constants.UNPICK_NAME + " gen";
String DIFF = "diff";
String JAVADOC_GENERATION = "javadoc generation";
String PER_VERSION = Constants.PER_VERSION_MAPPINGS_NAME;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package quilt.internal.constants;

public interface Namespaces {
String INTERMEDIARY = Constants.INTERMEDIARY_MAPPINGS_NAME;
String PER_VERSION = Constants.PER_VERSION_MAPPINGS_NAME;
String NAMED = "named";
String OFFICIAL = "official";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.gradle.api.GradleException;
import org.gradle.api.file.RegularFile;
import org.gradle.api.provider.Provider;
import quilt.internal.constants.Namespaces;

import net.fabricmc.mappingio.format.tiny.Tiny2FileReader;
import net.fabricmc.mappingio.tree.MappingTree;
Expand Down Expand Up @@ -133,7 +134,7 @@ public String provideMethodJavadoc(String methodName, String descriptor, String
}

public static Provider<MappingsJavadocProvider> provideNamed(Provider<RegularFile> mappings) {
return provide(mappings, "named");
return provide(mappings, Namespaces.NAMED);
}

public static Provider<MappingsJavadocProvider> provide(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import org.gradle.api.tasks.TaskProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import quilt.internal.Constants;
import quilt.internal.constants.Constants;
import quilt.internal.constants.Classifiers;
import quilt.internal.constants.Extensions;
import quilt.internal.QuiltMappingsExtension;
import quilt.internal.plugin.abstraction.MappingsProjectPlugin;
import quilt.internal.task.build.BuildIntermediaryTask;
Expand All @@ -27,6 +29,8 @@

import java.util.Objects;

import static quilt.internal.constants.Constants.INTERMEDIARY_MAPPINGS_NAME;

/**
* {@linkplain TaskContainer#register Registers} tasks related to
* {@value Constants#INTERMEDIARY_MAPPINGS_NAME} mappings.
Expand All @@ -49,7 +53,7 @@
* </ul>
*/
public abstract class MapIntermediaryPlugin implements MappingsProjectPlugin {
public static final String INTERMEDIARY_MAPPINGS_CONFIGURATION_NAME = Constants.INTERMEDIARY_MAPPINGS_NAME;
public static final String INTERMEDIARY_MAPPINGS_CONFIGURATION_NAME = INTERMEDIARY_MAPPINGS_NAME;

@Nullable
private Provider<RegularFile> intermediaryProvider;
Expand All @@ -60,7 +64,7 @@ public abstract class MapIntermediaryPlugin implements MappingsProjectPlugin {
public Provider<RegularFile> provideIntermediary() {
return Objects.requireNonNull(
this.intermediaryProvider,
Constants.INTERMEDIARY_MAPPINGS_NAME + " not yet populated"
INTERMEDIARY_MAPPINGS_NAME + " not yet populated"
);
}

Expand All @@ -87,7 +91,7 @@ public void apply(@NotNull Project project) {
ExtractTinyIntermediaryMappingsTask.class,
task -> {
task.getExtractionDest().convention(this.provideMappingsBuildFile(
ext.provideSuffixedMinecraftVersion("-" + Constants.INTERMEDIARY_MAPPINGS_NAME + "." + "tiny")
ext.provideSuffixedMinecraftVersion("-" + INTERMEDIARY_MAPPINGS_NAME + "." + Extensions.TINY)
));
}
);
Expand Down Expand Up @@ -118,9 +122,9 @@ public void apply(@NotNull Project project) {

task.getMergedTinyMappings().convention(mergeTinyV2.flatMap(MergeTinyV2Task::getOutputMappings));

task.getOutputMappings().convention(
this.provideMappingsBuildFile("mappings-intermediaryMerged.tiny")
);
task.getOutputMappings().convention(this.provideMappingsBuildFile(
"mappings-" + Classifiers.INTERMEDIARY + "Merged." + Extensions.TINY
));
}
);

Expand All @@ -131,7 +135,7 @@ public void apply(@NotNull Project project) {
task.getInput().convention(mergeIntermediary.flatMap(MergeIntermediaryTask::getOutputMappings));

task.getOutputMappings().convention(
this.provideMappingsBuildFile("mappings-intermediary.tiny")
this.provideMappingsBuildFile("mappings-" + Classifiers.INTERMEDIARY + "." + Extensions.TINY)
);
}
);
Expand All @@ -144,7 +148,7 @@ public void apply(@NotNull Project project) {
intermediaryV2MappingsJar.configure(task -> {
task.getMappings().convention(removeIntermediary.flatMap(RemoveIntermediaryTask::getOutputMappings));

task.getArchiveClassifier().convention(IntermediaryMappingsV2JarTask.CLASSIFIER);
task.getArchiveClassifier().convention(Classifiers.INTERMEDIARY_V2);
});

final var intermediaryV2MergedMappingsJar = tasks.register(
Expand All @@ -155,7 +159,7 @@ public void apply(@NotNull Project project) {
intermediaryV2MergedMappingsJar.configure(task -> {
task.getMappings().convention(mergeIntermediary.flatMap(MergeIntermediaryTask::getOutputMappings));

task.getArchiveClassifier().convention(IntermediaryMappingsV2JarTask.MERGED_CLASSIFIER);
task.getArchiveClassifier().convention(Classifiers.INTERMEDIARY_V2_MERGED);
});

tasks.register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.jvm.tasks.Jar;
import org.jetbrains.annotations.NotNull;
import quilt.internal.Constants;
import quilt.internal.constants.Constants;
import quilt.internal.constants.Classifiers;
import quilt.internal.constants.Extensions;
import quilt.internal.QuiltMappingsExtension;
import quilt.internal.plugin.abstraction.DefaultTaskedMappingsProjectPlugin;
import quilt.internal.task.build.AddProposedMappingsTask;
Expand All @@ -26,9 +27,7 @@
import quilt.internal.task.setup.DownloadMinecraftLibrariesTask;
import quilt.internal.task.setup.ExtractTinyMappingsTask;
import quilt.internal.task.setup.MergeJarsTask;
import quilt.internal.util.FileUtil;

import static quilt.internal.task.jarmapping.MapPerVersionMappingsJarTask.PER_VERSION_CLASSIFIER;
import static quilt.internal.util.FileUtil.getNameWithExtension;
import static quilt.internal.util.FileUtil.getPathWithExtension;

Expand Down Expand Up @@ -94,7 +93,7 @@ protected Tasks applyImpl(@NotNull Project project) {
task.getZippedFile().convention(this.provideRequiredFile(perVersionMappings));

task.getExtractionDest().convention(this.provideMappingsBuildFile(
ext.provideSuffixedMinecraftVersion("-" + Constants.PER_VERSION_MAPPINGS_NAME + "." + "tiny")
ext.provideSuffixedMinecraftVersion("-" + Classifiers.PER_VERSION + "." + Extensions.TINY)
));
}
);
Expand All @@ -109,7 +108,7 @@ protected Tasks applyImpl(@NotNull Project project) {

task.getInvertedTinyFile().convention(
task.getInput()
.map(input -> getPathWithExtension(input, "-inverted.tiny"))
.map(input -> getPathWithExtension(input, "-inverted." + Extensions.TINY))
.map(this.getProjectDir()::file)
);
}
Expand All @@ -136,7 +135,7 @@ protected Tasks applyImpl(@NotNull Project project) {

task.getOutputJar().convention(
this.provideMappedMinecraftBuildFile(
ext.provideSuffixedMinecraftVersion("-" + PER_VERSION_CLASSIFIER + "." + Jar.DEFAULT_EXTENSION)
ext.provideSuffixedMinecraftVersion("-" + Classifiers.PER_VERSION + "." + Extensions.JAR)
)
);
}
Expand All @@ -151,7 +150,7 @@ protected Tasks applyImpl(@NotNull Project project) {
);

task.getOutputMappings().convention(
this.provideMappingsBuildFile(Constants.MAPPINGS_NAME + ".tiny")
this.provideMappingsBuildFile(Constants.MAPPINGS_NAME + "." + Extensions.TINY)
);
}
);
Expand All @@ -168,19 +167,19 @@ protected Tasks applyImpl(@NotNull Project project) {

task.getOutputMappings().convention(
this.getMappingsBuildDir().zip(task.getInputMappings(), (dir, input) ->
dir.file(getNameWithExtension(input, "-inserted.tiny"))
dir.file(getNameWithExtension(input, "-inserted." + Extensions.TINY))
)
);

task.getPreprocessedMappings().convention(
this.getTempDir().zip(task.getInputMappings(), (dir, input) ->
dir.file(getNameWithExtension(input, "-preprocessed.tiny"))
dir.file(getNameWithExtension(input, "-preprocessed." + Extensions.TINY))
)
);

task.getProcessedMappings().convention(
this.getTempDir().zip(task.getInputMappings(), (dir, input) ->
dir.file(getNameWithExtension(input, "-processed.tiny"))
dir.file(getNameWithExtension(input, "-processed." + Extensions.TINY))
)
);
}
Expand All @@ -196,7 +195,7 @@ protected Tasks applyImpl(@NotNull Project project) {
invertPerVersionMappings.flatMap(InvertPerVersionMappingsTask::getInvertedTinyFile)
);

task.getOutputMappings().convention(this.provideMappingsBuildFile("mappings.tiny"));
task.getOutputMappings().convention(this.provideMappingsBuildFile("mappings." + Extensions.TINY));
}
);

Expand All @@ -223,7 +222,7 @@ protected Tasks applyImpl(@NotNull Project project) {

task.getArtifactVersion().convention(ext.getMappingsVersion());

task.getArtifactClassifier().convention(CompressTinyTask.TINY_CLASSIFIER);
task.getArtifactClassifier().convention(Classifiers.TINY);
}
);

Expand Down
Loading

2 comments on commit 263cfee

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No difference between head and target.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With commit 263cfee, 11 file(s) were updated with 24 line(s) added and 24 removed compared to the latest Quilt Mappings version.

View the diff here:
diff -bur namedTargetSrc/net/minecraft/client/gui/ParentElement.java namedSrc/net/minecraft/client/gui/ParentElement.java
--- namedTargetSrc/net/minecraft/client/gui/ParentElement.java	2024-10-29 06:49:40.558731760 +0000
+++ namedSrc/net/minecraft/client/gui/ParentElement.java	2024-10-29 06:48:30.606101328 +0000
@@ -153,7 +153,7 @@
     * Mapping not found
     */
    @Override
-   default void setFocused(boolean bl) {
+   default void setFocused(boolean focused) {
    }
 
    /**
diff -bur namedTargetSrc/net/minecraft/client/gui/screen/realms/RealmsMainScreen.java namedSrc/net/minecraft/client/gui/screen/realms/RealmsMainScreen.java
--- namedTargetSrc/net/minecraft/client/gui/screen/realms/RealmsMainScreen.java	2024-10-29 06:49:40.674732274 +0000
+++ namedSrc/net/minecraft/client/gui/screen/realms/RealmsMainScreen.java	2024-10-29 06:48:30.758103336 +0000
@@ -1506,9 +1506,9 @@
        * Mapping not found
        */
       @Override
-      public void setFocused(boolean bl) {
-         super.setFocused(bl);
-         this.button.setFocused(bl);
+      public void setFocused(boolean focused) {
+         super.setFocused(focused);
+         this.button.setFocused(focused);
       }
 
       /**
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/ClickableWidget.java namedSrc/net/minecraft/client/gui/widget/ClickableWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/ClickableWidget.java	2024-10-29 06:49:40.698732380 +0000
+++ namedSrc/net/minecraft/client/gui/widget/ClickableWidget.java	2024-10-29 06:48:30.790103759 +0000
@@ -447,8 +447,8 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
-      this.focused = bl;
+   public void setFocused(boolean focused) {
+      this.focused = focused;
    }
 
    /**
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/DraggingWidget.java namedSrc/net/minecraft/client/gui/widget/DraggingWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/DraggingWidget.java	2024-10-29 06:49:40.562731777 +0000
+++ namedSrc/net/minecraft/client/gui/widget/DraggingWidget.java	2024-10-29 06:48:30.618101487 +0000
@@ -121,7 +121,7 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
-      ParentElement.super.setFocused(bl);
+   public void setFocused(boolean focused) {
+      ParentElement.super.setFocused(focused);
    }
 }
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/EditBoxWidget.java namedSrc/net/minecraft/client/gui/widget/EditBoxWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/EditBoxWidget.java	2024-10-29 06:49:40.658732203 +0000
+++ namedSrc/net/minecraft/client/gui/widget/EditBoxWidget.java	2024-10-29 06:48:30.734103019 +0000
@@ -342,9 +342,9 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
-      super.setFocused(bl);
-      if (bl) {
+   public void setFocused(boolean focused) {
+      super.setFocused(focused);
+      if (focused) {
          this.focusTime = Util.getMeasuringTimeMs();
       }
    }
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/HeaderBar.java namedSrc/net/minecraft/client/gui/widget/HeaderBar.java
--- namedTargetSrc/net/minecraft/client/gui/widget/HeaderBar.java	2024-10-29 06:49:40.738732558 +0000
+++ namedSrc/net/minecraft/client/gui/widget/HeaderBar.java	2024-10-29 06:48:30.854104604 +0000
@@ -122,10 +122,10 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
-      super.setFocused(bl);
+   public void setFocused(boolean focused) {
+      super.setFocused(focused);
       if (this.getFocused() != null) {
-         this.getFocused().setFocused(bl);
+         this.getFocused().setFocused(focused);
       }
    }
 
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/list/EntryListWidget.java namedSrc/net/minecraft/client/gui/widget/list/EntryListWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/list/EntryListWidget.java	2024-10-29 06:49:40.470731369 +0000
+++ namedSrc/net/minecraft/client/gui/widget/list/EntryListWidget.java	2024-10-29 06:48:30.506100007 +0000
@@ -908,7 +908,7 @@
        * @mapping {@literal named setFocused Lnet/minecraft/client/gui/widget/list/EntryListWidget$Entry;setFocused(Z)V}
        */
       @Override
-      public void setFocused(boolean bl) {
+      public void setFocused(boolean focused) {
       }
 
       /**
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/recipe_book/RecipeAlternativesWidget.java namedSrc/net/minecraft/client/gui/widget/recipe_book/RecipeAlternativesWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/recipe_book/RecipeAlternativesWidget.java	2024-10-29 06:49:40.562731777 +0000
+++ namedSrc/net/minecraft/client/gui/widget/recipe_book/RecipeAlternativesWidget.java	2024-10-29 06:48:30.618101487 +0000
@@ -249,7 +249,7 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
+   public void setFocused(boolean focused) {
    }
 
    /**
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/recipe_book/RecipeBookWidget.java namedSrc/net/minecraft/client/gui/widget/recipe_book/RecipeBookWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/recipe_book/RecipeBookWidget.java	2024-10-29 06:49:40.706732416 +0000
+++ namedSrc/net/minecraft/client/gui/widget/recipe_book/RecipeBookWidget.java	2024-10-29 06:48:30.798103864 +0000
@@ -742,7 +742,7 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
+   public void setFocused(boolean focused) {
    }
 
    /**
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/SliderWidget.java namedSrc/net/minecraft/client/gui/widget/SliderWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/SliderWidget.java	2024-10-29 06:49:40.458731316 +0000
+++ namedSrc/net/minecraft/client/gui/widget/SliderWidget.java	2024-10-29 06:48:30.490099797 +0000
@@ -151,9 +151,9 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
-      super.setFocused(bl);
-      if (!bl) {
+   public void setFocused(boolean focused) {
+      super.setFocused(focused);
+      if (!focused) {
          this.mutable = false;
       } else {
          InputType lv = MinecraftClient.getInstance().getLastInputType();
diff -bur namedTargetSrc/net/minecraft/client/gui/widget/TextFieldWidget.java namedSrc/net/minecraft/client/gui/widget/TextFieldWidget.java
--- namedTargetSrc/net/minecraft/client/gui/widget/TextFieldWidget.java	2024-10-29 06:49:40.494731476 +0000
+++ namedSrc/net/minecraft/client/gui/widget/TextFieldWidget.java	2024-10-29 06:48:30.530100324 +0000
@@ -736,10 +736,10 @@
     * Mapping not found
     */
    @Override
-   public void setFocused(boolean bl) {
-      if (this.focusUnlocked || bl) {
-         super.setFocused(bl);
-         if (bl) {
+   public void setFocused(boolean focused) {
+      if (this.focusUnlocked || focused) {
+         super.setFocused(focused);
+         if (focused) {
             this.lastFocusTime = Util.getMeasuringTimeMs();
          }
       }

Please sign in to comment.