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/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java index 72b20fa06b461d89f0eeff7b2fbbbe89bae0027c..1e8720e1bf492e2cf1a1638071514e62ac66391d 100644 --- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java +++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java @@ -46,6 +46,7 @@ public class LibraryLoader private final RepositorySystem repository; private final DefaultRepositorySystemSession session; private final List repositories; + private final String repositoryAddress = System.getProperty("Leaf.library-download-repo") != null ? System.getProperty("Leaf.library-download-repo") : "https://repo.maven.apache.org/maven2"; // Leaf - Configurable maven repos public static java.util.function.BiFunction LIBRARY_LOADER_FACTORY; // Paper - rewrite reflection in libraries public static java.util.function.Function, List> REMAPPER; // Paper - remap libraries @@ -79,7 +80,17 @@ 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( new RemoteRepository.Builder( "central", "default", repositoryAddress ).build() ) ); + /* // 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