mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-31 04:46:38 +00:00
Better warning message for discouraging Maven Central as CDN
This commit is contained in:
@@ -7,7 +7,7 @@ Add JVM flag `-DLeaf.library-download-repo=link` to choose library download repo
|
||||
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 b0069a05c322e058f0df668908f0918c0b85a814..b899e9cbb2658c7f08343b2e6500fb34427fc238 100644
|
||||
index 6e0be8c43502aece01371554c3ff60cb97f12944..ab239c0ea1b63b6b8455f11b4c7ec089969c049f 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
|
||||
@@ -59,12 +59,25 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||
@@ -38,16 +38,11 @@ index b0069a05c322e058f0df668908f0918c0b85a814..b899e9cbb2658c7f08343b2e6500fb34
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("MavenLibraryResolver");
|
||||
|
||||
private final RepositorySystem repository;
|
||||
@@ -120,15 +133,34 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||
@@ -120,12 +133,33 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||
* dependencies from
|
||||
*/
|
||||
public void addRepository(final RemoteRepository remoteRepository) {
|
||||
- if (MAVEN_CENTRAL_URLS.stream().anyMatch(remoteRepository.getUrl()::startsWith)) {
|
||||
- // Leaf start - Use warning instead of direct throw
|
||||
- try {
|
||||
- throw new RuntimeException("Plugin used Maven Central for library resolution");
|
||||
- } catch (RuntimeException e) {
|
||||
- LOGGER.error("Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead. Please contact plugin's support for help.", e);
|
||||
+ // Leaf start - Configurable LibraryLoader maven repos
|
||||
+ for (String url : MAVEN_CENTRAL_URLS) {
|
||||
+ if (remoteRepository.getUrl().startsWith(url)) {
|
||||
@@ -56,16 +51,14 @@ index b0069a05c322e058f0df668908f0918c0b85a814..b899e9cbb2658c7f08343b2e6500fb34
|
||||
+ this.repositories.add(mirrorRepo);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf start - Use warning instead of direct throw
|
||||
+ try {
|
||||
+ throw new RuntimeException("Plugin used Maven Central for library resolution");
|
||||
+ } catch (RuntimeException e) {
|
||||
+ LOGGER.error("Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead. Please contact plugin's support for help.", e);
|
||||
+ }
|
||||
+ // Leaf end - Use warning instead of direct throw
|
||||
}
|
||||
- // Leaf end - Use warning instead of direct throw
|
||||
}
|
||||
+ // Leaf end - Configurable LibraryLoader maven repos
|
||||
LOGGER.warn(
|
||||
"Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead. DO NOT report it to Paper or Leaf! Please contact plugin's support to adapt this change.", // Leaf - Better warning message for discouraging Maven Central as CDN
|
||||
new RuntimeException("Plugin used Maven Central for library resolution")
|
||||
);
|
||||
+ // Leaf start - Configurable LibraryLoader maven repos
|
||||
+ }
|
||||
+ }
|
||||
+ // Match google api maven central mirror urls
|
||||
+ for (String url : MAVEN_CENTRAL_GOOGLE_MIRROR_URLS) {
|
||||
+ if (remoteRepository.getUrl().startsWith(url)) {
|
||||
@@ -75,12 +68,12 @@ index b0069a05c322e058f0df668908f0918c0b85a814..b899e9cbb2658c7f08343b2e6500fb34
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ // Leaf end - Configurable LibraryLoader maven repos
|
||||
this.repositories.add(remoteRepository);
|
||||
}
|
||||
|
||||
@@ -165,4 +197,15 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||
@@ -162,4 +196,15 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||
}
|
||||
return central;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user