Split out some constants (#267)
This pull request also reorganizes parts of the constants class into categories.
This commit is contained in:
parent
d5ed659e7d
commit
21a9209b86
13 changed files with 105 additions and 57 deletions
|
@ -110,23 +110,23 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
// Force add Mojang repository
|
||||
addMavenRepo(target, "Mojang", "https://libraries.minecraft.net/");
|
||||
|
||||
Configuration modCompileClasspathConfig = project.getConfigurations().maybeCreate(Constants.MOD_COMPILE_CLASSPATH);
|
||||
Configuration modCompileClasspathConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MOD_COMPILE_CLASSPATH);
|
||||
modCompileClasspathConfig.setTransitive(true);
|
||||
Configuration modCompileClasspathMappedConfig = project.getConfigurations().maybeCreate(Constants.MOD_COMPILE_CLASSPATH_MAPPED);
|
||||
Configuration modCompileClasspathMappedConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MOD_COMPILE_CLASSPATH_MAPPED);
|
||||
modCompileClasspathMappedConfig.setTransitive(false);
|
||||
|
||||
Configuration minecraftNamedConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT_NAMED);
|
||||
Configuration minecraftNamedConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MINECRAFT_NAMED);
|
||||
minecraftNamedConfig.setTransitive(false); // The launchers do not recurse dependencies
|
||||
Configuration minecraftDependenciesConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT_DEPENDENCIES);
|
||||
Configuration minecraftDependenciesConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MINECRAFT_DEPENDENCIES);
|
||||
minecraftDependenciesConfig.setTransitive(false);
|
||||
Configuration minecraftConfig = project.getConfigurations().maybeCreate(Constants.MINECRAFT);
|
||||
Configuration minecraftConfig = project.getConfigurations().maybeCreate(Constants.Configurations.MINECRAFT);
|
||||
minecraftConfig.setTransitive(false);
|
||||
|
||||
Configuration includeConfig = project.getConfigurations().maybeCreate(Constants.INCLUDE);
|
||||
Configuration includeConfig = project.getConfigurations().maybeCreate(Constants.Configurations.INCLUDE);
|
||||
includeConfig.setTransitive(false); // Dont get transitive deps
|
||||
|
||||
project.getConfigurations().maybeCreate(Constants.MAPPINGS);
|
||||
project.getConfigurations().maybeCreate(Constants.MAPPINGS_FINAL);
|
||||
project.getConfigurations().maybeCreate(Constants.Configurations.MAPPINGS);
|
||||
project.getConfigurations().maybeCreate(Constants.Configurations.MAPPINGS_FINAL);
|
||||
|
||||
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
|
||||
Configuration compileModsConfig = project.getConfigurations().maybeCreate(entry.getSourceConfiguration());
|
||||
|
@ -137,19 +137,19 @@ public class AbstractPlugin implements Plugin<Project> {
|
|||
extendsFrom(entry.getTargetConfiguration(project.getConfigurations()), entry.getRemappedConfiguration());
|
||||
|
||||
if (entry.isOnModCompileClasspath()) {
|
||||
extendsFrom(Constants.MOD_COMPILE_CLASSPATH, entry.getSourceConfiguration());
|
||||
extendsFrom(Constants.MOD_COMPILE_CLASSPATH_MAPPED, entry.getRemappedConfiguration());
|
||||
extendsFrom(Constants.Configurations.MOD_COMPILE_CLASSPATH, entry.getSourceConfiguration());
|
||||
extendsFrom(Constants.Configurations.MOD_COMPILE_CLASSPATH_MAPPED, entry.getRemappedConfiguration());
|
||||
}
|
||||
}
|
||||
|
||||
extendsFrom("compileClasspath", Constants.MINECRAFT_NAMED);
|
||||
extendsFrom("runtimeClasspath", Constants.MINECRAFT_NAMED);
|
||||
extendsFrom("testCompileClasspath", Constants.MINECRAFT_NAMED);
|
||||
extendsFrom("testRuntimeClasspath", Constants.MINECRAFT_NAMED);
|
||||
extendsFrom("compileClasspath", Constants.Configurations.MINECRAFT_NAMED);
|
||||
extendsFrom("runtimeClasspath", Constants.Configurations.MINECRAFT_NAMED);
|
||||
extendsFrom("testCompileClasspath", Constants.Configurations.MINECRAFT_NAMED);
|
||||
extendsFrom("testRuntimeClasspath", Constants.Configurations.MINECRAFT_NAMED);
|
||||
|
||||
extendsFrom(Constants.MINECRAFT_NAMED, Constants.MINECRAFT_DEPENDENCIES);
|
||||
extendsFrom(Constants.Configurations.MINECRAFT_NAMED, Constants.Configurations.MINECRAFT_DEPENDENCIES);
|
||||
|
||||
extendsFrom("compile", Constants.MAPPINGS_FINAL);
|
||||
extendsFrom("compile", Constants.Configurations.MAPPINGS_FINAL);
|
||||
|
||||
configureIDEs();
|
||||
configureCompile();
|
||||
|
|
|
@ -65,7 +65,7 @@ public class MinecraftProcessedProvider extends MinecraftMappedProvider {
|
|||
|
||||
getProject().getRepositories().flatDir(repository -> repository.dir(getJarDirectory(getExtension().getProjectPersistentCache(), PROJECT_MAPPED_CLASSIFIER)));
|
||||
|
||||
getProject().getDependencies().add(Constants.MINECRAFT_NAMED,
|
||||
getProject().getDependencies().add(Constants.Configurations.MINECRAFT_NAMED,
|
||||
getProject().getDependencies().module("net.minecraft:minecraft:" + getJarVersionString(PROJECT_MAPPED_CLASSIFIER)));
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ public class LaunchProvider extends DependencyProvider {
|
|||
writeLog4jConfig();
|
||||
FileUtils.writeStringToFile(getExtension().getDevLauncherConfig(), launchConfig.asString(), StandardCharsets.UTF_8);
|
||||
|
||||
addDependency("net.fabricmc:dev-launch-injector:" + Constants.DEV_LAUNCH_INJECTOR_VERSION, "runtimeOnly");
|
||||
addDependency("net.minecrell:terminalconsoleappender:" + Constants.TERMINAL_CONSOLE_APPENDER_VERSION, "runtimeOnly");
|
||||
addDependency("org.jetbrains:annotations:" + Constants.JETBRAINS_ANNOTATIONS_VERSION, "compileOnly");
|
||||
addDependency(Constants.Dependencies.DEV_LAUNCH_INJECTOR + Constants.Dependencies.Versions.DEV_LAUNCH_INJECTOR, "runtimeOnly");
|
||||
addDependency(Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER, "runtimeOnly");
|
||||
addDependency(Constants.Dependencies.JETBRAINS_ANNOTATIONS + Constants.Dependencies.Versions.JETBRAINS_ANNOTATIONS, "compileOnly");
|
||||
}
|
||||
|
||||
private File getLog4jConfigFile() {
|
||||
|
@ -92,7 +92,7 @@ public class LaunchProvider extends DependencyProvider {
|
|||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.MINECRAFT_NAMED;
|
||||
return Constants.Configurations.MINECRAFT_NAMED;
|
||||
}
|
||||
|
||||
public static class LaunchConfig {
|
||||
|
|
|
@ -144,7 +144,7 @@ public class MappingsProvider extends DependencyProvider {
|
|||
ZipUtil.pack(new ZipEntrySource[] {new FileSource("mappings/mappings.tiny", tinyMappings)}, tinyMappingsJar);
|
||||
}
|
||||
|
||||
addDependency(tinyMappingsJar, Constants.MAPPINGS_FINAL);
|
||||
addDependency(tinyMappingsJar, Constants.Configurations.MAPPINGS_FINAL);
|
||||
|
||||
LoomGradleExtension extension = getExtension();
|
||||
|
||||
|
@ -302,7 +302,7 @@ public class MappingsProvider extends DependencyProvider {
|
|||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.MAPPINGS;
|
||||
return Constants.Configurations.MAPPINGS;
|
||||
}
|
||||
|
||||
public Path getMappingsDir() {
|
||||
|
|
|
@ -55,7 +55,7 @@ public class MinecraftLibraryProvider {
|
|||
isClientOnly = true;
|
||||
} */
|
||||
|
||||
project.getDependencies().add(Constants.MINECRAFT_DEPENDENCIES, project.getDependencies().module(library.getArtifactName()));
|
||||
project.getDependencies().add(Constants.Configurations.MINECRAFT_DEPENDENCIES, project.getDependencies().module(library.getArtifactName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
|||
protected void addDependencies(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) {
|
||||
getProject().getRepositories().flatDir(repository -> repository.dir(getJarDirectory(getExtension().getUserCache(), "mapped")));
|
||||
|
||||
getProject().getDependencies().add(Constants.MINECRAFT_NAMED,
|
||||
getProject().getDependencies().add(Constants.Configurations.MINECRAFT_NAMED,
|
||||
getProject().getDependencies().module("net.minecraft:minecraft:" + getJarVersionString("mapped")));
|
||||
}
|
||||
|
||||
|
@ -173,6 +173,6 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
|||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.MINECRAFT_NAMED;
|
||||
return Constants.Configurations.MINECRAFT_NAMED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ public class MinecraftProvider extends DependencyProvider {
|
|||
}
|
||||
} else {
|
||||
getProject().getLogger().debug("Downloading version manifests");
|
||||
DownloadUtil.downloadIfChanged(new URL("https://launchermeta.mojang.com/mc/game/version_manifest.json"), manifests, getProject().getLogger());
|
||||
DownloadUtil.downloadIfChanged(new URL(Constants.VERSION_MANIFESTS), manifests, getProject().getLogger());
|
||||
}
|
||||
|
||||
String versionManifest = Files.asCharSource(manifests, StandardCharsets.UTF_8).read();
|
||||
|
@ -211,6 +211,6 @@ public class MinecraftProvider extends DependencyProvider {
|
|||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.MINECRAFT;
|
||||
return Constants.Configurations.MINECRAFT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,16 +29,12 @@ import java.util.List;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class Constants {
|
||||
public static final String DEFAULT_FABRIC_CLIENT_TWEAKER = "net.fabricmc.loader.launch.FabricClientTweaker";
|
||||
public static final String DEFAULT_FABRIC_SERVER_TWEAKER = "net.fabricmc.loader.launch.FabricServerTweaker";
|
||||
|
||||
public static final String LIBRARIES_BASE = "https://libraries.minecraft.net/";
|
||||
public static final String RESOURCES_BASE = "http://resources.download.minecraft.net/";
|
||||
public static final String VERSION_MANIFESTS = "https://launchermeta.mojang.com/mc/game/version_manifest.json";
|
||||
|
||||
public static final String SYSTEM_ARCH = System.getProperty("os.arch").equals("64") ? "64" : "32";
|
||||
|
||||
public static final String MOD_COMPILE_CLASSPATH = "modCompileClasspath";
|
||||
public static final String MOD_COMPILE_CLASSPATH_MAPPED = "modCompileClasspathMapped";
|
||||
public static final List<RemappedConfigurationEntry> MOD_COMPILE_ENTRIES = ImmutableList.of(
|
||||
new RemappedConfigurationEntry("modCompile", "compile", true, "compile"),
|
||||
new RemappedConfigurationEntry("modApi", "api", true, "compile"),
|
||||
|
@ -47,15 +43,67 @@ public class Constants {
|
|||
new RemappedConfigurationEntry("modCompileOnly", "compileOnly", true, "")
|
||||
);
|
||||
|
||||
public static final String INCLUDE = "include";
|
||||
public static final String MINECRAFT = "minecraft";
|
||||
public static final String MINECRAFT_DEPENDENCIES = "minecraftLibraries";
|
||||
public static final String MINECRAFT_NAMED = "minecraftNamed";
|
||||
public static final String MAPPINGS = "mappings";
|
||||
public static final String MAPPINGS_FINAL = "mappingsFinal";
|
||||
private Constants() {
|
||||
}
|
||||
|
||||
public static final String MIXIN_COMPILE_EXTENSIONS_VERSION = "0.3.2.6";
|
||||
public static final String DEV_LAUNCH_INJECTOR_VERSION = "0.2.1+build.8";
|
||||
public static final String TERMINAL_CONSOLE_APPENDER_VERSION = "1.2.0";
|
||||
public static final String JETBRAINS_ANNOTATIONS_VERSION = "19.0.0";
|
||||
/**
|
||||
* Constants related to configurations.
|
||||
*/
|
||||
public static final class Configurations {
|
||||
public static final String MOD_COMPILE_CLASSPATH = "modCompileClasspath";
|
||||
public static final String MOD_COMPILE_CLASSPATH_MAPPED = "modCompileClasspathMapped";
|
||||
public static final String INCLUDE = "include";
|
||||
public static final String MINECRAFT = "minecraft";
|
||||
public static final String MINECRAFT_DEPENDENCIES = "minecraftLibraries";
|
||||
public static final String MINECRAFT_NAMED = "minecraftNamed";
|
||||
public static final String MAPPINGS = "mappings";
|
||||
public static final String MAPPINGS_FINAL = "mappingsFinal";
|
||||
|
||||
private Configurations() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constants related to dependencies.
|
||||
*/
|
||||
public static final class Dependencies {
|
||||
public static final String MIXIN_COMPILE_EXTENSIONS = "net.fabricmc:fabric-mixin-compile-extensions:";
|
||||
public static final String DEV_LAUNCH_INJECTOR = "net.fabricmc:dev-launch-injector:";
|
||||
public static final String TERMINAL_CONSOLE_APPENDER = "net.minecrell:terminalconsoleappender:";
|
||||
public static final String JETBRAINS_ANNOTATIONS = "org.jetbrains:annotations:";
|
||||
|
||||
private Dependencies() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constants for versions of dependencies.
|
||||
*/
|
||||
public static final class Versions {
|
||||
public static final String MIXIN_COMPILE_EXTENSIONS = "0.3.2.6";
|
||||
public static final String DEV_LAUNCH_INJECTOR = "0.2.1+build.8";
|
||||
public static final String TERMINAL_CONSOLE_APPENDER = "1.2.0";
|
||||
public static final String JETBRAINS_ANNOTATIONS = "19.0.0";
|
||||
|
||||
private Versions() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class MixinArguments {
|
||||
public static final String IN_MAP_FILE_NAMED_INTERMEDIARY = "inMapFileNamedIntermediary";
|
||||
public static final String OUT_MAP_FILE_NAMED_INTERMEDIARY = "outMapFileNamedIntermediary";
|
||||
public static final String OUT_REFMAP_FILE = "outRefMapFile";
|
||||
public static final String DEFAULT_OBFUSCATION_ENV = "defaultObfuscationEnv";
|
||||
|
||||
private MixinArguments() {
|
||||
}
|
||||
}
|
||||
|
||||
public static final class LaunchWrapper {
|
||||
public static final String DEFAULT_FABRIC_CLIENT_TWEAKER = "net.fabricmc.loader.launch.FabricClientTweaker";
|
||||
public static final String DEFAULT_FABRIC_SERVER_TWEAKER = "net.fabricmc.loader.launch.FabricServerTweaker";
|
||||
|
||||
private LaunchWrapper() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class LoomDependencyManager {
|
|||
if (extension.getInstallerJson() == null) {
|
||||
//If we've not found the installer JSON we've probably skipped remapping Fabric loader, let's go looking
|
||||
project.getLogger().info("Searching through modCompileClasspath for installer JSON");
|
||||
final Configuration configuration = project.getConfigurations().getByName(Constants.MOD_COMPILE_CLASSPATH);
|
||||
final Configuration configuration = project.getConfigurations().getByName(Constants.Configurations.MOD_COMPILE_CLASSPATH);
|
||||
|
||||
for (File input : configuration.resolve()) {
|
||||
JsonObject jsonObject = ModProcessor.readInstallerJson(input, project);
|
||||
|
@ -173,7 +173,7 @@ public class LoomDependencyManager {
|
|||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
|
||||
JsonObject libraries = jsonObject.get("libraries").getAsJsonObject();
|
||||
Configuration mcDepsConfig = project.getConfigurations().getByName(Constants.MINECRAFT_DEPENDENCIES);
|
||||
Configuration mcDepsConfig = project.getConfigurations().getByName(Constants.Configurations.MINECRAFT_DEPENDENCIES);
|
||||
Configuration apDepsConfig = project.getConfigurations().getByName("annotationProcessor");
|
||||
|
||||
libraries.get("common").getAsJsonArray().forEach(jsonElement -> {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class NestedJars {
|
|||
private static List<File> getContainedJars(Project project) {
|
||||
List<File> fileList = new ArrayList<>();
|
||||
|
||||
Configuration configuration = project.getConfigurations().getByName(Constants.INCLUDE);
|
||||
Configuration configuration = project.getConfigurations().getByName(Constants.Configurations.INCLUDE);
|
||||
ResolvedConfiguration resolvedConfiguration = configuration.getResolvedConfiguration();
|
||||
Set<ResolvedDependency> dependencies = resolvedConfiguration.getFirstLevelModuleDependencies();
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class NestedJars {
|
|||
public static List<RemapJarTask> getRequiredTasks(Project project) {
|
||||
List<RemapJarTask> remapTasks = new ArrayList<>();
|
||||
|
||||
Configuration configuration = project.getConfigurations().getByName(Constants.INCLUDE);
|
||||
Configuration configuration = project.getConfigurations().getByName(Constants.Configurations.INCLUDE);
|
||||
DependencySet dependencies = configuration.getDependencies();
|
||||
|
||||
for (Dependency dependency : dependencies) {
|
||||
|
|
|
@ -113,7 +113,7 @@ public class RunConfig {
|
|||
|
||||
if ("launchwrapper".equals(extension.getLoaderLaunchMethod())) {
|
||||
runConfig.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||
runConfig.programArgs = "--tweakClass " + ("client".equals(mode) ? Constants.DEFAULT_FABRIC_CLIENT_TWEAKER : Constants.DEFAULT_FABRIC_SERVER_TWEAKER);
|
||||
runConfig.programArgs = "--tweakClass " + ("client".equals(mode) ? Constants.LaunchWrapper.DEFAULT_FABRIC_CLIENT_TWEAKER : Constants.LaunchWrapper.DEFAULT_FABRIC_SERVER_TWEAKER);
|
||||
} else {
|
||||
runConfig.mainClass = "net.fabricmc.devlaunchinjector.Main";
|
||||
runConfig.programArgs = "";
|
||||
|
|
|
@ -202,7 +202,7 @@ public class SourceRemapper {
|
|||
public static Mercury createMercuryWithClassPath(Project project, boolean toNamed) {
|
||||
Mercury m = new Mercury();
|
||||
|
||||
for (File file : project.getConfigurations().getByName(Constants.MINECRAFT_DEPENDENCIES).getFiles()) {
|
||||
for (File file : project.getConfigurations().getByName(Constants.Configurations.MINECRAFT_DEPENDENCIES).getFiles()) {
|
||||
m.getClassPath().add(file.toPath());
|
||||
}
|
||||
|
||||
|
|
|
@ -72,10 +72,10 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
|||
try {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
Map<String, String> args = new HashMap<String, String>() {{
|
||||
put("inMapFileNamedIntermediary", extension.getMappingsProvider().tinyMappings.getCanonicalPath());
|
||||
put("outMapFileNamedIntermediary", extension.getNextMixinMappings().getCanonicalPath());
|
||||
put("outRefMapFile", getRefmapDestination(task, extension));
|
||||
put("defaultObfuscationEnv", "named:intermediary");
|
||||
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, extension.getMappingsProvider().tinyMappings.getCanonicalPath());
|
||||
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, extension.getNextMixinMappings().getCanonicalPath());
|
||||
put(Constants.MixinArguments.OUT_REFMAP_FILE, getRefmapDestination(task, extension));
|
||||
put(Constants.MixinArguments.DEFAULT_OBFUSCATION_ENV, "named:intermediary");
|
||||
}};
|
||||
|
||||
project.getLogger().debug("Outputting refmap to dir: " + getDestinationDir(task) + " for compile task: " + task);
|
||||
|
@ -94,14 +94,14 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
|||
project.getLogger().info("Adding mixin to classpath of AP config: " + processorConfig.getName());
|
||||
// Pass named MC classpath to mixin AP classpath
|
||||
processorConfig.extendsFrom(
|
||||
configs.getByName(Constants.MINECRAFT_NAMED),
|
||||
configs.getByName(Constants.MOD_COMPILE_CLASSPATH_MAPPED),
|
||||
configs.getByName(Constants.MAPPINGS_FINAL)
|
||||
configs.getByName(Constants.Configurations.MINECRAFT_NAMED),
|
||||
configs.getByName(Constants.Configurations.MOD_COMPILE_CLASSPATH_MAPPED),
|
||||
configs.getByName(Constants.Configurations.MAPPINGS_FINAL)
|
||||
);
|
||||
|
||||
// Add Mixin and mixin extensions (fabric-mixin-compile-extensions pulls mixin itself too)
|
||||
project.getDependencies().add(processorConfig.getName(),
|
||||
"net.fabricmc:fabric-mixin-compile-extensions:" + Constants.MIXIN_COMPILE_EXTENSIONS_VERSION);
|
||||
Constants.Dependencies.MIXIN_COMPILE_EXTENSIONS + Constants.Dependencies.Versions.MIXIN_COMPILE_EXTENSIONS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue