mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
79 lines
4.2 KiB
Diff
79 lines
4.2 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 cfe41c0a67c8d729b6bd23b0cfa32db3c9db9f74..9f167a9cb4a93a79b8ed709b61214ce0138a875d 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
|
@@ -74,7 +74,19 @@ public class LibraryLoader {
|
|
session.setSystemProperties(System.getProperties());
|
|
session.setReadOnly();
|
|
|
|
- this.repositories = repository.newResolutionRepositories(session, Arrays.asList(new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build()));
|
|
+ // 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();
|
|
+ }
|
|
+}
|