mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
79 lines
4.1 KiB
Diff
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..81d7b0d1a9f5e1f6e55e0d6a61ce1433825ef414 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 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 211c093ce2253e918cd40725ebf1ef172d1b9bdf..5acd7cd09e9bdc26de443d166b193e163aae0188 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
|
@@ -79,7 +79,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 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 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();
|
|
+ }
|
|
+}
|