mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Rewrite Minecraft Library handling. (#857)
This PR rewrites the Minecraft library processing with a more structured and testable set of "library processors". The old code is a mess of special cases and work arounds for various issues on various platforms. Previously this was only really used on lesser used platforms/versions so wasnt a major issue if things broke, however current shipping Minecraft versions (1.19.4) use an LWJGL version that does not work well on Java versions new than 19. With this change LWJGL is upgraded when using Java 19 or later. Upgraded libraries are also now only placed on the runtime classpath, this prevents you from using newer library features in your mod.
This commit is contained in:
@@ -109,9 +109,9 @@ public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
});
|
||||
}
|
||||
|
||||
public static void setupForLegacyVersions(Project project) {
|
||||
public static void setupForLegacyVersions(RepositoryHandler repositories) {
|
||||
// 1.4.7 contains an LWJGL version with an invalid maven pom, set the metadata sources to not use the pom for this version.
|
||||
project.getRepositories().named("Mojang", MavenArtifactRepository.class, repo -> {
|
||||
repositories.named("Mojang", MavenArtifactRepository.class, repo -> {
|
||||
repo.metadataSources(sources -> {
|
||||
// Only use the maven artifact and not the pom or gradle metadata.
|
||||
sources.artifact();
|
||||
@@ -120,9 +120,14 @@ public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
});
|
||||
}
|
||||
|
||||
public static void forceLWJGLFromMavenCentral(Project project) {
|
||||
public static void forceLWJGLFromMavenCentral(RepositoryHandler repositories) {
|
||||
if (repositories.findByName("MavenCentralLWJGL") != null) {
|
||||
// Already applied.
|
||||
return;
|
||||
}
|
||||
|
||||
// Force LWJGL from central, as it contains all the platform natives.
|
||||
MavenArtifactRepository central = project.getRepositories().maven(repo -> {
|
||||
MavenArtifactRepository central = repositories.maven(repo -> {
|
||||
repo.setName("MavenCentralLWJGL");
|
||||
repo.setUrl(ArtifactRepositoryContainer.MAVEN_CENTRAL_URL);
|
||||
repo.content(content -> {
|
||||
@@ -130,7 +135,7 @@ public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
});
|
||||
});
|
||||
|
||||
project.getRepositories().exclusiveContent(repository -> {
|
||||
repositories.exclusiveContent(repository -> {
|
||||
repository.forRepositories(central);
|
||||
repository.filter(filter -> {
|
||||
filter.includeGroup("org.lwjgl");
|
||||
|
||||
Reference in New Issue
Block a user