async function setupUnmanagedFolder()

in src/commands/testDependenciesCommands.ts [55:96]


async function setupUnmanagedFolder(projectUri: Uri, testKind?: TestKind): Promise<void> {
    testKind ??= await getTestKind();
    if (testKind === undefined) {
        return;
    }
    const libFolder: string = await getLibFolder(projectUri);
    const libFolderExists: boolean = await fse.pathExists(libFolder);
    if (!libFolderExists) {
        await fse.ensureDir(libFolder);
    }

    try {
        await window.withProgress({
            location: ProgressLocation.Notification,
            cancellable: true
        }, async (progress: Progress<{message?: string; increment?: number}>, token: CancellationToken) => {
            const metadata: IArtifactMetadata[] = getJarIds(testKind!);
            for (const jar of metadata) {
                if (token.isCancellationRequested) {
                    throw new Error('User cancelled');
                }
                progress.report({
                    message: `Downloading ${jar.artifactId}.jar...`,
                });
                if (!jar.version) {
                    jar.version = await getLatestVersion(jar.groupId, jar.artifactId) || jar.defaultVersion;
                }
                await downloadJar(libFolder, jar.groupId, jar.artifactId, jar.version, metadata.length, progress, token);
            }
        });
    } catch (e) {
        if (e?.message !== 'User cancelled') {
            sendError(e);
        }
        if (!libFolderExists) {
            fse.remove(libFolder);
        }
        return;
    }

    updateProjectSettings(projectUri, libFolder);
}