mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2024-11-27 06:10:08 +08:00
parent
0a17aad9d6
commit
99c3ef8a57
@ -21,10 +21,10 @@ package org.jackhuang.hmcl.download.java;
|
||||
* @author Glavo
|
||||
*/
|
||||
public enum JavaPackageType {
|
||||
JDK(true, false),
|
||||
JRE(false, false),
|
||||
JDKFX(true, true),
|
||||
JREFX(false, true);
|
||||
JDK(true, false),
|
||||
JREFX(false, true),
|
||||
JDKFX(true, true);
|
||||
|
||||
private final boolean jdk;
|
||||
private final boolean javafx;
|
||||
|
@ -46,22 +46,27 @@ public final class DiscoFetchJavaListTask extends Task<TreeMap<Integer, DiscoJav
|
||||
}
|
||||
|
||||
private final DiscoJavaDistribution distribution;
|
||||
private final String packageType;
|
||||
private final boolean isJavaFXBundled;
|
||||
private final String archiveType;
|
||||
private final Task<String> fetchPackagesTask;
|
||||
|
||||
public DiscoFetchJavaListTask(DownloadProvider downloadProvider, DiscoJavaDistribution distribution, Platform platform, JavaPackageType packageType) {
|
||||
this.distribution = distribution;
|
||||
this.packageType = packageType.isJDK() ? "jdk" : "jre";
|
||||
this.isJavaFXBundled = packageType.isJavaFXBundled();
|
||||
this.archiveType = platform.getOperatingSystem() == OperatingSystem.WINDOWS ? "zip" : "tar.gz";
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("distribution", distribution.getApiParameter());
|
||||
params.put("package", packageType.isJDK() ? "jdk" : "jre");
|
||||
params.put("javafx_bundled", Boolean.toString(packageType.isJavaFXBundled()));
|
||||
params.put("package", this.packageType);
|
||||
params.put("javafx_bundled", Boolean.toString(isJavaFXBundled));
|
||||
params.put("operating_system", getOperatingSystemName(platform.getOperatingSystem()));
|
||||
params.put("architecture", getArchitectureName(platform.getArchitecture()));
|
||||
params.put("archive_type", platform.getOperatingSystem() == OperatingSystem.WINDOWS ? "zip" : "tar.gz");
|
||||
params.put("archive_type", archiveType);
|
||||
params.put("directly_downloadable", "true");
|
||||
if (platform.getOperatingSystem() == OperatingSystem.LINUX) {
|
||||
if (platform.getOperatingSystem() == OperatingSystem.LINUX)
|
||||
params.put("lib_c_type", "glibc");
|
||||
}
|
||||
|
||||
this.fetchPackagesTask = new GetTask(downloadProvider.injectURLWithCandidates(NetworkUtils.withQuery(API_ROOT + "/packages", params)));
|
||||
}
|
||||
@ -79,6 +84,13 @@ public final class DiscoFetchJavaListTask extends Task<TreeMap<Integer, DiscoJav
|
||||
TreeMap<Integer, DiscoJavaRemoteVersion> map = new TreeMap<>();
|
||||
|
||||
for (DiscoJavaRemoteVersion version : result) {
|
||||
if (!distribution.getApiParameter().equals(version.getDistribution())
|
||||
|| !version.isDirectlyDownloadable()
|
||||
|| !packageType.equals(version.getPackageType())
|
||||
|| !archiveType.equals(version.getArchiveType())
|
||||
|| isJavaFXBundled != version.isJavaFXBundled())
|
||||
continue;
|
||||
|
||||
if (!distribution.testVersion(version))
|
||||
continue;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public enum DiscoJavaDistribution implements JavaDistribution<DiscoJavaRemoteVer
|
||||
pair(WINDOWS, EnumSet.of(X86_64, X86, ARM64)),
|
||||
pair(LINUX, EnumSet.of(X86_64, X86, ARM64, ARM32, RISCV64, PPC64, PPC64LE, S390X, SPARCV9)),
|
||||
pair(OSX, EnumSet.of(X86_64, ARM64))),
|
||||
LIBERICA("Liberica", "liberica", "BellSoft",
|
||||
LIBERICA("BellSoft Liberica", "liberica", "BellSoft",
|
||||
EnumSet.of(JDK, JRE, JDKFX, JREFX),
|
||||
pair(WINDOWS, EnumSet.of(X86_64, X86, ARM64)),
|
||||
pair(LINUX, EnumSet.of(X86_64, X86, ARM64, ARM32, RISCV64, PPC64LE)),
|
||||
@ -57,12 +57,12 @@ public enum DiscoJavaDistribution implements JavaDistribution<DiscoJavaRemoteVer
|
||||
return !fileName.endsWith("-lite.tar.gz") && !fileName.endsWith("-lite.zip");
|
||||
}
|
||||
},
|
||||
ZULU("Zulu", "zulu", "Azul",
|
||||
ZULU("Azul Zulu", "zulu", "Azul",
|
||||
EnumSet.of(JDK, JRE, JDKFX, JREFX),
|
||||
pair(WINDOWS, EnumSet.of(X86_64, X86, ARM64)),
|
||||
pair(LINUX, EnumSet.of(X86_64, X86, ARM64, ARM32, RISCV64, PPC64LE)),
|
||||
pair(OSX, EnumSet.of(X86_64, ARM64))),
|
||||
GRAALVM("GraalVM", "graalvm", "Oracle",
|
||||
GRAALVM("Oracle GraalVM", "graalvm", "Oracle",
|
||||
EnumSet.of(JDK),
|
||||
pair(WINDOWS, EnumSet.of(X86_64)),
|
||||
pair(LINUX, EnumSet.of(X86_64, ARM64)),
|
||||
@ -72,6 +72,12 @@ public enum DiscoJavaDistribution implements JavaDistribution<DiscoJavaRemoteVer
|
||||
pair(WINDOWS, EnumSet.of(X86_64)),
|
||||
pair(LINUX, EnumSet.of(X86_64, ARM64, PPC64LE, S390X)),
|
||||
pair(OSX, EnumSet.of(X86_64, ARM64))
|
||||
),
|
||||
CORRETTO("Amazon Corretto", "corretto", "Amazon",
|
||||
EnumSet.of(JDK),
|
||||
pair(WINDOWS, EnumSet.of(X86_64)),
|
||||
pair(LINUX, EnumSet.of(X86_64, ARM64)),
|
||||
pair(OSX, EnumSet.of(X86_64, ARM64))
|
||||
);
|
||||
|
||||
public static DiscoJavaDistribution of(String name) {
|
||||
|
@ -191,7 +191,7 @@ public final class DiscoJavaRemoteVersion implements JavaRemoteVersion {
|
||||
return packageType;
|
||||
}
|
||||
|
||||
public boolean isJavafxBundled() {
|
||||
public boolean isJavaFXBundled() {
|
||||
return javafxBundled;
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,7 @@ public final class JavaInfo {
|
||||
return "Azul";
|
||||
case "IBM Corporation":
|
||||
case "International Business Machines Corporation":
|
||||
case "Eclipse OpenJ9":
|
||||
return "IBM";
|
||||
case "Eclipse Adoptium":
|
||||
return "Adoptium";
|
||||
|
Loading…
Reference in New Issue
Block a user