Skip to content

Commit 13237f9

Browse files
committed
修复 maven 依赖版本获取问题
1 parent c3695ae commit 13237f9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

MiraiMC-Base/src/main/java/me/dreamvoid/miraimc/internal/loader/LibraryLoader.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
import org.w3c.dom.Node;
88
import org.w3c.dom.NodeList;
99
import org.xml.sax.InputSource;
10+
import org.xml.sax.SAXException;
1011

1112
import javax.annotation.Nullable;
1213
import javax.xml.XMLConstants;
1314
import javax.xml.parsers.DocumentBuilderFactory;
15+
import javax.xml.parsers.ParserConfigurationException;
1416
import java.io.*;
1517
import java.net.MalformedURLException;
1618
import java.net.URL;
@@ -147,14 +149,14 @@ public String getLibraryVersion(String groupId, String artifactId, String repo){
147149
@Nullable
148150
private static Document fetchMavenMetadata(String groupId, String artifactId, String repo) {
149151
try {
150-
String content = Utils.Http.get(repo + "/" + groupId.replace(".", "/") + artifactId + "/maven-metadata.xml");
152+
String content = Utils.Http.get(repo + "/" + groupId.replace(".", "/") + "/" + artifactId + "/maven-metadata.xml");
151153
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
152154
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
153155
return factory.newDocumentBuilder().parse(new InputSource(new StringReader(content)));
154-
} catch (Exception e) {
155-
return null;
156-
}
157-
}
156+
} catch (IOException | ParserConfigurationException | SAXException e) {
157+
throw new RuntimeException(e);
158+
}
159+
}
158160

159161
private static String getJarUrl(String groupId, String artifactId, String version, String repo, String archiveSuffix) throws Exception {
160162
if(version.endsWith("-SNAPSHOT")){

0 commit comments

Comments
 (0)