UNPKG

3.16 kBTypeScriptView Raw
1import { Platform } from "@xmcl/core";
2import { Task } from "@xmcl/task";
3import { DownloadTask } from "./downloadTask";
4import { DownloadBaseOptions } from "./http/download";
5export interface JavaInfo {
6 /**
7 * Full java executable path
8 */
9 path: string;
10 /**
11 * Java version string
12 */
13 version: string;
14 /**
15 * Major version of java
16 */
17 majorVersion: number;
18}
19export interface InstallJavaOptions extends DownloadBaseOptions {
20 /**
21 * The destination of this installation
22 */
23 destination: string;
24 /**
25 * The cached directory which compressed java lzma will be download to.
26 * @default os.tempdir()
27 */
28 cacheDir?: string;
29 /**
30 * The platform to install. It will be auto-resolved by default.
31 * @default currentPlatform
32 */
33 platform?: Platform;
34 /**
35 * Unpack lzma function. It must present, else it will not be able to unpack mojang provided LZMA.
36 */
37 unpackLZMA: UnpackLZMAFunction;
38}
39export declare type UnpackLZMAFunction = ((src: string, dest: string) => Promise<void>) | ((src: string, dest: string) => Task<void>);
40export declare class DownloadJRETask extends DownloadTask {
41 constructor(jre: DownloadInfo, dir: string, options: InstallJavaOptions);
42}
43interface DownloadInfo {
44 sha1: string;
45 url: string;
46 version: string;
47}
48/**
49 * Install JRE from Mojang offical resource. It should install jdk 8.
50 * @param options The install options
51 */
52export declare function installJreFromMojangTask(options: InstallJavaOptions): import("@xmcl/task").TaskRoutine<void>;
53/**
54 * Install JRE from Mojang offical resource. It should install jdk 8.
55 * @param options The install options
56 */
57export declare function installJreFromMojang(options: InstallJavaOptions): Promise<void>;
58/**
59 * Try to resolve a java info at this path. This will call `java -version`
60 * @param path The java exectuable path.
61 */
62export declare function resolveJava(path: string): Promise<JavaInfo | undefined>;
63/**
64 * Parse version string and major version number from stderr of java process.
65 *
66 * @param versionText The stderr for `java -version`
67 */
68export declare function parseJavaVersion(versionText: string): {
69 version: string;
70 majorVersion: number;
71} | undefined;
72/**
73 * Get all potential java locations for Minecraft.
74 *
75 * On mac/linux, it will perform `which java`. On win32, it will perform `where java`
76 *
77 * @returns The absolute java locations path
78 */
79export declare function getPotentialJavaLocations(): Promise<string[]>;
80/**
81 * Scan local java version on the disk.
82 *
83 * It will check if the passed `locations` are the home of java.
84 * Notice that the locations should not be the executable, but the path of java installation, like JAVA_HOME.
85 *
86 * This will call `getPotentialJavaLocations` and then `resolveJava`
87 *
88 * @param locations The location (like java_home) want to check.
89 * @returns All validate java info
90 */
91export declare function scanLocalJava(locations: string[]): Promise<JavaInfo[]>;
92export {};
93//# sourceMappingURL=java.d.ts.map
\No newline at end of file