9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-api/paper-patches/features/0017-Configurable-LibraryLoader-maven-repos.patch
Dreeam 5ef030ab1e [ci skip] Updated Upstream (Paper/Purpur)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@39203a65 [ci/skip] Publish PR API and dev bundles (#12672)
PaperMC/Paper@a1b30587 Provide env environment variable and copy spigots sys prop for overriding default repository

Purpur Changes:
PurpurMC/Purpur@b1d412fb Updated Upstream (Paper)
PurpurMC/Purpur@293e28a0 use empty registryaccess where context is not needed, closes #1676
PurpurMC/Purpur@452bb319 port PaperMC/Paper#12654, closes #1665
PurpurMC/Purpur@849bc79c register test subcommands used for debugging, closes #1675
PurpurMC/Purpur@61d7f559 Updated Upstream (Paper)
2025-06-21 11:04:38 +08:00

79 lines
4.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sat, 3 Feb 2024 18:45:53 -0500
Subject: [PATCH] Configurable LibraryLoader maven repos
TODO - Dreeam: Support multi maven repos for lib downloading.
Add JVM flag `-DLeaf.library-download-repo=link` to choose library download repo link.
e.g. `-DLeaf.library-download-repo=https://maven.aliyun.com/repository/public`
diff --git a/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java b/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
index 107705db2d82b7c191e5e625ec888e0bc3b03831..77a58fc7c173b1724d44b0eeaf23b4a1b22b5fcb 100644
--- a/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
+++ b/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
@@ -105,7 +105,7 @@ public class MavenLibraryResolver implements ClassPathLibrary {
* dependencies from
*/
public void addRepository(final RemoteRepository remoteRepository) {
- this.repositories.add(remoteRepository);
+ this.repositories.add(org.dreeam.leaf.plugin.loader.MavenCentralMirror.getCentralRepo(remoteRepository)); // Leaf - Configurable LibraryLoader maven repos
}
/**
diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
index 23e3fcc8c2d6e0555448295199eee186de619042..502c51b3ae0a05569540c09b4c51dad1438da36e 100644
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
@@ -88,7 +88,19 @@ public class LibraryLoader {
session.setSystemProperties(System.getProperties());
session.setReadOnly();
- this.repositories = repository.newResolutionRepositories(session, getRepositories());
+ // Leaf start - Configurable LibraryLoader maven repos
+ this.repositories = repository.newResolutionRepositories(
+ session,
+ List.of(org.dreeam.leaf.plugin.loader.MavenCentralMirror.getCentralRepo("https://repo.maven.apache.org/maven2"))
+ );
+ /* // Dreeam TODO
+ this.repositories = repository.newResolutionRepositories(session, List.of(
+ new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build(),
+ new RemoteRepository.Builder("aliyun", "default", "https://maven.aliyun.com/repository/public").build(),
+ new RemoteRepository.Builder("tencentclound", "default", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public/").build(),
+ new RemoteRepository.Builder("huaweicloud", "default", "https://repo.huaweicloud.com/repository/maven/").build()
+ ));*/
+ // Leaf end - Configurable LibraryLoader maven repos
}
@Nullable
diff --git a/src/main/java/org/dreeam/leaf/plugin/loader/MavenCentralMirror.java b/src/main/java/org/dreeam/leaf/plugin/loader/MavenCentralMirror.java
new file mode 100644
index 0000000000000000000000000000000000000000..95534cb6d771a0fe288e7c843c41b0036bdc7095
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/plugin/loader/MavenCentralMirror.java
@@ -0,0 +1,24 @@
+package org.dreeam.leaf.plugin.loader;
+
+import org.eclipse.aether.repository.RemoteRepository;
+
+public class MavenCentralMirror {
+
+ public static final String MAVEN_CENTRAL_MIRROR_REPO = System.getProperty("Leaf.library-download-repo");
+
+ public static RemoteRepository getCentralRepo(RemoteRepository repo) {
+ if (MAVEN_CENTRAL_MIRROR_REPO != null && repo.getUrl().contains("repo.maven.apache.org/maven2")) {
+ repo = new RemoteRepository.Builder("central", "default", MAVEN_CENTRAL_MIRROR_REPO).build();
+ }
+
+ return repo;
+ }
+
+ public static RemoteRepository getCentralRepo(String repo) {
+ if (MAVEN_CENTRAL_MIRROR_REPO != null) {
+ repo = MAVEN_CENTRAL_MIRROR_REPO;
+ }
+
+ return new RemoteRepository.Builder("central", "default", repo).build();
+ }
+}