From a04a05bf12c38acf538e3daa13fd86cffca92550 Mon Sep 17 00:00:00 2001 From: Richard Willis Date: Sat, 3 Oct 2020 16:04:41 +0100 Subject: [PATCH] Add runBuild to extension API (#706) * Fix compat checks * Expose runBuild public API --- extension/src/api/Api.ts | 33 +++++++++++++++++++++++++-------- extension/src/compat.ts | 10 ++++------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/extension/src/api/Api.ts b/extension/src/api/Api.ts index b8fb3cd83..6fdedffdb 100644 --- a/extension/src/api/Api.ts +++ b/extension/src/api/Api.ts @@ -4,8 +4,11 @@ import { Logger, logger } from '../logger'; import { GradleTasksTreeDataProvider } from '../views'; import { GradleTaskDefinition } from '../tasks'; import { GradleClient } from '../client'; -import { getRunTaskCommandCancellationKey } from '../client/CancellationKeys'; import { Icons } from '../icons'; +import { + getRunBuildCancellationKey, + getRunTaskCommandCancellationKey, +} from '../client/CancellationKeys'; export interface RunTaskOpts { projectFolder: string; @@ -16,6 +19,14 @@ export interface RunTaskOpts { showOutputColors: boolean; } +export interface RunBuildOpts { + projectFolder: string; + args: ReadonlyArray; + input?: string; + onOutput?: (output: Output) => void; + showOutputColors: boolean; +} + export interface CancelTaskOpts { projectFolder: string; taskName: string; @@ -29,19 +40,25 @@ export class Api { ) {} public async runTask(opts: RunTaskOpts): Promise { + const taskArgs = (opts.args || []).filter(Boolean); const task = await this.findTask(opts.projectFolder, opts.taskName); - const definition = task.definition as GradleTaskDefinition; - const buildArgs = [definition.script] - .concat(opts.args || []) - .filter(Boolean); - const cancellationKey = getRunTaskCommandCancellationKey( + const runBuildArgs = [opts.taskName].concat(taskArgs); + const runBuildOpts = { + ...opts, + args: runBuildArgs, + }; + return this.runBuild(runBuildOpts, task); + } + + public async runBuild(opts: RunBuildOpts, task?: vscode.Task): Promise { + const cancellationKey = getRunBuildCancellationKey( opts.projectFolder, - opts.taskName + opts.args ); return this.client.runBuild( opts.projectFolder, cancellationKey, - buildArgs, + opts.args, opts.input, 0, task, diff --git a/extension/src/compat.ts b/extension/src/compat.ts index 721bca048..50153d3b4 100644 --- a/extension/src/compat.ts +++ b/extension/src/compat.ts @@ -2,21 +2,19 @@ import * as vscode from 'vscode'; export const JAVA_LANGUAGE_EXTENSION_ID = 'redhat.java'; export const JAVA_DEBUGGER_EXTENSION_ID = 'vscjava.vscode-java-debug'; -export const JAVA_CONFIGURATION_UPDATE_COMMAND = - 'java.projectConfiguration.update'; export function isJavaLanguageSupportExtensionActivated(): boolean { const javaExt: | vscode.Extension - | undefined = getJavaDebuggerExtension(); - return !!javaExt && javaExt.isActive; + | undefined = getJavaLanguageSupportExtension(); + return javaExt?.isActive || false; } export function isJavaDebuggerExtensionActivated(): boolean { const javaExt: | vscode.Extension - | undefined = getJavaLanguageSupportExtension(); - return !!javaExt && javaExt.isActive; + | undefined = getJavaDebuggerExtension(); + return javaExt?.isActive || false; } export function getJavaLanguageSupportExtension():