Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,23 @@ private void provideServerLibraries() {
}

private List<Library> processLibraries(List<Library> libraries) {
final LibraryContext libraryContext = new LibraryContext(minecraftProvider.getVersionInfo(), JavaVersion.current());
final LibraryContext libraryContext = new LibraryContext(minecraftProvider.getVersionInfo(), getTargetRuntimeJavaVersion());
return processorManager.processLibraries(libraries, libraryContext);
}

private JavaVersion getTargetRuntimeJavaVersion() {
final Object property = project.findProperty(Constants.Properties.RUNTIME_JAVA_COMPATIBILITY_VERSION);

if (property != null) {
// This is very much a last ditch effort to allow users to set the runtime java version
// It's not recommended and will likely cause support confusion if it has been changed without good reason.
project.getLogger().warn("Runtime java compatibility version has manually been set to: %s".formatted(property));
return JavaVersion.toVersion(property);
}

return JavaVersion.current();
}

private void applyClientLibrary(Library library) {
switch (library.target()) {
case COMPILE -> addLibrary(Constants.Configurations.MINECRAFT_CLIENT_COMPILE_LIBRARIES, library);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/fabricmc/loom/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ public static final class Properties {
public static final String LIBRARY_PROCESSORS = "fabric.loom.libraryProcessors";
@ApiStatus.Experimental
public static final String SANDBOX = "fabric.loom.experimental.sandbox";
/**
* When set the version of java that will be assumed that the game will run on, this defaults to the current java version.
* Only set this when you have a good reason to do so, the default should be fine for almost all cases.
*/
public static final String RUNTIME_JAVA_COMPATIBILITY_VERSION = "fabric.loom.runtimeJavaCompatibilityVersion";
}

public static final class Manifest {
Expand Down