Fix applying mods to server libraries.

This commit is contained in:
modmuss50
2023-04-18 14:27:54 +01:00
parent 89d09600c5
commit b35753476c

View File

@@ -125,35 +125,28 @@ public class MinecraftLibraryProvider {
private void applyClientLibrary(Library library) {
switch (library.target()) {
case COMPILE -> {
addLibrary(Constants.Configurations.MINECRAFT_CLIENT_COMPILE_LIBRARIES, library);
}
case RUNTIME -> {
addLibrary(Constants.Configurations.MINECRAFT_CLIENT_RUNTIME_LIBRARIES, library);
}
case NATIVES -> {
addLibrary(Constants.Configurations.MINECRAFT_NATIVES, library);
}
case LOCAL_MOD -> {
ExternalModuleDependency dependency = (ExternalModuleDependency) project.getDependencies().create(library.mavenNotation());
dependency.setTransitive(false);
project.getDependencies().add("modLocalRuntime", dependency);
}
case COMPILE -> addLibrary(Constants.Configurations.MINECRAFT_CLIENT_COMPILE_LIBRARIES, library);
case RUNTIME -> addLibrary(Constants.Configurations.MINECRAFT_CLIENT_RUNTIME_LIBRARIES, library);
case NATIVES -> addLibrary(Constants.Configurations.MINECRAFT_NATIVES, library);
case LOCAL_MOD -> applyLocalModLibrary(library);
}
}
private void applyServerLibrary(Library library) {
switch (library.target()) {
case COMPILE -> {
addLibrary(Constants.Configurations.MINECRAFT_SERVER_COMPILE_LIBRARIES, library);
}
case RUNTIME -> {
addLibrary(Constants.Configurations.MINECRAFT_SERVER_RUNTIME_LIBRARIES, library);
}
default -> throw new IllegalStateException("Target not supported for server library");
case COMPILE -> addLibrary(Constants.Configurations.MINECRAFT_SERVER_COMPILE_LIBRARIES, library);
case RUNTIME -> addLibrary(Constants.Configurations.MINECRAFT_SERVER_RUNTIME_LIBRARIES, library);
case LOCAL_MOD -> applyLocalModLibrary(library);
default -> throw new IllegalStateException("Target not supported for server library: %s".formatted(library));
}
}
private void applyLocalModLibrary(Library library) {
ExternalModuleDependency dependency = (ExternalModuleDependency) project.getDependencies().create(library.mavenNotation());
dependency.setTransitive(false);
project.getDependencies().add("modLocalRuntime", dependency);
}
private void addLibrary(String configuration, Library library) {
addDependency(configuration, library.mavenNotation());
}