测试上传

This commit is contained in:
坏黑
2018-04-07 21:53:09 +08:00
parent d8f8ffc5a3
commit b22ade7cff
9 changed files with 82 additions and 66 deletions

View File

@@ -40,20 +40,30 @@ public class TDependency {
if (file.exists()) {
TDependencyLoader.addToPath(Main.getInst(), file);
return true;
} else if (downloadMaven(repo, arr[0], arr[1], arr[2], file, url)) {
TDependencyLoader.addToPath(Main.getInst(), file);
return true;
} else return false;
} else {
boolean downloadFinish = false;
try {
downloadFinish = downloadMaven(repo, arr[0], arr[1], arr[2], file, url);
} catch (Exception ignored) {
}
if (downloadFinish) {
TDependencyLoader.addToPath(Main.getInst(), file);
}
return downloadFinish;
}
}
return false;
}
private static boolean downloadMaven(String url, String groupId, String artifactId, String version, File target, String dl) {
if (Main.getInst().getConfig().getBoolean("OFFLINE-MODE")) {
TLib.getTLib().getLogger().warn("已启用离线模式, 将不会下载第三方依赖库");
return false;
}
ReentrantLock lock = new ReentrantLock();
AtomicBoolean failed = new AtomicBoolean(false);
EagletTask task = new EagletTask()
.url(dl == null ? url + "/" + groupId.replace('.', '/') + "/" +
artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar" : dl)
.url(dl == null ? url + "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar" : dl)
.file(target)
.setThreads(TLib.getTLib().getConfig().getDownloadPoolSize())
.setOnStart(event -> lock.lock())