Skip to content

Commit

Permalink
Add runBuild to extension API (#706)
Browse files Browse the repository at this point in the history
* Fix compat checks

* Expose runBuild public API
  • Loading branch information
badsyntax authored Oct 3, 2020
1 parent 7379b10 commit a04a05b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
33 changes: 25 additions & 8 deletions extension/src/api/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +19,14 @@ export interface RunTaskOpts {
showOutputColors: boolean;
}

export interface RunBuildOpts {
projectFolder: string;
args: ReadonlyArray<string>;
input?: string;
onOutput?: (output: Output) => void;
showOutputColors: boolean;
}

export interface CancelTaskOpts {
projectFolder: string;
taskName: string;
Expand All @@ -29,19 +40,25 @@ export class Api {
) {}

public async runTask(opts: RunTaskOpts): Promise<void> {
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<void> {
const cancellationKey = getRunBuildCancellationKey(
opts.projectFolder,
opts.taskName
opts.args
);
return this.client.runBuild(
opts.projectFolder,
cancellationKey,
buildArgs,
opts.args,
opts.input,
0,
task,
Expand Down
10 changes: 4 additions & 6 deletions extension/src/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>
| undefined = getJavaDebuggerExtension();
return !!javaExt && javaExt.isActive;
| undefined = getJavaLanguageSupportExtension();
return javaExt?.isActive || false;
}

export function isJavaDebuggerExtensionActivated(): boolean {
const javaExt:
| vscode.Extension<unknown>
| undefined = getJavaLanguageSupportExtension();
return !!javaExt && javaExt.isActive;
| undefined = getJavaDebuggerExtension();
return javaExt?.isActive || false;
}

export function getJavaLanguageSupportExtension():
Expand Down

0 comments on commit a04a05b

Please sign in to comment.