├── .nvmrc ├── extension ├── test-fixtures │ ├── no-gradle │ │ └── .git-keep │ ├── .gitignore │ ├── tool-options-provider-test-extension │ │ ├── .gitignore │ │ ├── .vscodeignore │ │ ├── tsconfig.json │ │ ├── package.json │ │ ├── src │ │ │ └── extension.ts │ │ └── package-lock.json │ ├── vscode-user │ │ └── User │ │ │ └── settings.json │ ├── multi-project │ │ ├── .gitignore │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── subproject-example │ │ │ ├── sub-subproject-example │ │ │ │ └── build.gradle │ │ │ └── build.gradle │ │ ├── settings.gradle.kts │ │ └── build.gradle │ ├── gradle-groovy-custom-build-file │ │ ├── .gitignore │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── settings.gradle │ │ └── my-custom-build.gradle │ ├── gradle-groovy-default-build-file │ │ ├── .gitignore │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── settings.gradle │ │ └── build.gradle │ ├── gradle-kotlin-default-build-file │ │ ├── .gitignore │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── settings.gradle.kts │ │ └── build.gradle.kts │ └── multi-root │ │ └── multiple-project.code-workspace ├── .npmrc ├── src │ ├── api │ │ └── index.ts │ ├── icons │ │ ├── index.ts │ │ └── Icons.ts │ ├── server │ │ ├── index.ts │ │ └── serverUtil.ts │ ├── client │ │ ├── index.ts │ │ ├── CancellationKeys.ts │ │ ├── utils.ts │ │ └── GradleBuildContentProvider.ts │ ├── progress │ │ ├── index.ts │ │ └── ProgressHandler.ts │ ├── rootProject │ │ ├── index.ts │ │ └── RootProject.ts │ ├── terminal │ │ └── index.ts │ ├── test │ │ ├── vscode-version.ts │ │ ├── unit │ │ │ └── index.ts │ │ └── integration │ │ │ ├── gradle │ │ │ └── index.ts │ │ │ ├── multi-root │ │ │ └── index.ts │ │ │ ├── no-gradle │ │ │ ├── index.ts │ │ │ └── extension.test.ts │ │ │ ├── multi-project │ │ │ └── index.ts │ │ │ └── nested-projects │ │ │ └── index.ts │ ├── stores │ │ ├── types.ts │ │ ├── RecentTasksStore.ts │ │ ├── TaskStore.ts │ │ ├── index.ts │ │ ├── EventedStore.ts │ │ ├── TaskTerminalsStore.ts │ │ ├── StoreMapSet.ts │ │ ├── StoreMap.ts │ │ └── PinnedTasksStore.ts │ ├── commands │ │ ├── Command.ts │ │ ├── ShowLogsCommand.ts │ │ ├── CancellingTreeItemTaskCommand.ts │ │ ├── OpenSettingsCommand.ts │ │ ├── LoadTasksCommand.ts │ │ ├── ExplorerFlatCommand.ts │ │ ├── ExplorerTreeCommand.ts │ │ ├── RefreshDaemonStatusCommand.ts │ │ ├── ShowTasksCommand.ts │ │ ├── HideStoppedDaemonsCommand.ts │ │ ├── ShowStoppedDaemonsCommand.ts │ │ ├── ClearAllRecentTasksCommand.ts │ │ ├── CancelBuildCommand.ts │ │ ├── DebugTaskCommand.ts │ │ ├── RemoveRecentTaskCommand.ts │ │ ├── RenderTaskCommand.ts │ │ ├── RestartTaskCommand.ts │ │ ├── UnpinAllTasksCommand.ts │ │ ├── PinTaskCommand.ts │ │ ├── UnpinTaskCommand.ts │ │ ├── RunTaskWithArgsCommand.ts │ │ ├── DebugTaskWithArgsCommand.ts │ │ ├── ReloadJavaProjectsCommand.ts │ │ ├── CloseTaskTerminalsCommand.ts │ │ ├── FindTaskCommand.ts │ │ ├── CloseAllTaskTerminalsCommand.ts │ │ ├── RefreshCommand.ts │ │ ├── PinTaskWithArgsCommand.ts │ │ ├── ShowTaskTerminalCommand.ts │ │ ├── RunTasksCommand.ts │ │ ├── CancelTreeItemTaskCommand.ts │ │ ├── index.ts │ │ ├── OpenBuildFileCommand.ts │ │ ├── StopDaemonCommand.ts │ │ └── RunTaskCommand.ts │ ├── views │ │ ├── gradleDaemons │ │ │ ├── index.ts │ │ │ ├── services │ │ │ │ ├── GradleExecution.ts │ │ │ │ └── GradleLocalInstallation.ts │ │ │ ├── models │ │ │ │ ├── GradleConnectionType.ts │ │ │ │ ├── DaemonStatus.ts │ │ │ │ └── DaemonInfo.ts │ │ │ ├── util.ts │ │ │ └── GradleDaemonTreeItem.ts │ │ ├── index.ts │ │ ├── recentTasks │ │ │ ├── index.ts │ │ │ ├── NoRecentTasksTreeItem.ts │ │ │ └── RecentTasksRootProjectTreeItem.ts │ │ ├── gradleTasks │ │ │ ├── ProjectTreeItem.ts │ │ │ ├── index.ts │ │ │ ├── GroupTreeItem.ts │ │ │ ├── HintItem.ts │ │ │ ├── NoGradleTasksTreeItem.ts │ │ │ ├── RootProjectTreeItem.ts │ │ │ ├── PinnedTasksRootProjectTreeItem.ts │ │ │ ├── ProjectTaskTreeItem.ts │ │ │ ├── DependencyConfigurationTreeItem.ts │ │ │ ├── PinnedTasksTreeItem.ts │ │ │ ├── utils.ts │ │ │ ├── ProjectDependencyTreeItem.ts │ │ │ ├── DependencyTreeItem.ts │ │ │ └── GradleTaskTreeItem.ts │ │ ├── NoTasksTreeItem.ts │ │ ├── defaultProject │ │ │ └── types.ts │ │ └── constants.ts │ ├── tasks │ │ ├── index.ts │ │ ├── GradleTaskDefinition.ts │ │ └── GradleTaskManager.ts │ ├── util │ │ ├── execAsync.ts │ │ ├── telemetryFilter.ts │ │ ├── javaExtension.ts │ │ ├── Deferred.ts │ │ ├── compat.ts │ │ ├── EventWaiter.ts │ │ ├── DoubleClickChecker.ts │ │ └── decorators.ts │ ├── logger │ │ ├── index.ts │ │ └── LoggerSteam.ts │ ├── createProject │ │ ├── utils.ts │ │ └── types.ts │ ├── languageServer │ │ └── utils.ts │ ├── index.ts │ └── bs │ │ └── GradleBuildLinkProvider.ts ├── beta │ ├── icon.png │ ├── package-beta.json │ ├── README.md │ └── prepare.js ├── resources │ ├── icon.png │ ├── icon-transparency.png │ ├── dark │ │ ├── add.svg │ │ ├── list-flat.svg │ │ ├── stop.svg │ │ ├── run.svg │ │ ├── warning.svg │ │ ├── list-tree.svg │ │ ├── console.svg │ │ ├── close.svg │ │ ├── clear-all.svg │ │ ├── circle-outline.svg │ │ ├── refresh.svg │ │ ├── close-all.svg │ │ ├── gear.svg │ │ ├── stop-daemons.svg │ │ ├── circle-filled.svg │ │ └── loading.svg │ └── light │ │ ├── add.svg │ │ ├── list-flat.svg │ │ ├── stop.svg │ │ ├── run.svg │ │ ├── list-tree.svg │ │ ├── console.svg │ │ ├── close.svg │ │ ├── circle-outline.svg │ │ ├── refresh.svg │ │ ├── close-all.svg │ │ ├── gear.svg │ │ ├── clear-all.svg │ │ ├── warning.svg │ │ ├── stop-daemons.svg │ │ ├── circle-filled.svg │ │ └── loading.svg ├── .prettierrc.json ├── .eslintignore ├── jdtls.ext │ ├── com.microsoft.gradle.bs.importer │ │ ├── build.properties │ │ ├── src │ │ │ ├── com │ │ │ │ └── microsoft │ │ │ │ │ ├── gradle │ │ │ │ │ └── bs │ │ │ │ │ │ └── importer │ │ │ │ │ │ ├── model │ │ │ │ │ │ ├── Telemetry.java │ │ │ │ │ │ ├── NamedPipeConnectionException.java │ │ │ │ │ │ └── JavaTestStatus.java │ │ │ │ │ │ ├── BuildServerConnection.java │ │ │ │ │ │ ├── GradleBuildServerProjectNature.java │ │ │ │ │ │ └── jpms │ │ │ │ │ │ └── JpmsArgValue.java │ │ │ │ │ └── java │ │ │ │ │ └── builder │ │ │ │ │ └── jdtbuilder │ │ │ │ │ ├── ICompilationUnitLocator.java │ │ │ │ │ ├── AdditionalTypeCollection.java │ │ │ │ │ ├── MissingSourceFileException.java │ │ │ │ │ ├── AbortIncrementalBuildException.java │ │ │ │ │ └── ProblemFactory.java │ │ │ └── ch │ │ │ │ └── epfl │ │ │ │ └── scala │ │ │ │ └── bsp4j │ │ │ │ └── extended │ │ │ │ └── TestStartEx.java │ │ ├── .classpath │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ ├── .project │ │ └── pom.xml │ ├── .project │ ├── com.microsoft.gradle.bs.importer.target │ │ ├── .project │ │ └── pom.xml │ └── .mvn │ │ └── wrapper │ │ └── maven-wrapper.properties ├── .prettierignore ├── .gitignore ├── .vscodeignore ├── gradle-language-configuration.json ├── .eslintrc.js ├── scripts │ └── prepare-nightly-build.js ├── tsconfig.json └── syntaxes │ └── GradleBuild.tmLanguage.json ├── .github ├── CODEOWNERS ├── auto_assign-issues.yml └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── npm-package ├── .npmrc ├── .prettierignore ├── README.md ├── .eslintignore ├── .prettierrc.json ├── .eslintrc.json ├── tsconfig.json ├── index.ts ├── .gitignore ├── .npmignore └── package.json ├── images ├── error.jpg ├── output.png ├── pin-task.png ├── task-run.png ├── run-build.png ├── task-output.png ├── unpin-task.png ├── debug-output.png ├── dependencies.png ├── highlighting.gif ├── no-connection.png ├── recent-tasks.png ├── auto-completion.gif ├── debug-screencast.gif ├── document-outline.gif ├── gradle-daemons.png ├── gradle-tasks-view.png ├── reuse-terminals-all.gif ├── reuse-terminals-off.gif └── reuse-terminals-task.gif ├── gradle-language-server ├── test-resources │ ├── spring-boot-webapp │ │ ├── app │ │ │ ├── src │ │ │ │ ├── main │ │ │ │ │ ├── resources │ │ │ │ │ │ └── application.properties │ │ │ │ │ └── java │ │ │ │ │ │ └── org │ │ │ │ │ │ └── gradle │ │ │ │ │ │ └── samples │ │ │ │ │ │ └── SpringBootDemoApplication.java │ │ │ │ └── test │ │ │ │ │ └── java │ │ │ │ │ └── org │ │ │ │ │ └── gradle │ │ │ │ │ └── samples │ │ │ │ │ └── SpringBootDemoApplicationTests.java │ │ │ ├── HELP.md │ │ │ └── build.gradle │ │ ├── settings.gradle │ │ └── gradle │ │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── diagnostics-classpath │ │ ├── build.gradle │ │ └── classpath.jar │ └── diagnostics │ │ └── build.gradle ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── microsoft │ │ │ └── gradle │ │ │ ├── resolver │ │ │ ├── GradleField.java │ │ │ ├── GradleClosure.java │ │ │ └── GradleMethod.java │ │ │ ├── semantictokens │ │ │ ├── TokenType.java │ │ │ └── TokenModifier.java │ │ │ ├── compile │ │ │ └── GradleCompilationUnit.java │ │ │ └── handlers │ │ │ └── DefaultDependenciesHandler.java │ └── test │ │ └── java │ │ └── com │ │ └── microsoft │ │ └── gradle │ │ └── GradleTestConstants.java └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── javaConfig.json ├── .gitattributes ├── gradle-plugin-api ├── src │ └── main │ │ └── java │ │ └── com │ │ └── microsoft │ │ └── gradle │ │ └── api │ │ ├── GradleDependencyType.java │ │ ├── GradleField.java │ │ ├── GradleMethod.java │ │ ├── GradleClosure.java │ │ ├── GradleDependencyNode.java │ │ ├── GradleTask.java │ │ ├── GradleModelAction.java │ │ └── GradleProjectModel.java └── build.gradle ├── gradle-server └── src │ └── main │ ├── resources │ └── simplelogger.properties │ └── java │ └── com │ └── github │ └── badsyntax │ └── gradle │ ├── GradleProjectConnectionType.java │ ├── ByteBufferOutputStream.java │ ├── exceptions │ ├── GradleBuildRunnerException.java │ └── GradleCancellationException.java │ ├── ErrorMessageBuilder.java │ ├── BuildServerThread.java │ └── handlers │ ├── CancelBuildsHandler.java │ └── CancelBuildHandler.java ├── .vscode ├── extensions.json ├── tasks.json └── settings.json ├── settings.gradle ├── .editorconfig ├── .gitignore ├── gradle-plugin ├── src │ └── main │ │ └── java │ │ └── com │ │ └── microsoft │ │ └── gradle │ │ ├── DefaultGradleField.java │ │ ├── GradlePlugin.java │ │ ├── DefaultGradleMethod.java │ │ ├── DefaultGradleClosure.java │ │ ├── DefaultGradleDependencyNode.java │ │ └── DefaultGradleTask.java └── build.gradle ├── API.md └── LICENSE.md /.nvmrc: -------------------------------------------------------------------------------- 1 | 18.20.4 2 | -------------------------------------------------------------------------------- /extension/test-fixtures/no-gradle/.git-keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /extension/.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ -------------------------------------------------------------------------------- /extension/src/api/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Api"; 2 | -------------------------------------------------------------------------------- /extension/src/icons/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Icons"; 2 | -------------------------------------------------------------------------------- /extension/test-fixtures/.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | .vscode/ 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @chagong @testforstephen @wenytang-ms 2 | -------------------------------------------------------------------------------- /npm-package/.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /extension/src/server/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./GradleServer"; 2 | -------------------------------------------------------------------------------- /npm-package/.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /extension/src/client/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./TaskServerClient"; 2 | -------------------------------------------------------------------------------- /extension/src/progress/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ProgressHandler"; 2 | -------------------------------------------------------------------------------- /extension/src/rootProject/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./RootProject"; 2 | -------------------------------------------------------------------------------- /extension/src/terminal/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./GradleRunnerTerminal"; 2 | -------------------------------------------------------------------------------- /extension/src/test/vscode-version.ts: -------------------------------------------------------------------------------- 1 | export const VSCODE_TEST_VERSIONS = []; 2 | -------------------------------------------------------------------------------- /npm-package/README.md: -------------------------------------------------------------------------------- 1 | # vscode-gradle 2 | 3 | Type definitions for vscode-gradle. 4 | -------------------------------------------------------------------------------- /images/error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/error.jpg -------------------------------------------------------------------------------- /images/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/output.png -------------------------------------------------------------------------------- /extension/src/stores/types.ts: -------------------------------------------------------------------------------- 1 | export type TaskId = string; 2 | export type TaskArgs = string; 3 | -------------------------------------------------------------------------------- /extension/test-fixtures/tool-options-provider-test-extension/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /images/pin-task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/pin-task.png -------------------------------------------------------------------------------- /images/task-run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/task-run.png -------------------------------------------------------------------------------- /images/run-build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/run-build.png -------------------------------------------------------------------------------- /images/task-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/task-output.png -------------------------------------------------------------------------------- /images/unpin-task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/unpin-task.png -------------------------------------------------------------------------------- /extension/beta/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/extension/beta/icon.png -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/app/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /images/debug-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/debug-output.png -------------------------------------------------------------------------------- /images/dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/dependencies.png -------------------------------------------------------------------------------- /images/highlighting.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/highlighting.gif -------------------------------------------------------------------------------- /images/no-connection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/no-connection.png -------------------------------------------------------------------------------- /images/recent-tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/recent-tasks.png -------------------------------------------------------------------------------- /images/auto-completion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/auto-completion.gif -------------------------------------------------------------------------------- /images/debug-screencast.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/debug-screencast.gif -------------------------------------------------------------------------------- /images/document-outline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/document-outline.gif -------------------------------------------------------------------------------- /images/gradle-daemons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/gradle-daemons.png -------------------------------------------------------------------------------- /npm-package/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | **/*.ts 4 | **/*.js 5 | !/*.ts 6 | /*.d.ts 7 | -------------------------------------------------------------------------------- /npm-package/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "tabWidth": 2, 4 | "printWidth": 80 5 | } 6 | -------------------------------------------------------------------------------- /extension/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/extension/resources/icon.png -------------------------------------------------------------------------------- /images/gradle-tasks-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/gradle-tasks-view.png -------------------------------------------------------------------------------- /images/reuse-terminals-all.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/reuse-terminals-all.gif -------------------------------------------------------------------------------- /images/reuse-terminals-off.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/reuse-terminals-off.gif -------------------------------------------------------------------------------- /images/reuse-terminals-task.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/images/reuse-terminals-task.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /extension/test-fixtures/vscode-user/User/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "update.mode": "none", 3 | "window.restoreWindows": "none" 4 | } 5 | -------------------------------------------------------------------------------- /extension/src/stores/RecentTasksStore.ts: -------------------------------------------------------------------------------- 1 | import { TaskStore } from "."; 2 | 3 | export class RecentTasksStore extends TaskStore {} 4 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'spring-boot-demo' 2 | 3 | include 'app' 4 | -------------------------------------------------------------------------------- /extension/resources/icon-transparency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/extension/resources/icon-transparency.png -------------------------------------------------------------------------------- /extension/src/commands/Command.ts: -------------------------------------------------------------------------------- 1 | export abstract class Command { 2 | public abstract run(...args: unknown[]): Promise; 3 | } 4 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./GradleDaemonTreeItem"; 2 | export * from "./GradleDaemonsTreeDataProvider"; 3 | -------------------------------------------------------------------------------- /extension/src/test/unit/index.ts: -------------------------------------------------------------------------------- 1 | import { createTestRunner } from "../testUtil"; 2 | 3 | export const run = createTestRunner("**/**.test.js"); 4 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/services/GradleExecution.ts: -------------------------------------------------------------------------------- 1 | export interface GradleExecution { 2 | exec(args: string[]): Promise; 3 | } 4 | -------------------------------------------------------------------------------- /extension/beta/package-beta.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-gradle-preview", 3 | "displayName": "Gradle Tasks - Preview", 4 | "preview": true 5 | } 6 | -------------------------------------------------------------------------------- /extension/src/tasks/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./GradleTaskDefinition"; 2 | export * from "./GradleTaskManager"; 3 | export * from "./GradleTaskProvider"; 4 | -------------------------------------------------------------------------------- /extension/src/util/execAsync.ts: -------------------------------------------------------------------------------- 1 | import { exec } from "child_process"; 2 | import { promisify } from "util"; 3 | 4 | export const execAsync = promisify(exec); 5 | -------------------------------------------------------------------------------- /extension/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "printWidth": 120, 4 | "overrides": [{ "files": "*.svg", "options": { "parser": "html" } }] 5 | } 6 | -------------------------------------------------------------------------------- /extension/src/test/integration/gradle/index.ts: -------------------------------------------------------------------------------- 1 | import { createTestRunner } from "../../testUtil"; 2 | 3 | export const run = createTestRunner("**/**.test.js"); 4 | -------------------------------------------------------------------------------- /extension/src/test/integration/multi-root/index.ts: -------------------------------------------------------------------------------- 1 | import { createTestRunner } from "../../testUtil"; 2 | 3 | export const run = createTestRunner("**/**.test.js"); 4 | -------------------------------------------------------------------------------- /extension/src/test/integration/no-gradle/index.ts: -------------------------------------------------------------------------------- 1 | import { createTestRunner } from "../../testUtil"; 2 | 3 | export const run = createTestRunner("**/**.test.js"); 4 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/diagnostics-classpath/build.gradle: -------------------------------------------------------------------------------- 1 | import org.microsoft.gradle.test.ClasspathType 2 | 3 | plugins { 4 | id "java" 5 | } 6 | -------------------------------------------------------------------------------- /extension/src/logger/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Logger"; 2 | export * from "./LoggerSteam"; 3 | import { Logger } from "./Logger"; 4 | export const logger = new Logger(); 5 | -------------------------------------------------------------------------------- /extension/src/test/integration/multi-project/index.ts: -------------------------------------------------------------------------------- 1 | import { createTestRunner } from "../../testUtil"; 2 | 3 | export const run = createTestRunner("**/**.test.js"); 4 | -------------------------------------------------------------------------------- /extension/src/test/integration/nested-projects/index.ts: -------------------------------------------------------------------------------- 1 | import { createTestRunner } from "../../testUtil"; 2 | 3 | export const run = createTestRunner("**/**.test.js"); 4 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-project/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/models/GradleConnectionType.ts: -------------------------------------------------------------------------------- 1 | export enum GradleConnectionType { 2 | WRAPPER, 3 | LOCALINSTALLATION, 4 | SPECIFICVERSION, 5 | } 6 | -------------------------------------------------------------------------------- /extension/src/views/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./NoTasksTreeItem"; 2 | export * from "./gradleTasks"; 3 | export * from "./gradleDaemons"; 4 | export * from "./recentTasks"; 5 | -------------------------------------------------------------------------------- /extension/src/stores/TaskStore.ts: -------------------------------------------------------------------------------- 1 | import { TaskId, TaskArgs } from "./types"; 2 | import { StoreMapSet } from "."; 3 | 4 | export class TaskStore extends StoreMapSet {} 5 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-custom-build-file/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-default-build-file/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-kotlin-default-build-file/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /extension/test-fixtures/tool-options-provider-test-extension/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | src/** 4 | **/tsconfig.json 5 | **/eslint.config.mjs 6 | **/*.map 7 | **/*.ts 8 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-project/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/extension/test-fixtures/multi-project/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle-language-server/test-resources/diagnostics-classpath/classpath.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/gradle-language-server/test-resources/diagnostics-classpath/classpath.jar -------------------------------------------------------------------------------- /extension/resources/dark/add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /extension/resources/light/add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/diagnostics/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java" 3 | 4 | 5 | java { 6 | sourceCompatibility = JavaVersion.VERSION_1_8 7 | targetCompatibility = JavaVersion.VERSION_1_8 8 | } 9 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/models/DaemonStatus.ts: -------------------------------------------------------------------------------- 1 | export enum DaemonStatus { 2 | IDLE = "IDLE", 3 | BUSY = "BUSY", 4 | STOPPED = "STOPPED", 5 | STOPPING = "STOPPING", 6 | CANCELED = "CANCELED", 7 | } 8 | -------------------------------------------------------------------------------- /extension/src/views/recentTasks/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./NoRecentTasksTreeItem"; 2 | export * from "./RecentTaskTreeItem"; 3 | export * from "./RecentTasksTreeDataProvider"; 4 | export * from "./RecentTasksRootProjectTreeItem"; 5 | -------------------------------------------------------------------------------- /extension/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode-test 3 | out/ 4 | dist/ 5 | test-fixtures/ 6 | package-lock.json 7 | lib/ 8 | src/proto/ 9 | build/ 10 | beta/ 11 | webpack.config.js 12 | build-server-for-gradle/ 13 | bin/ 14 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | plugin.xml,\ 6 | lib/bsp4j-2.1.0-M4.jar 7 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/model/Telemetry.java: -------------------------------------------------------------------------------- 1 | package com.microsoft.gradle.bs.importer.model; 2 | 3 | public record Telemetry(String kind, Object data) { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-custom-build-file/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/extension/test-fixtures/gradle-groovy-custom-build-file/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-default-build-file/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/extension/test-fixtures/gradle-groovy-default-build-file/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-kotlin-default-build-file/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/extension/test-fixtures/gradle-kotlin-default-build-file/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/vscode-gradle/HEAD/gradle-language-server/test-resources/spring-boot-webapp/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /extension/src/views/recentTasks/NoRecentTasksTreeItem.ts: -------------------------------------------------------------------------------- 1 | import { NoTasksTreeItem } from ".."; 2 | 3 | export class NoRecentTasksTreeItem extends NoTasksTreeItem { 4 | constructor() { 5 | super("No recent tasks"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /extension/.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode-test 3 | out/ 4 | dist/ 5 | test-fixtures/ 6 | package-lock.json 7 | package.json 8 | lib/ 9 | src/proto/ 10 | build/ 11 | src/java-test-runner.api.ts 12 | build-server-for-gradle/ 13 | bin/ 14 | -------------------------------------------------------------------------------- /javaConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ 3 | "./extension/jdtls.ext/com.microsoft.gradle.bs.importer" 4 | ], 5 | "targetPlatform": "./extension/jdtls.ext/com.microsoft.gradle.bs.importer.target/com.microsoft.gradle.bs.importer.tp.target" 6 | } 7 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/ProjectTreeItem.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { TreeItemWithTasksOrGroups } from "."; 3 | 4 | export class ProjectTreeItem extends TreeItemWithTasksOrGroups { 5 | public readonly iconPath = vscode.ThemeIcon.File; 6 | } 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | 5 | # This matches the .editorconfig settings 6 | * text=auto eol=lf 7 | 8 | # These are explicitly windows files and should use crlf 9 | *.bat text eol=crlf 10 | 11 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-project/subproject-example/sub-subproject-example/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'groovy' 3 | } 4 | 5 | tasks.register("helloGroovySubSubProject") { 6 | doLast { 7 | println 'Hello, World! SubSubProject' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /extension/.gitignore: -------------------------------------------------------------------------------- 1 | /out 2 | /dist 3 | node_modules 4 | *.vsix 5 | .vscode-test 6 | /lib 7 | !jdtls.ext/**/.project 8 | !jdtls.ext/**/.classpath 9 | .settings 10 | /src/proto/ 11 | /*.md 12 | /images 13 | server 14 | jdtls.ext/com.microsoft.gradle.bs.importer/lib/*.jar 15 | -------------------------------------------------------------------------------- /extension/resources/dark/list-flat.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /extension/resources/light/list-flat.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-project/subproject-example/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'groovy' 3 | } 4 | 5 | subprojects { 6 | version = "1.0" 7 | } 8 | 9 | tasks.register("helloGroovySubProject") { 10 | doLast { 11 | println 'Hello, World!' 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /npm-package/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "extends": [ 4 | "plugin:@typescript-eslint/recommended", 5 | "prettier", 6 | "plugin:prettier/recommended" 7 | ], 8 | "parserOptions": { "ecmaVersion": 2018, "sourceType": "module" } 9 | } 10 | -------------------------------------------------------------------------------- /extension/src/views/recentTasks/RecentTasksRootProjectTreeItem.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { TreeItemWithTasksOrGroups } from ".."; 3 | 4 | export class RecentTasksRootProjectTreeItem extends TreeItemWithTasksOrGroups { 5 | public readonly iconPath = vscode.ThemeIcon.Folder; 6 | } 7 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleDependencyType.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | public enum GradleDependencyType { 7 | PROJECT, CONFIGURATION, DEPENDENCY, 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /extension/beta/README.md: -------------------------------------------------------------------------------- 1 | # VS Code Gradle Tasks - Preview 2 | 3 | This is the preview release of Gradle Tasks. The stable release can be found here: https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-gradle 4 | 5 | This version is only used for BETA testing of unstable features and is likely to be broken. 6 | -------------------------------------------------------------------------------- /extension/resources/dark/stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/resources/light/stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/src/stores/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./EventedStore"; 2 | export * from "./StoreMap"; 3 | export * from "./StoreMapSet"; 4 | export * from "./TaskStore"; 5 | export * from "./PinnedTasksStore"; 6 | export * from "./RecentTasksStore"; 7 | export * from "./TaskTerminalsStore"; 8 | export * from "./RootProjectsStore"; 9 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleField.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | public interface GradleField { 7 | String getName(); 8 | boolean getDeprecated(); 9 | } 10 | -------------------------------------------------------------------------------- /gradle-server/src/main/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | org.slf4j.simpleLogger.defaultLogLevel=info 2 | org.slf4j.simpleLogger.showDateTime=false 3 | org.slf4j.simpleLogger.levelInBrackets=true 4 | org.slf4j.simpleLogger.showLogName=false 5 | org.slf4j.simpleLogger.showShortLogName=false 6 | org.slf4j.simpleLogger.showThreadName=false 7 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/BuildServerConnection.java: -------------------------------------------------------------------------------- 1 | package com.microsoft.gradle.bs.importer; 2 | 3 | import ch.epfl.scala.bsp4j.BuildServer; 4 | import ch.epfl.scala.bsp4j.JavaBuildServer; 5 | 6 | public interface BuildServerConnection extends BuildServer, JavaBuildServer {} 7 | -------------------------------------------------------------------------------- /extension/src/commands/ShowLogsCommand.ts: -------------------------------------------------------------------------------- 1 | import { logger } from "../logger"; 2 | import { Command } from "./Command"; 3 | 4 | export const COMMAND_SHOW_LOGS = "gradle.showLogs"; 5 | 6 | export class ShowLogsCommand extends Command { 7 | async run(): Promise { 8 | logger.getChannel()?.show(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./GradleTaskTreeItem"; 2 | export * from "./GradleTasksTreeDataProvider"; 3 | export * from "./TreeItemWithTasksOrGroups"; 4 | export * from "./ProjectTreeItem"; 5 | export * from "./GroupTreeItem"; 6 | export * from "./NoGradleTasksTreeItem"; 7 | export * from "./RootProjectTreeItem"; 8 | -------------------------------------------------------------------------------- /extension/test-fixtures/tool-options-provider-test-extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES2017", 5 | "outDir": "out", 6 | "lib": [ 7 | "ES2017" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "declaration": true, 12 | "strict": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/GradleProjectConnectionType.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.github.badsyntax.gradle; 5 | 6 | public enum GradleProjectConnectionType { 7 | WRAPPER, SPECIFICVERSION, LOCALINSTALLATION, 8 | } 9 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/model/NamedPipeConnectionException.java: -------------------------------------------------------------------------------- 1 | package com.microsoft.gradle.bs.importer.model; 2 | 3 | public class NamedPipeConnectionException extends RuntimeException { 4 | public NamedPipeConnectionException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-project/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /.github/auto_assign-issues.yml: -------------------------------------------------------------------------------- 1 | # If enabled, auto-assigns users when a new issue is created 2 | # Defaults to true, allows you to install the app globally, and disable on a per-repo basis 3 | addAssignees: true 4 | 5 | # The list of users to assign to new issues. 6 | # If empty or not provided, the repository owner is assigned 7 | assignees: 8 | - CsCherrYY 9 | -------------------------------------------------------------------------------- /extension/resources/dark/run.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/resources/light/run.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-root/multiple-project.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "../gradle-groovy-default-build-file" 5 | }, 6 | { 7 | "path": "../gradle-groovy-custom-build-file" 8 | }, 9 | { 10 | "path": "../gradle-kotlin-default-build-file" 11 | } 12 | ], 13 | "settings": {} 14 | } 15 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-custom-build-file/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-default-build-file/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-kotlin-default-build-file/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /extension/src/util/telemetryFilter.ts: -------------------------------------------------------------------------------- 1 | import { ReplacementOption } from "@vscode/extension-telemetry"; 2 | 3 | export class TelemetryFilter { 4 | public static hideUrlOption: ReplacementOption = { 5 | lookup: /https?:\/\/[^:\s]+:[^@\s]+@[^\s]+/g, // match URLs with embedded credentials 6 | replacementString: "", 7 | }; 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "EditorConfig.EditorConfig", 5 | "vscjava.vscode-java-debug", 6 | "vscjava.vscode-java-test", 7 | "redhat.java", 8 | "zxh404.vscode-proto3", 9 | "streetsidesoftware.code-spell-checker", 10 | "vscjava.vscode-gradle", 11 | "esbenp.prettier-vscode" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleMethod.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | import java.util.List; 7 | 8 | public interface GradleMethod { 9 | String getName(); 10 | List getParameterTypes(); 11 | boolean getDeprecated(); 12 | } 13 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/app/src/test/java/org/gradle/samples/SpringBootDemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootDemoApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleClosure.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | import java.util.List; 7 | 8 | public interface GradleClosure { 9 | String getName(); 10 | List getMethods(); 11 | List getFields(); 12 | } 13 | -------------------------------------------------------------------------------- /extension/resources/dark/warning.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/GroupTreeItem.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { TreeItemWithTasksOrGroups } from "."; 3 | 4 | export class GroupTreeItem extends TreeItemWithTasksOrGroups { 5 | constructor(name: string, parentTreeItem: vscode.TreeItem, resourceUri?: vscode.Uri) { 6 | super(name, parentTreeItem, resourceUri, vscode.TreeItemCollapsibleState.Collapsed); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/HintItem.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export class HintItem extends vscode.TreeItem { 7 | constructor(message: string) { 8 | super("", vscode.TreeItemCollapsibleState.None); 9 | this.description = message; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /extension/resources/dark/list-tree.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /extension/resources/light/list-tree.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /extension/src/views/NoTasksTreeItem.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { TREE_ITEM_STATE_NO_TASKS } from "./constants"; 3 | 4 | export class NoTasksTreeItem extends vscode.TreeItem { 5 | constructor(message: string) { 6 | super("", vscode.TreeItemCollapsibleState.None); 7 | this.contextValue = TREE_ITEM_STATE_NO_TASKS; 8 | this.description = message; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/ByteBufferOutputStream.java: -------------------------------------------------------------------------------- 1 | package com.github.badsyntax.gradle; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | 5 | public abstract class ByteBufferOutputStream extends ByteArrayOutputStream { 6 | @Override 7 | public void flush() { 8 | onFlush(toByteArray()); 9 | reset(); 10 | } 11 | 12 | public abstract void onFlush(byte[] bytes); 13 | } 14 | -------------------------------------------------------------------------------- /extension/beta/prepare.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | const packageJson = require("../package.json"); 4 | const betaPackageJson = require("./package-beta.json"); 5 | 6 | Object.assign(packageJson, betaPackageJson); 7 | 8 | fs.writeFileSync("../package.json", JSON.stringify(packageJson, null, 2), "utf8"); 9 | 10 | fs.copyFileSync("./README.md", "../README.md"); 11 | fs.copyFileSync("./icon.png", "../icon.png"); 12 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/NoGradleTasksTreeItem.ts: -------------------------------------------------------------------------------- 1 | import { NoTasksTreeItem } from ".."; 2 | import { COMMAND_SHOW_LOGS } from "../../commands"; 3 | 4 | export class NoGradleTasksTreeItem extends NoTasksTreeItem { 5 | constructor() { 6 | super("No tasks found"); 7 | this.command = { 8 | title: "Show Logs", 9 | command: COMMAND_SHOW_LOGS, 10 | }; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleDependencyNode.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | import java.util.List; 7 | 8 | public interface GradleDependencyNode { 9 | String getName(); 10 | GradleDependencyType getType(); 11 | List getChildren(); 12 | } 13 | -------------------------------------------------------------------------------- /extension/resources/dark/console.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/src/commands/CancellingTreeItemTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { Command } from "./Command"; 3 | 4 | export const COMMAND_CANCELLING_TREE_ITEM_TASK = "gradle.cancellingTreeItemTask"; 5 | 6 | export class CancellingTreeItemTaskCommand extends Command { 7 | async run(): Promise { 8 | await vscode.window.showInformationMessage("Gradle task is cancelling, please wait"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /extension/resources/light/console.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-default-build-file/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/5.6.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'gradle' 11 | -------------------------------------------------------------------------------- /npm-package/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "./", 6 | "lib": ["ES6", "DOM"], 7 | "sourceMap": false, 8 | "strict": true, 9 | "rootDir": "./", 10 | "noUnusedLocals": true, 11 | "allowJs": false, 12 | "declaration": true, 13 | "skipLibCheck": true 14 | }, 15 | "exclude": ["node_modules", "lib", "build"], 16 | "include": ["./index.ts"] 17 | } 18 | -------------------------------------------------------------------------------- /extension/src/commands/OpenSettingsCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { Command } from "./Command"; 3 | 4 | export const COMMAND_OPEN_SETTINGS = "gradle.openSettings"; 5 | const EXTENSION_NAME = "vscjava.vscode-gradle"; 6 | 7 | export class OpenSettingsCommand extends Command { 8 | async run(): Promise { 9 | await vscode.commands.executeCommand("workbench.action.openSettings", `@ext:${EXTENSION_NAME}`); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /gradle-language-server/src/main/java/com/microsoft/gradle/resolver/GradleField.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.resolver; 5 | 6 | public class GradleField { 7 | public String name; 8 | public boolean deprecated; 9 | 10 | public GradleField(String name, boolean deprecated) { 11 | this.name = name; 12 | this.deprecated = deprecated; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'vscode-gradle' 2 | 3 | dependencyResolutionManagement { 4 | versionCatalogs { 5 | libs { 6 | plugin('spotless', 'com.diffplug.spotless').version(JavaVersion.current().isJava8() ? '6.13.0' : '6.22.0') 7 | } 8 | } 9 | } 10 | 11 | include('gradle-server') 12 | include('extension') 13 | include('npm-package') 14 | include('gradle-plugin-api') 15 | include('gradle-plugin') 16 | include('gradle-language-server') 17 | -------------------------------------------------------------------------------- /extension/resources/dark/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/resources/light/close.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/src/views/defaultProject/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import { Range } from "vscode-languageclient/node"; 5 | 6 | export interface DefaultDependencyItem { 7 | name: string; 8 | configuration: string; 9 | range: Range; 10 | } 11 | 12 | export interface DefaultTaskDefinition { 13 | name: string; 14 | group: string; 15 | description: string; 16 | } 17 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-kotlin-default-build-file/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/5.6.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = "gradle-kotlin" 11 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleTask.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | public interface GradleTask { 7 | String getName(); 8 | String getGroup(); 9 | String getPath(); 10 | String getProject(); 11 | String getBuildFile(); 12 | String getRootProject(); 13 | String getDescription(); 14 | boolean getDebuggable(); 15 | } 16 | -------------------------------------------------------------------------------- /extension/jdtls.ext/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | gradle-jdtls-ext-parent 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/GradleBuildRunnerException.java: -------------------------------------------------------------------------------- 1 | package com.github.badsyntax.gradle.exceptions; 2 | 3 | public class GradleBuildRunnerException extends Exception { 4 | private static final long serialVersionUID = 1L; 5 | 6 | public GradleBuildRunnerException(String message) { 7 | super(message); 8 | } 9 | 10 | public GradleBuildRunnerException(String message, Throwable cause) { 11 | super(message, cause); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/GradleCancellationException.java: -------------------------------------------------------------------------------- 1 | package com.github.badsyntax.gradle.exceptions; 2 | 3 | public class GradleCancellationException extends Exception { 4 | private static final long serialVersionUID = 1L; 5 | 6 | public GradleCancellationException(String message) { 7 | super(message); 8 | } 9 | 10 | public GradleCancellationException(String message, Throwable cause) { 11 | super(message, cause); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /npm-package/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Output, 3 | RunBuildRequest, 4 | CancelBuildRequest, 5 | } from './lib/proto/gradle_pb'; 6 | 7 | import type { 8 | Api, 9 | RunTaskOpts, 10 | CancelTaskOpts, 11 | CancelBuildOpts, 12 | RunBuildOpts, 13 | } from './lib/api/Api'; 14 | 15 | export { 16 | Output, 17 | RunBuildRequest, 18 | RunBuildOpts, 19 | RunTaskOpts, 20 | CancelBuildRequest, 21 | CancelBuildOpts, 22 | CancelTaskOpts, 23 | Api as ExtensionApi, 24 | }; 25 | -------------------------------------------------------------------------------- /gradle-plugin-api/build.gradle: -------------------------------------------------------------------------------- 1 | java { 2 | sourceCompatibility = JavaVersion.VERSION_1_8 3 | targetCompatibility = JavaVersion.VERSION_1_8 4 | } 5 | 6 | dependencies { 7 | implementation ("org.gradle:gradle-tooling-api:${toolingAPIVersion}") 8 | } 9 | 10 | spotless { 11 | java { 12 | importOrder() 13 | eclipse() 14 | removeUnusedImports() 15 | trimTrailingWhitespace() 16 | targetExclude "build/**" 17 | } 18 | } 19 | 20 | compileJava.dependsOn 'spotlessCheck' 21 | -------------------------------------------------------------------------------- /extension/src/util/javaExtension.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | const JAVA_EXTENSION_ID = "redhat.java"; 7 | 8 | export function isJavaExtEnabled(): boolean { 9 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 10 | const javaExt: vscode.Extension | undefined = vscode.extensions.getExtension(JAVA_EXTENSION_ID); 11 | return !!javaExt; 12 | } 13 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/app/src/main/java/org/gradle/samples/SpringBootDemoApplication.java: -------------------------------------------------------------------------------- 1 | package org.gradle.samples; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootDemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootDemoApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | [*.gradle] 12 | charset = utf-8 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.java] 17 | charset = utf-8 18 | indent_style = tab 19 | indent_size = 4 20 | 21 | [*.ts] 22 | charset = utf-8 23 | indent_style = space 24 | indent_size = 4 25 | -------------------------------------------------------------------------------- /extension/src/commands/LoadTasksCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { GradleTaskProvider } from "../tasks"; 3 | import { Command } from "./Command"; 4 | export const COMMAND_LOAD_TASKS = "gradle.loadTasks"; 5 | 6 | export class LoadTasksCommand extends Command { 7 | constructor(private gradleTaskProvider: GradleTaskProvider) { 8 | super(); 9 | } 10 | async run(): Promise { 11 | return this.gradleTaskProvider.loadTasks(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /extension/src/commands/ExplorerFlatCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTasksTreeDataProvider } from "../views"; 2 | import { Command } from "./Command"; 3 | 4 | export const COMMAND_EXPLORER_FLAT = "gradle.explorerFlat"; 5 | 6 | export class ExplorerFlatCommand extends Command { 7 | constructor(private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider) { 8 | super(); 9 | } 10 | async run(): Promise { 11 | await this.gradleTasksTreeDataProvider.setCollapsed(true); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /extension/src/commands/ExplorerTreeCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTasksTreeDataProvider } from "../views"; 2 | import { Command } from "./Command"; 3 | 4 | export const COMMAND_EXPLORER_TREE = "gradle.explorerTree"; 5 | 6 | export class ExplorerTreeCommand extends Command { 7 | constructor(private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider) { 8 | super(); 9 | } 10 | async run(): Promise { 11 | await this.gradleTasksTreeDataProvider.setCollapsed(false); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/5.6.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = "multi-project" 11 | 12 | include("subproject-example:sub-subproject-example") 13 | -------------------------------------------------------------------------------- /extension/src/commands/RefreshDaemonStatusCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleDaemonsTreeDataProvider } from "../views"; 2 | import { Command } from "./Command"; 3 | export const COMMAND_REFRESH_DAEMON_STATUS = "gradle.refreshDaemonStatus"; 4 | 5 | export class RefreshDaemonStatusCommand extends Command { 6 | constructor(private gradleDaemonsTreeDataProvider: GradleDaemonsTreeDataProvider) { 7 | super(); 8 | } 9 | async run(): Promise { 10 | this.gradleDaemonsTreeDataProvider.refresh(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /extension/src/client/CancellationKeys.ts: -------------------------------------------------------------------------------- 1 | export function getBuildCancellationKey(rootProjectFolder: string): string { 2 | return "getBuild" + rootProjectFolder; 3 | } 4 | 5 | export function getRunBuildCancellationKey(rootProjectFolder: string, args: ReadonlyArray): string { 6 | return "runBuild" + rootProjectFolder + args.join(""); 7 | } 8 | 9 | export function getRunTaskCommandCancellationKey(rootProjectFolder: string, taskName: string): string { 10 | return "runTask" + rootProjectFolder + taskName; 11 | } 12 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer.target/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.microsoft.gradle.bs.importer.target 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-custom-build-file/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/5.6.3/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'gradle-groovy-custom-build-file' 11 | rootProject.buildFileName = 'my-custom-build.gradle' 12 | -------------------------------------------------------------------------------- /gradle-language-server/src/main/java/com/microsoft/gradle/resolver/GradleClosure.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.resolver; 5 | 6 | public class GradleClosure { 7 | public String name; 8 | public GradleMethod[] methods; 9 | public GradleField[] fields; 10 | 11 | public GradleClosure(String name, GradleMethod[] methods, GradleField[] fields) { 12 | this.name = name; 13 | this.methods = methods; 14 | this.fields = fields; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleModelAction.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | import org.gradle.tooling.BuildAction; 7 | import org.gradle.tooling.BuildController; 8 | 9 | public class GradleModelAction implements BuildAction { 10 | @Override 11 | public GradleProjectModel execute(BuildController controller) { 12 | return controller.getModel(GradleProjectModel.class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /extension/src/commands/ShowTasksCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { focusProjectInGradleTasksTree } from "../views/viewUtil"; 3 | import { Command } from "./Command"; 4 | export const COMMAND_SHOW_TASKS = "gradle.showTasks"; 5 | 6 | export class ShowTasksCommand extends Command { 7 | constructor(private gradleTasksTreeView: vscode.TreeView) { 8 | super(); 9 | } 10 | async run(uri: vscode.Uri): Promise { 11 | await focusProjectInGradleTasksTree(uri, this.gradleTasksTreeView); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/ErrorMessageBuilder.java: -------------------------------------------------------------------------------- 1 | package com.github.badsyntax.gradle; 2 | 3 | import io.grpc.Status; 4 | import io.grpc.StatusRuntimeException; 5 | 6 | public class ErrorMessageBuilder { 7 | private ErrorMessageBuilder() { 8 | } 9 | 10 | public static StatusRuntimeException build(Exception e) { 11 | return build(e, Status.INTERNAL); 12 | } 13 | 14 | public static StatusRuntimeException build(Exception e, Status status) { 15 | return status.withDescription(e.getMessage()).asRuntimeException(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Output directories 3 | build/ 4 | target/ 5 | bin/ 6 | 7 | # Mac OS X files 8 | .DS_Store 9 | 10 | # Eclipse files 11 | .settings 12 | .classpath 13 | .project 14 | 15 | # vim files 16 | .*.sw[a-z] 17 | *.un~ 18 | 19 | # Java class files 20 | *.class 21 | 22 | # Gradle 23 | .gradle 24 | 25 | # direnv 26 | .envrc 27 | 28 | # Ignore Gradle build output directory 29 | build 30 | 31 | # build plugin jar files 32 | gradle-server/src/main/resources/*.jar 33 | 34 | # Ignore user-specified .tool-versions file (asdf-vm configuration) 35 | .tool-versions 36 | -------------------------------------------------------------------------------- /gradle-language-server/src/main/java/com/microsoft/gradle/resolver/GradleMethod.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.resolver; 5 | 6 | public class GradleMethod { 7 | public String name; 8 | public String[] parameterTypes; 9 | public boolean deprecated; 10 | 11 | public GradleMethod(String name, String[] parameterTypes, boolean deprecated) { 12 | this.name = name; 13 | this.parameterTypes = parameterTypes; 14 | this.deprecated = deprecated; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/app/HELP.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ### Reference Documentation 4 | For further reference, please consider the following sections: 5 | 6 | * [Official Gradle documentation](https://docs.gradle.org) 7 | * [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.1.RELEASE/gradle-plugin/reference/html/) 8 | 9 | ### Additional Links 10 | These additional references should also help you: 11 | 12 | * [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) 13 | 14 | -------------------------------------------------------------------------------- /extension/resources/dark/clear-all.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /extension/test-fixtures/tool-options-provider-test-extension/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tooloptionstest", 3 | "publisher": "vscjava", 4 | "displayName": "Tool options test", 5 | "engines": { 6 | "vscode": "^1.76.0" 7 | }, 8 | "version": "1.0.0", 9 | "main": "./out/extension.js", 10 | "activationEvents": [ 11 | "*" 12 | ], 13 | "scripts": { 14 | "compile": "tsc -p ./" 15 | }, 16 | "devDependencies": { 17 | "@types/vscode": "^1.76.0", 18 | "typescript": "^5.6.3" 19 | }, 20 | "extensionDependencies": [ 21 | "vscjava.vscode-gradle" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /gradle-language-server/src/test/java/com/microsoft/gradle/GradleTestConstants.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle; 5 | 6 | import java.nio.file.Path; 7 | import java.nio.file.Paths; 8 | 9 | public class GradleTestConstants { 10 | public static String LANGUAGE_GRADLE = "gradle"; 11 | public static String TEST_PROJECT_PATH = "./test-resources/spring-boot-webapp"; 12 | public static Path testPath = Paths.get(System.getProperty("user.dir")) 13 | .resolve(GradleTestConstants.TEST_PROJECT_PATH);; 14 | } 15 | -------------------------------------------------------------------------------- /extension/src/stores/EventedStore.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { debounce } from "../util/decorators"; 3 | 4 | export abstract class EventedStore implements vscode.Disposable { 5 | private readonly _onDidChange: vscode.EventEmitter = new vscode.EventEmitter(); 6 | public readonly onDidChange: vscode.Event = this._onDidChange.event; 7 | 8 | @debounce(0) 9 | public fireOnDidChange(value: V | null): void { 10 | this._onDidChange.fire(value); 11 | } 12 | 13 | public dispose(): void { 14 | this._onDidChange.dispose(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/util.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export function getSpecificVersionStatus(): boolean { 7 | const versionConfig = vscode.workspace.getConfiguration("java").get("import.gradle.version"); 8 | const wrapperConfig = vscode.workspace 9 | .getConfiguration("java") 10 | .get("import.gradle.wrapper.enabled"); 11 | return wrapperConfig === false && versionConfig !== null && versionConfig !== ""; 12 | } 13 | -------------------------------------------------------------------------------- /extension/src/tasks/GradleTaskDefinition.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | 3 | export interface GradleTaskDefinition extends vscode.TaskDefinition { 4 | id: string; 5 | script: string; 6 | description: string; 7 | group: string; 8 | project: string; 9 | rootProject: string; 10 | buildFile: string; 11 | projectFolder: string; 12 | workspaceFolder: string; 13 | // the task can be debugged or not 14 | debuggable: boolean; 15 | args: string; 16 | // this run session of the task should be debugged or not 17 | javaDebug: boolean; 18 | isPinned: boolean; 19 | } 20 | -------------------------------------------------------------------------------- /extension/src/util/Deferred.ts: -------------------------------------------------------------------------------- 1 | export class Deferred { 2 | public promise: Promise; 3 | 4 | private _resolve?: (value: T) => void; 5 | private _reject?: (reason?: Error) => void; 6 | 7 | constructor() { 8 | this.promise = new Promise((resolve: (value: T) => void, reject: (reason?: Error) => void) => { 9 | this._resolve = resolve; 10 | this._reject = reject; 11 | }); 12 | } 13 | 14 | resolve(value: T): void { 15 | this._resolve!(value); 16 | } 17 | 18 | reject(reason: Error): void { 19 | this._reject!(reason); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /extension/test-fixtures/multi-project/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This is a general purpose Gradle build. 5 | * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds 6 | */ 7 | 8 | allprojects { 9 | repositories { 10 | jcenter() 11 | } 12 | } 13 | 14 | subprojects { 15 | version = "1.0" 16 | } 17 | 18 | tasks.register("hello") { 19 | doLast { 20 | println "Hello, World!" 21 | } 22 | } 23 | 24 | tasks.register("helloGroovyRoot") { 25 | doLast { 26 | println "Hello, World!" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /extension/src/commands/HideStoppedDaemonsCommand.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import { GradleDaemonsTreeDataProvider } from "../views"; 5 | import { Command } from "./Command"; 6 | export const HIDE_STOPPED_DAEMONS = "gradle.hideStoppedDaemons"; 7 | 8 | export class HideStoppedDaemonsCommand extends Command { 9 | constructor(private gradleDaemonsTreeDataProvider: GradleDaemonsTreeDataProvider) { 10 | super(); 11 | } 12 | 13 | async run(): Promise { 14 | this.gradleDaemonsTreeDataProvider.hideStoppedDaemons(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /extension/src/commands/ShowStoppedDaemonsCommand.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import { GradleDaemonsTreeDataProvider } from "../views"; 5 | import { Command } from "./Command"; 6 | export const SHOW_STOPPED_DAEMONS = "gradle.showStoppedDaemons"; 7 | 8 | export class ShowStoppedDaemonsCommand extends Command { 9 | constructor(private gradleDaemonsTreeDataProvider: GradleDaemonsTreeDataProvider) { 10 | super(); 11 | } 12 | 13 | async run(): Promise { 14 | this.gradleDaemonsTreeDataProvider.showStoppedDaemons(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /npm-package/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Output directories 4 | build/ 5 | target/ 6 | bin/ 7 | 8 | # Mac OS X files 9 | .DS_Store 10 | 11 | # Eclipse files 12 | .settings 13 | .classpath 14 | .project 15 | 16 | # vim files 17 | .*.sw[a-z] 18 | *.un~ 19 | 20 | # Java class files 21 | *.class 22 | 23 | # Gradle 24 | .gradle 25 | 26 | # direnv 27 | .envrc 28 | 29 | # Ignore Gradle build output directory 30 | build 31 | 32 | # proto generated files 33 | proto 34 | 35 | # these files are copied from subprojects and should not be included 36 | lib 37 | 38 | #sourcemaps 39 | *.map 40 | 41 | # generated files 42 | index.js 43 | index.d.ts 44 | -------------------------------------------------------------------------------- /npm-package/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Output directories 4 | build/ 5 | target/ 6 | bin/ 7 | 8 | # Mac OS X files 9 | .DS_Store 10 | 11 | # Eclipse files 12 | .settings 13 | .classpath 14 | .project 15 | 16 | # vim files 17 | .*.sw[a-z] 18 | *.un~ 19 | 20 | # Java class files 21 | *.class 22 | 23 | # Gradle 24 | .gradle 25 | 26 | # direnv 27 | .envrc 28 | 29 | # Ignore Gradle build output directory 30 | build 31 | 32 | # Gradle build 33 | build.gradle 34 | 35 | # Dotfiles 36 | .eslintignore 37 | .eslintrc.json 38 | .prettierignore 39 | .prettierrc.json 40 | 41 | # Sourcemaps 42 | *.map 43 | 44 | # TypeScript 45 | tsconfig.json 46 | index.ts 47 | -------------------------------------------------------------------------------- /gradle-plugin-api/src/main/java/com/microsoft/gradle/api/GradleProjectModel.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.api; 5 | 6 | import java.util.List; 7 | import org.gradle.tooling.model.Model; 8 | 9 | public interface GradleProjectModel extends Model { 10 | boolean getIsRoot(); 11 | String getProjectPath(); 12 | List getSubProjects(); 13 | List getTasks(); 14 | GradleDependencyNode getDependencyNode(); 15 | List getPlugins(); 16 | List getClosures(); 17 | List getScriptClasspaths(); 18 | } 19 | -------------------------------------------------------------------------------- /extension/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/** 4 | src/** 5 | .gitignore 6 | **/tsconfig.json 7 | **/.eslintignore 8 | **/.eslintrc.json 9 | **/.prettierrc.json 10 | **/.prettierignore 11 | **/.classpath 12 | **/.project 13 | **/.settings 14 | **/*.map 15 | **/*.ts 16 | test-fixtures/** 17 | images/** 18 | proto/** 19 | build.gradle 20 | build/** 21 | .gradle/** 22 | node_modules 23 | webpack.config.js 24 | beta/** 25 | ARCHITECTURE.md 26 | # Ignore output of code sign 27 | lib/*.md 28 | **/*.log 29 | 30 | scripts 31 | # for nightly build 32 | package.insiders.json 33 | jdtls.ext 34 | build-server-for-gradle 35 | #codesign 36 | **/CodeSignSummary-*.md 37 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer.target/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.microsoft.gradle.jdtls.ext 6 | gradle-jdtls-ext-parent 7 | 0.5.4 8 | 9 | com.microsoft.gradle.bs.importer.tp 10 | ${base.name} :: Target Platform 11 | eclipse-target-definition 12 | 13 | -------------------------------------------------------------------------------- /extension/resources/dark/circle-outline.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/resources/light/circle-outline.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /extension/resources/dark/refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /extension/resources/light/refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | --- 7 | 8 | **Is your feature request related to a problem? Please describe.** 9 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 10 | 11 | **Describe the solution you'd like** 12 | A clear and concise description of what you want to happen. 13 | 14 | **Describe alternatives you've considered** 15 | A clear and concise description of any alternative solutions or features you've considered. 16 | 17 | **Additional context** 18 | Add any other context or screenshots about the feature request here. 19 | -------------------------------------------------------------------------------- /extension/resources/dark/close-all.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /extension/resources/light/close-all.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /extension/test-fixtures/tool-options-provider-test-extension/src/extension.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | 3 | export function activate(context: vscode.ExtensionContext) { 4 | const extension = vscode.extensions.getExtension("vscjava.vscode-gradle"); 5 | if (extension) { 6 | extension.activate().then((exports) => { 7 | console.log(exports); 8 | context.subscriptions.push( 9 | exports.registerToolOptionsProvider({ 10 | async resolveToolOptions(): Promise { 11 | return "-DtoolOptionsTest=true"; 12 | }, 13 | }) 14 | ); 15 | }); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gradle-language-server/src/main/java/com/microsoft/gradle/semantictokens/TokenType.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.semantictokens; 5 | 6 | import org.eclipse.lsp4j.SemanticTokenTypes; 7 | 8 | public enum TokenType { 9 | FUNCTION(SemanticTokenTypes.Function), PROPERTY(SemanticTokenTypes.Property), VARIABLE( 10 | SemanticTokenTypes.Variable), PARAMETER(SemanticTokenTypes.Parameter); 11 | 12 | private String genericName; 13 | 14 | TokenType(String genericName) { 15 | this.genericName = genericName; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return genericName; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/java/com/microsoft/gradle/DefaultGradleField.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle; 5 | 6 | import com.microsoft.gradle.api.GradleField; 7 | import java.io.Serializable; 8 | 9 | public class DefaultGradleField implements Serializable, GradleField { 10 | private String name; 11 | private boolean deprecated; 12 | 13 | public DefaultGradleField(String name, boolean deprecated) { 14 | this.name = name; 15 | this.deprecated = deprecated; 16 | } 17 | 18 | public String getName() { 19 | return this.name; 20 | } 21 | 22 | public boolean getDeprecated() { 23 | return this.deprecated; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extension/src/commands/ClearAllRecentTasksCommand.ts: -------------------------------------------------------------------------------- 1 | import { confirmModal } from "../util/input"; 2 | import { RecentTasksStore } from "../stores"; 3 | import { Command } from "./Command"; 4 | 5 | export const COMMAND_CLEAR_ALL_RECENT_TASKS = "gradle.clearAllRecentTasks"; 6 | 7 | export class ClearAllRecentTasksCommand extends Command { 8 | constructor(private recentTasksStore: RecentTasksStore) { 9 | super(); 10 | } 11 | 12 | async run(): Promise { 13 | if ( 14 | this.recentTasksStore.getData().size && 15 | (await confirmModal("Are you sure you want to clear the recent tasks?")) 16 | ) { 17 | this.recentTasksStore.clear(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /extension/gradle-language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "//", 4 | "blockComment": ["/*", "*/"] 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ["[", "]"], 9 | ["(", ")"] 10 | ], 11 | "autoClosingPairs": [ 12 | ["{", "}"], 13 | ["[", "]"], 14 | ["(", ")"], 15 | ["\"", "\""], 16 | ["'", "'"], 17 | { 18 | "open": "/**", 19 | "close": " */", 20 | "notIn": ["string"] 21 | } 22 | ], 23 | "surroundingPairs": [ 24 | ["{", "}"], 25 | ["[", "]"], 26 | ["(", ")"], 27 | ["\"", "\""], 28 | ["'", "'"], 29 | ["<", ">"] 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /extension/resources/dark/gear.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /extension/resources/light/gear.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /extension/src/commands/CancelBuildCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { cancelBuild } from "../tasks/taskUtil"; 3 | import { logger } from "../logger"; 4 | import { Command } from "./Command"; 5 | import { TaskServerClient } from "../client"; 6 | export const COMMAND_CANCEL_BUILD = "gradle.cancelBuild"; 7 | 8 | export class CancelBuildCommand extends Command { 9 | constructor(private client: TaskServerClient) { 10 | super(); 11 | } 12 | async run(cancellationKey: string, task?: vscode.Task): Promise { 13 | try { 14 | await cancelBuild(this.client, cancellationKey, task); 15 | } catch (e) { 16 | logger.error("Error cancelling task:", e.message); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /extension/src/stores/TaskTerminalsStore.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { TaskId } from "./types"; 3 | import { StoreMapSet } from "."; 4 | 5 | export class TaskTerminalsStore extends StoreMapSet { 6 | removeTerminal(terminal: vscode.Terminal): void { 7 | Array.from(this.getData().keys()).forEach((key) => { 8 | const itemSet = this.getItem(key); 9 | if (itemSet) { 10 | Array.from(itemSet).forEach((taskTerminal) => { 11 | if (taskTerminal === terminal) { 12 | itemSet.delete(taskTerminal); 13 | } 14 | }); 15 | } 16 | }); 17 | this.fireOnDidChange(null); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /extension/resources/light/clear-all.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /extension/src/commands/DebugTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { runTask } from "../tasks/taskUtil"; 3 | import { Command } from "./Command"; 4 | import { RootProjectsStore } from "../stores"; 5 | import { TaskServerClient } from "../client"; 6 | export const COMMAND_DEBUG_TASK = "gradle.debugTask"; 7 | 8 | export class DebugTaskCommand extends Command { 9 | constructor(private rootProjectsStore: RootProjectsStore, private client: TaskServerClient) { 10 | super(); 11 | } 12 | async run(treeItem: GradleTaskTreeItem, args = ""): Promise { 13 | if (treeItem && treeItem.task) { 14 | await runTask(this.rootProjectsStore, treeItem.task, this.client, args, true); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-default-build-file/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This is a general purpose Gradle build. 5 | * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds 6 | */ 7 | 8 | tasks.register("hello") { 9 | doLast { 10 | println 'Hello, World!' 11 | } 12 | } 13 | 14 | tasks.register("bye") { 15 | doLast { 16 | println 'Goodbye cruel world' 17 | } 18 | } 19 | 20 | tasks.register("helloProjectProperty") { 21 | doLast { 22 | println 'Hello, Project Property!' + customProp 23 | } 24 | } 25 | 26 | tasks.register("helloGroovyDefault") { 27 | doLast { 28 | println 'Hello, World!' 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/java/com/microsoft/gradle/GradlePlugin.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle; 5 | 6 | import javax.inject.Inject; 7 | import org.gradle.api.Plugin; 8 | import org.gradle.api.Project; 9 | import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry; 10 | 11 | public class GradlePlugin implements Plugin { 12 | 13 | private ToolingModelBuilderRegistry registry; 14 | 15 | @Inject 16 | public GradlePlugin(ToolingModelBuilderRegistry registry) { 17 | this.registry = registry; 18 | } 19 | 20 | @Override 21 | public void apply(Project project) { 22 | registry.register(new GradleProjectModelBuilder(registry)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /extension/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-undef 2 | module.exports = { 3 | root: true, 4 | parser: "@typescript-eslint/parser", 5 | plugins: ["@typescript-eslint", "prettier"], 6 | extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], 7 | rules: { 8 | "@typescript-eslint/no-non-null-assertion": "off", 9 | "@typescript-eslint/consistent-type-assertions": [ 10 | 2, 11 | { 12 | assertionStyle: "as", 13 | objectLiteralTypeAssertions: "allow", 14 | }, 15 | ], 16 | "no-case-declarations": "off", 17 | "no-async-promise-executor": "off", 18 | }, 19 | ignorePatterns: "scripts/*.js", 20 | }; 21 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/models/DaemonInfo.ts: -------------------------------------------------------------------------------- 1 | import { DaemonStatus } from "./DaemonStatus"; 2 | 3 | export class DaemonInfo { 4 | constructor(private pid: string, private status: DaemonStatus, private info: string) {} 5 | 6 | public getPid(): string { 7 | return this.pid; 8 | } 9 | 10 | public getStatus(): DaemonStatus { 11 | return this.status; 12 | } 13 | 14 | public getInfo(): string { 15 | return this.info; 16 | } 17 | 18 | public setStatus(status: DaemonStatus): void { 19 | this.status = status; 20 | } 21 | 22 | public setInfo(info: string): void { 23 | this.info = info; 24 | } 25 | 26 | public setPid(pid: string): void { 27 | this.pid = pid; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /extension/src/util/compat.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | 3 | export const JAVA_LANGUAGE_EXTENSION_ID = "redhat.java"; 4 | export const JAVA_DEBUGGER_EXTENSION_ID = "vscjava.vscode-java-debug"; 5 | 6 | export function isJavaLanguageSupportExtensionActivated(): boolean { 7 | const javaExt: vscode.Extension | undefined = getJavaLanguageSupportExtension(); 8 | return javaExt?.isActive || false; 9 | } 10 | 11 | export function getJavaLanguageSupportExtension(): vscode.Extension | undefined { 12 | return vscode.extensions.getExtension(JAVA_LANGUAGE_EXTENSION_ID); 13 | } 14 | 15 | export function getJavaDebuggerExtension(): vscode.Extension | undefined { 16 | return vscode.extensions.getExtension(JAVA_DEBUGGER_EXTENSION_ID); 17 | } 18 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-groovy-custom-build-file/my-custom-build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This is a general purpose Gradle build. 5 | * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds 6 | */ 7 | 8 | tasks.register("hello") { 9 | doLast { 10 | println 'Hello, World!' 11 | } 12 | } 13 | 14 | tasks.register("bye") { 15 | doLast { 16 | println 'Goodbye cruel world' 17 | } 18 | } 19 | 20 | tasks.register("helloProjectProperty") { 21 | doLast { 22 | println 'Hello, Project Property!' + customProp 23 | } 24 | } 25 | 26 | tasks.register("helloGroovyCustom") { 27 | doLast { 28 | println 'Hello, World!' 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /extension/resources/light/warning.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /extension/src/commands/RemoveRecentTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { GradleTaskDefinition } from "../tasks"; 3 | import { Command } from "./Command"; 4 | import { RecentTasksStore } from "../stores"; 5 | 6 | export const COMMAND_REMOVE_RECENT_TASK = "gradle.removeRecentTask"; 7 | 8 | export class RemoveRecentTaskCommand extends Command { 9 | constructor(private recentTasksStore: RecentTasksStore) { 10 | super(); 11 | } 12 | async run(treeItem: GradleTaskTreeItem): Promise { 13 | if (treeItem && treeItem.task) { 14 | const definition = treeItem.task.definition as GradleTaskDefinition; 15 | this.recentTasksStore.removeEntry(definition.id, definition.args); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /extension/src/commands/RenderTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { GradleTasksTreeDataProvider, RecentTasksTreeDataProvider } from "../views"; 3 | import { updateGradleTreeItemStateForTask } from "../views/viewUtil"; 4 | import { Command } from "./Command"; 5 | export const COMMAND_RENDER_TASK = "gradle.renderTask"; 6 | 7 | export class RenderTaskCommand extends Command { 8 | constructor( 9 | private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider, 10 | private recentTasksTreeDataProvider: RecentTasksTreeDataProvider 11 | ) { 12 | super(); 13 | } 14 | async run(task: vscode.Task): Promise { 15 | updateGradleTreeItemStateForTask(task, this.gradleTasksTreeDataProvider, this.recentTasksTreeDataProvider); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /extension/src/commands/RestartTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { getTaskExecution, queueRestartTask } from "../tasks/taskUtil"; 3 | import { Command } from "./Command"; 4 | import { TaskServerClient } from "../client"; 5 | export const COMMAND_RESTART_TASK = "gradle.restartTask"; 6 | 7 | export class RestartTaskCommand extends Command { 8 | constructor(private client: TaskServerClient) { 9 | super(); 10 | } 11 | async run(treeItem: GradleTaskTreeItem): Promise { 12 | if (treeItem && treeItem.task) { 13 | const taskExecution = getTaskExecution(treeItem.task); 14 | if (taskExecution) { 15 | await queueRestartTask(this.client, taskExecution.task); 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/RootProjectTreeItem.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { ProjectTreeItem } from "."; 3 | import { TREE_ITEM_STATE_FOLDER } from "../constants"; 4 | 5 | export class RootProjectTreeItem extends vscode.TreeItem { 6 | public readonly projects: ProjectTreeItem[] = []; 7 | public readonly parentTreeItem: RootProjectTreeItem | null = null; 8 | 9 | constructor(name: string, resourceUri: vscode.Uri) { 10 | super(name, vscode.TreeItemCollapsibleState.Expanded); 11 | this.contextValue = TREE_ITEM_STATE_FOLDER; 12 | this.resourceUri = resourceUri; 13 | this.iconPath = vscode.ThemeIcon.Folder; 14 | } 15 | 16 | public addProject(project: ProjectTreeItem): void { 17 | this.projects.push(project); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /extension/src/logger/LoggerSteam.ts: -------------------------------------------------------------------------------- 1 | import * as util from "util"; 2 | import { Logger, LogVerbosity } from "./Logger"; 3 | 4 | export class LoggerStream { 5 | private buffer = ""; 6 | constructor(private readonly logger: Logger, private readonly verbosity: LogVerbosity) {} 7 | 8 | public write(bytes: Uint8Array): void { 9 | const message = new util.TextDecoder("utf-8").decode(bytes); 10 | const formattedMessage = this.buffer.length ? message : this.logger.format(message.trimLeft(), this.verbosity); 11 | this.buffer += message; 12 | this.append(formattedMessage); 13 | } 14 | 15 | private append(message: string): void { 16 | this.logger.append(message, this.verbosity); 17 | } 18 | 19 | public getBuffer(): string { 20 | return this.buffer; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /extension/src/createProject/utils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | /* eslint-disable @typescript-eslint/no-explicit-any */ 5 | import { debounce } from "lodash"; 6 | 7 | export function asyncDebounce(func: any, wait: any, bind: any) { 8 | const debounced = debounce(async (resolve, reject, bindSelf, args) => { 9 | try { 10 | const result = await func.bind(bindSelf)(...args); 11 | resolve(result); 12 | } catch (error) { 13 | reject(error); 14 | } 15 | }, wait); 16 | 17 | function returnFunc(...args: any[]) { 18 | return new Promise((resolve, reject) => { 19 | debounced(resolve, reject, bind, args); 20 | }); 21 | } 22 | 23 | return returnFunc; 24 | } 25 | -------------------------------------------------------------------------------- /extension/test-fixtures/gradle-kotlin-default-build-file/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This is a general purpose Gradle build. 5 | * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds 6 | */ 7 | 8 | tasks.register("hello") { 9 | doLast { 10 | println("Hello, World!") 11 | } 12 | } 13 | 14 | tasks.register("bye") { 15 | doLast { 16 | println("Goodbye cruel world") 17 | } 18 | } 19 | 20 | tasks.register("helloKotlinDefault") { 21 | doLast { 22 | println("Hello, helloKotlinDefault!") 23 | } 24 | } 25 | 26 | val customProp: String by project 27 | 28 | tasks.register("helloProjectProperty") { 29 | doLast { 30 | println("Hello, Project Property!" + customProp) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/BuildServerThread.java: -------------------------------------------------------------------------------- 1 | package com.github.badsyntax.gradle; 2 | 3 | import com.microsoft.java.bs.core.Launcher; 4 | import java.nio.file.Paths; 5 | public class BuildServerThread implements Runnable { 6 | 7 | private String bundleDirectory; 8 | 9 | private final String pipeName; 10 | 11 | public BuildServerThread(String pipeName, String bundleDirectory) { 12 | this.pipeName = pipeName; 13 | this.bundleDirectory = bundleDirectory; 14 | } 15 | 16 | @Override 17 | public void run() { 18 | System.setProperty("plugin.dir", getBuildServerPluginPath()); 19 | String[] args = {"--pipe=" + this.pipeName}; 20 | Launcher.main(args); 21 | } 22 | 23 | private String getBuildServerPluginPath() { 24 | return Paths.get(bundleDirectory, "plugins").toString(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gradle-language-server/test-resources/spring-boot-webapp/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.2.1.RELEASE' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.2' 7 | group = 'org.gradle.samples' 8 | 9 | java { 10 | sourceCompatibility = JavaVersion.VERSION_1_8 11 | targetCompatibility = JavaVersion.VERSION_1_8 12 | } 13 | 14 | repositories { 15 | mavenCentral() 16 | } 17 | 18 | dependencies { 19 | implementation platform('org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE') 20 | implementation 'org.springframework.boot:spring-boot-dependenciesboot:spring-boot-starter' 21 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 22 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 23 | } 24 | } 25 | 26 | tasks.named('test', Test) { 27 | useJUnitPlatform() 28 | } 29 | -------------------------------------------------------------------------------- /gradle-language-server/src/main/java/com/microsoft/gradle/compile/GradleCompilationUnit.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.compile; 5 | 6 | import groovy.lang.GroovyClassLoader; 7 | import java.security.CodeSource; 8 | import org.codehaus.groovy.control.CompilationUnit; 9 | import org.codehaus.groovy.control.CompilerConfiguration; 10 | 11 | public class GradleCompilationUnit extends CompilationUnit { 12 | private Integer version; 13 | 14 | public GradleCompilationUnit(CompilerConfiguration configuration, CodeSource codeSource, GroovyClassLoader loader, 15 | Integer version) { 16 | super(configuration, codeSource, loader); 17 | this.version = version; 18 | } 19 | 20 | public Integer getVersion() { 21 | return this.version; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Gradle Build Server Importer 4 | Bundle-SymbolicName: com.microsoft.gradle.bs.importer;singleton:=true 5 | Bundle-Version: 0.5.4 6 | Bundle-Activator: com.microsoft.gradle.bs.importer.ImporterPlugin 7 | Bundle-RequiredExecutionEnvironment: JavaSE-21 8 | Bundle-ActivationPolicy: lazy 9 | Import-Package: org.eclipse.jdt.core, 10 | org.eclipse.jdt.launching, 11 | org.osgi.framework;version="1.3.0" 12 | Require-Bundle: org.eclipse.core.runtime, 13 | org.eclipse.jdt.ls.core, 14 | org.eclipse.jdt.core, 15 | org.eclipse.lsp4j, 16 | org.eclipse.lsp4j.jsonrpc, 17 | org.eclipse.core.resources, 18 | org.eclipse.jdt.launching, 19 | org.apache.commons.lang3, 20 | com.google.gson 21 | Bundle-ClassPath: lib/bsp4j-2.1.0-M4.jar, 22 | . 23 | -------------------------------------------------------------------------------- /extension/src/languageServer/utils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export function prepareLanguageServerParams(): string[] { 7 | const params = []; 8 | params.push("-Dfile.encoding=" + getJavaEncoding()); 9 | return params; 10 | } 11 | 12 | function getJavaEncoding(): string { 13 | const config = vscode.workspace.getConfiguration(); 14 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 15 | const languageConfig = config.get("[java]") as any; 16 | let javaEncoding = null; 17 | if (languageConfig) { 18 | javaEncoding = languageConfig["files.encoding"]; 19 | } 20 | if (!javaEncoding) { 21 | javaEncoding = config.get("files.encoding", "UTF-8"); 22 | } 23 | return javaEncoding; 24 | } 25 | -------------------------------------------------------------------------------- /extension/src/progress/ProgressHandler.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | 3 | export class ProgressHandler { 4 | private readonly _onDidProgressStart: vscode.EventEmitter = new vscode.EventEmitter(); 5 | public readonly onDidProgressStart: vscode.Event = this._onDidProgressStart.event; 6 | 7 | public constructor( 8 | private readonly progress: vscode.Progress<{ message?: string }>, 9 | private readonly initialMessage?: string 10 | ) { 11 | if (this.initialMessage) { 12 | this.progress.report({ message: this.initialMessage }); 13 | } 14 | } 15 | 16 | public report(message: string): void { 17 | if (message.trim()) { 18 | this.progress.report({ message }); 19 | this._onDidProgressStart.fire(null); 20 | this._onDidProgressStart.dispose(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/PinnedTasksRootProjectTreeItem.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | import { TREE_ITEM_STATE_FOLDER } from "../constants"; 6 | 7 | export class PinnedTasksRootProjectTreeItem extends vscode.TreeItem { 8 | private children: vscode.TreeItem[] = []; 9 | 10 | constructor(name: string, resourceUri: vscode.Uri) { 11 | super(name, vscode.TreeItemCollapsibleState.Expanded); 12 | this.contextValue = TREE_ITEM_STATE_FOLDER; 13 | this.resourceUri = resourceUri; 14 | this.iconPath = vscode.ThemeIcon.Folder; 15 | } 16 | 17 | public setChildren(children: vscode.TreeItem[]): void { 18 | this.children = children; 19 | } 20 | 21 | public getChildren(): vscode.TreeItem[] { 22 | return this.children; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/ProjectTaskTreeItem.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export class ProjectTaskTreeItem extends vscode.TreeItem { 7 | private children: vscode.TreeItem[] | undefined; 8 | constructor( 9 | name: string, 10 | collapsibleState: vscode.TreeItemCollapsibleState, 11 | public readonly parentTreeItem: vscode.TreeItem, 12 | iconPath: vscode.ThemeIcon = new vscode.ThemeIcon("file-submodule") 13 | ) { 14 | super(name, collapsibleState); 15 | this.iconPath = iconPath; 16 | } 17 | 18 | public setChildren(children: vscode.TreeItem[]): void { 19 | this.children = children; 20 | } 21 | 22 | public getChildren(): vscode.TreeItem[] | undefined { 23 | return this.children; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | --- 7 | 8 | Extension Name: vscode-gradle 9 | Extension Version: 10 | OS Version: 11 | VSCode version: 12 | 13 | **Describe the bug** 14 | A clear and concise description of what the bug is. 15 | 16 | **To Reproduce** 17 | Steps to reproduce the behavior. 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots** 23 | If applicable, add screenshots to help explain your problem. 24 | 25 | **Output from "Gradle for Java"** 26 | You can find this by clicking on the "Output" panel, then selecting the "Gradle for Java" channel from the dropdown. 27 | 28 | **Does the bug still exist if you disable all other extensions?** 29 | Yes/No 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /extension/scripts/prepare-nightly-build.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | const json = JSON.parse(fs.readFileSync("./package.json").toString()); 4 | const stableVersion = json.version.match(/(\d+)\.(\d+)\.(\d+)/); 5 | const major = stableVersion[1]; 6 | const minor = stableVersion[2]; 7 | 8 | function prependZero(number) { 9 | if (number > 99) { 10 | throw "Unexpected value to prepend with zero"; 11 | } 12 | return `${number < 10 ? "0" : ""}${number}`; 13 | } 14 | 15 | const date = new Date(); 16 | const month = date.getMonth() + 1; 17 | const day = date.getDate(); 18 | const hours = date.getHours(); 19 | patch = `${date.getFullYear()}${prependZero(month)}${prependZero(day)}${prependZero(hours)}`; 20 | 21 | const insiderPackageJson = Object.assign(json, { 22 | version: `${major}.${minor}.${patch}`, 23 | }); 24 | 25 | fs.writeFileSync("./package.insiders.json", JSON.stringify(insiderPackageJson)); 26 | -------------------------------------------------------------------------------- /extension/src/commands/UnpinAllTasksCommand.ts: -------------------------------------------------------------------------------- 1 | import { confirmModal } from "../util/input"; 2 | import { PinnedTasksStore } from "../stores"; 3 | import { Command } from "./Command"; 4 | import { GradleTasksTreeDataProvider } from "../views"; 5 | 6 | export const COMMAND_UNPIN_ALL_TASKS = "gradle.unpinAllTasks"; 7 | 8 | export class UnpinAllTasksCommand extends Command { 9 | constructor( 10 | private pinnedTasksStore: PinnedTasksStore, 11 | private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider 12 | ) { 13 | super(); 14 | } 15 | async run(): Promise { 16 | if ( 17 | this.pinnedTasksStore.getData().size && 18 | (await confirmModal("Are you sure you want to clear the pinned tasks?")) 19 | ) { 20 | this.pinnedTasksStore.clear(); 21 | this.gradleTasksTreeDataProvider.refresh(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /extension/src/util/EventWaiter.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | 3 | type callback = () => void; 4 | 5 | export class EventWaiter { 6 | private eventRun = false; 7 | 8 | constructor(private readonly event: vscode.Event) { 9 | this.waitForEvent(); 10 | } 11 | 12 | public waitForEvent = (callback?: callback): void => { 13 | const disposable = this.event(() => { 14 | disposable.dispose(); 15 | this.eventRun = true; 16 | if (callback) { 17 | callback(); 18 | } 19 | }); 20 | }; 21 | 22 | public wait = (): Promise => { 23 | if (this.eventRun) { 24 | return Promise.resolve(); 25 | } 26 | return new Promise(this.waitForEvent); 27 | }; 28 | 29 | public reset(): void { 30 | this.eventRun = false; 31 | this.waitForEvent(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /extension/src/commands/PinTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTasksTreeDataProvider, GradleTaskTreeItem } from "../views"; 2 | import { GradleTaskDefinition } from "../tasks"; 3 | import { Command } from "./Command"; 4 | import { PinnedTasksStore } from "../stores"; 5 | 6 | export const COMMAND_PIN_TASK = "gradle.pinTask"; 7 | 8 | export class PinTaskCommand extends Command { 9 | constructor( 10 | private pinnedTasksStore: PinnedTasksStore, 11 | private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider 12 | ) { 13 | super(); 14 | } 15 | async run(treeItem: GradleTaskTreeItem): Promise { 16 | if (treeItem && treeItem.task) { 17 | const definition = treeItem.task.definition as GradleTaskDefinition; 18 | this.pinnedTasksStore.addEntry(definition.id, definition.args); 19 | this.gradleTasksTreeDataProvider.refresh(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /extension/resources/dark/stop-daemons.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /extension/src/util/DoubleClickChecker.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export class DoubleClickChecker { 7 | private lastDate: Date | undefined; 8 | private lastItem: vscode.TreeItem | undefined; 9 | 10 | private resetState(): void { 11 | this.lastDate = undefined; 12 | this.lastItem = undefined; 13 | } 14 | 15 | private setState(item: vscode.TreeItem): void { 16 | this.lastDate = new Date(); 17 | this.lastItem = item; 18 | } 19 | 20 | public checkDoubleClick(item: vscode.TreeItem): boolean { 21 | if (this.lastDate && new Date().getTime() - this.lastDate.getTime() < 500 && this.lastItem === item) { 22 | this.resetState(); 23 | return true; 24 | } 25 | this.setState(item); 26 | return false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/DependencyConfigurationTreeItem.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export class DependencyConfigurationTreeItem extends vscode.TreeItem { 7 | private children: vscode.TreeItem[]; 8 | constructor( 9 | name: string, 10 | collapsibleState: vscode.TreeItemCollapsibleState, 11 | public readonly parentTreeItem: vscode.TreeItem, 12 | iconPath: vscode.ThemeIcon = new vscode.ThemeIcon("folder-library") 13 | ) { 14 | super(name, collapsibleState); 15 | this.iconPath = iconPath; 16 | this.children = []; 17 | } 18 | 19 | public setChildren(children: vscode.TreeItem[]): void { 20 | this.children = children; 21 | } 22 | 23 | public getChildren(): vscode.TreeItem[] { 24 | return this.children; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/PinnedTasksTreeItem.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export class PinnedTasksTreeItem extends vscode.TreeItem { 7 | private children: vscode.TreeItem[] = []; 8 | public readonly parentTreeItem?: vscode.TreeItem; 9 | public readonly iconPath = new vscode.ThemeIcon("star-full"); 10 | public readonly contextValue = "PinnedTasks"; 11 | constructor(label: string, resourceUri?: vscode.Uri, collapsibleState = vscode.TreeItemCollapsibleState.Expanded) { 12 | super(label, collapsibleState); 13 | this.resourceUri = resourceUri; 14 | } 15 | 16 | public setChildren(children: vscode.TreeItem[]): void { 17 | this.children = children; 18 | } 19 | 20 | public getChildren(): vscode.TreeItem[] { 21 | return this.children; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /extension/resources/light/stop-daemons.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /extension/src/commands/UnpinTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTasksTreeDataProvider, GradleTaskTreeItem } from "../views"; 2 | import { GradleTaskDefinition } from "../tasks"; 3 | import { Command } from "./Command"; 4 | import { PinnedTasksStore } from "../stores"; 5 | 6 | export const COMMAND_UNPIN_TASK = "gradle.unpinTask"; 7 | 8 | export class UnpinTaskCommand extends Command { 9 | constructor( 10 | private pinnedTasksStore: PinnedTasksStore, 11 | private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider 12 | ) { 13 | super(); 14 | } 15 | async run(treeItem: GradleTaskTreeItem): Promise { 16 | if (treeItem && treeItem.task) { 17 | const definition = treeItem.task.definition as GradleTaskDefinition; 18 | this.pinnedTasksStore.removeEntry(definition.id, definition.args); 19 | this.gradleTasksTreeDataProvider.refresh(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /extension/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "experimentalDecorators": true, 4 | "module": "commonjs", 5 | "target": "ES2017", 6 | "outDir": "out", 7 | "lib": ["ES6", "ES2018.promise", "ES2019.array", "DOM"], 8 | "sourceMap": true, 9 | "rootDir": "src", 10 | "noUnusedLocals": true, 11 | "noImplicitThis": true, 12 | "noImplicitAny": true, 13 | "noImplicitReturns": true, 14 | "noUnusedParameters": true, 15 | "strictNullChecks": true, 16 | "alwaysStrict": true, 17 | "skipLibCheck": true, 18 | "allowJs": true, // to support compiling the generated proto js files 19 | "allowSyntheticDefaultImports": true, 20 | "declaration": true, 21 | "declarationDir": "dist" 22 | }, 23 | "exclude": ["node_modules", ".vscode-test", "build", "beta", "scripts"], 24 | "include": ["./src"] 25 | } 26 | -------------------------------------------------------------------------------- /extension/src/commands/RunTaskWithArgsCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { runTaskWithArgs } from "../tasks/taskUtil"; 3 | import { logger } from "../logger"; 4 | import { Command } from "./Command"; 5 | import { RootProjectsStore } from "../stores"; 6 | import { TaskServerClient } from "../client"; 7 | export const COMMAND_RUN_TASK_WITH_ARGS = "gradle.runTaskWithArgs"; 8 | 9 | export class RunTaskWithArgsCommand extends Command { 10 | constructor(private rootProjectsStore: RootProjectsStore, private client: TaskServerClient) { 11 | super(); 12 | } 13 | async run(treeItem: GradleTaskTreeItem): Promise { 14 | if (treeItem && treeItem.task) { 15 | await runTaskWithArgs(this.rootProjectsStore, treeItem.task, this.client, false); 16 | } else { 17 | logger.error("Unable to run task with args. TreeItem or TreeItem task not found."); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /extension/src/commands/DebugTaskWithArgsCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { runTaskWithArgs } from "../tasks/taskUtil"; 3 | import { logger } from "../logger"; 4 | import { Command } from "./Command"; 5 | import { RootProjectsStore } from "../stores"; 6 | import { TaskServerClient } from "../client"; 7 | export const COMMAND_DEBUG_TASK_WITH_ARGS = "gradle.debugTaskWithArgs"; 8 | 9 | export class DebugTaskWithArgsCommand extends Command { 10 | constructor(private rootProjectsStore: RootProjectsStore, private client: TaskServerClient) { 11 | super(); 12 | } 13 | async run(treeItem: GradleTaskTreeItem): Promise { 14 | if (treeItem && treeItem.task) { 15 | await runTaskWithArgs(this.rootProjectsStore, treeItem.task, this.client, true); 16 | } else { 17 | logger.error("Unable to debug task with args. TreeItem or TreeItem task not found."); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /extension/src/commands/ReloadJavaProjectsCommand.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | import { getProjectTreeItemMap } from "../views/gradleTasks/GradleTasksTreeDataProvider"; 6 | import { Command } from "./Command"; 7 | export const COMMAND_RELOAD_JAVA_PROJECT = "gradle.java.projectConfiguration.update"; 8 | 9 | export class ReloadJavaProjectsCommand extends Command { 10 | constructor() { 11 | super(); 12 | } 13 | async run(): Promise { 14 | const projectsMap = getProjectTreeItemMap(); 15 | if (projectsMap?.size) { 16 | // call Reload All Java Projects in redhat.java 17 | vscode.commands.executeCommand( 18 | "java.projectConfiguration.update", 19 | Array.from(projectsMap.keys()).map((p) => vscode.Uri.file(p)) 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/java/com/microsoft/gradle/DefaultGradleMethod.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle; 5 | 6 | import com.microsoft.gradle.api.GradleMethod; 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | public class DefaultGradleMethod implements Serializable, GradleMethod { 11 | private String name; 12 | private List parameterTypes; 13 | private boolean deprecated; 14 | 15 | public DefaultGradleMethod(String name, List parameterTypes, boolean deprecated) { 16 | this.name = name; 17 | this.parameterTypes = parameterTypes; 18 | this.deprecated = deprecated; 19 | } 20 | 21 | public String getName() { 22 | return this.name; 23 | } 24 | 25 | public List getParameterTypes() { 26 | return this.parameterTypes; 27 | } 28 | 29 | public boolean getDeprecated() { 30 | return this.deprecated; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerProjectNature.java: -------------------------------------------------------------------------------- 1 | package com.microsoft.gradle.bs.importer; 2 | 3 | import org.eclipse.core.resources.IProject; 4 | import org.eclipse.core.resources.IProjectNature; 5 | import org.eclipse.core.runtime.CoreException; 6 | 7 | public class GradleBuildServerProjectNature implements IProjectNature { 8 | public static final String NATURE_ID = "com.microsoft.gradle.bs.importer.GradleBuildServerProjectNature"; 9 | 10 | private IProject project; 11 | 12 | @Override 13 | public void configure() throws CoreException { 14 | 15 | } 16 | 17 | @Override 18 | public void deconfigure() throws CoreException { 19 | 20 | } 21 | 22 | @Override 23 | public IProject getProject() { 24 | return project; 25 | } 26 | 27 | @Override 28 | public void setProject(IProject project) { 29 | this.project = project; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /extension/src/icons/Icons.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import * as path from "path"; 3 | import { ICON_LOADING, ICON_GRADLE_TASK } from "../views/constants"; 4 | 5 | export type IconPath = { 6 | light: string | vscode.Uri; 7 | dark: string | vscode.Uri; 8 | }; 9 | 10 | export class Icons { 11 | public iconPathRunning?: IconPath; 12 | public iconPathIdle?: IconPath; 13 | 14 | constructor(private readonly context: vscode.ExtensionContext) { 15 | this.iconPathRunning = { 16 | light: this.context.asAbsolutePath(path.join("resources", "light", ICON_LOADING)), 17 | dark: this.context.asAbsolutePath(path.join("resources", "dark", ICON_LOADING)), 18 | }; 19 | this.iconPathIdle = { 20 | light: this.context.asAbsolutePath(path.join("resources", "light", ICON_GRADLE_TASK)), 21 | dark: this.context.asAbsolutePath(path.join("resources", "dark", ICON_GRADLE_TASK)), 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/model/JavaTestStatus.java: -------------------------------------------------------------------------------- 1 | package com.microsoft.gradle.bs.importer.model; 2 | 3 | public enum JavaTestStatus { 4 | /** 5 | * Test will be run, but is not currently running. 6 | */ 7 | Queued(1), 8 | 9 | /** 10 | * Test is currently running. 11 | */ 12 | Running(2), 13 | 14 | /** 15 | * Test run has passed. 16 | */ 17 | Passed(3), 18 | 19 | /** 20 | * Test run has failed (on an assertion). 21 | */ 22 | Failed(4), 23 | 24 | /** 25 | * Test run has been skipped. 26 | */ 27 | Skipped(5), 28 | 29 | /** 30 | * Test run failed for some other reason (compilation error, timeout, etc). 31 | */ 32 | Errored(6); 33 | 34 | private final int value; 35 | 36 | JavaTestStatus(int value) { 37 | this.value = value; 38 | } 39 | 40 | public int getValue() { 41 | return value; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /gradle-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-gradle-plugin' 3 | } 4 | 5 | configurations { 6 | bundled 7 | } 8 | 9 | java { 10 | sourceCompatibility = JavaVersion.VERSION_1_8 11 | targetCompatibility = JavaVersion.VERSION_1_8 12 | } 13 | 14 | dependencies { 15 | implementation project(":gradle-plugin-api") 16 | bundled(project(":gradle-plugin-api")) { 17 | transitive = false 18 | } 19 | } 20 | 21 | jar { 22 | from { 23 | configurations.bundled.collect { 24 | it.isDirectory() ? it : zipTree(it) 25 | } 26 | } 27 | } 28 | 29 | task copyJar(type: Copy) { 30 | from "build/libs/gradle-plugin.jar" 31 | into "../gradle-server/src/main/resources" 32 | } 33 | 34 | spotless { 35 | java { 36 | importOrder() 37 | eclipse() 38 | removeUnusedImports() 39 | trimTrailingWhitespace() 40 | targetExclude "build/**" 41 | } 42 | } 43 | 44 | tasks.build.dependsOn tasks.copyJar 45 | tasks.copyJar.dependsOn tasks.jar 46 | compileJava.dependsOn 'spotlessCheck' 47 | -------------------------------------------------------------------------------- /extension/src/commands/CloseTaskTerminalsCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { GradleTaskDefinition } from "../tasks"; 3 | import { Command } from "./Command"; 4 | import { TaskTerminalsStore } from "../stores"; 5 | 6 | export const COMMAND_CLOSE_TASK_TERMINALS = "gradle.closeTaskTerminals"; 7 | 8 | export class CloseTaskTerminalsCommand extends Command { 9 | constructor(private taskTerminalsStore: TaskTerminalsStore) { 10 | super(); 11 | } 12 | async run(treeItem: GradleTaskTreeItem): Promise { 13 | if (treeItem && treeItem.task) { 14 | const definition = treeItem.task.definition as GradleTaskDefinition; 15 | const terminalsSet = this.taskTerminalsStore.getItem(definition.id + definition.args); 16 | if (terminalsSet) { 17 | Array.from(terminalsSet).forEach((terminal) => { 18 | terminal.dispose(); 19 | }); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /extension/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { initializeFromJsonFile, instrumentOperation } from "vscode-extension-telemetry-wrapper"; 3 | import { Api } from "./api"; 4 | import { Extension } from "./Extension"; 5 | import { TelemetryFilter } from "./util/telemetryFilter"; 6 | 7 | let extension: Extension; 8 | 9 | export async function activate(context: vscode.ExtensionContext): Promise { 10 | await initializeFromJsonFile(context.asAbsolutePath("./package.json"), { 11 | replacementOptions: [TelemetryFilter.hideUrlOption], 12 | }); 13 | return instrumentOperation("activation", activateExtension)(context); 14 | } 15 | 16 | function activateExtension(_operationId: string, context: vscode.ExtensionContext): Api { 17 | extension = new Extension(context); 18 | return extension.getApi(); 19 | } 20 | 21 | // eslint-disable-next-line @typescript-eslint/no-empty-function 22 | export async function deactivate(): Promise { 23 | await extension?.stop(); 24 | } 25 | -------------------------------------------------------------------------------- /extension/src/stores/StoreMapSet.ts: -------------------------------------------------------------------------------- 1 | import { StoreMap } from "./StoreMap"; 2 | 3 | export class StoreMapSet extends StoreMap> { 4 | public addEntry(key: K, value: V, fireOnDidChange = true): void { 5 | let set = this.getItem(key); 6 | if (!set) { 7 | set = new Set(); 8 | this.setItem(key, set, false); 9 | } 10 | if (!set.has(value)) { 11 | set.add(value); 12 | if (fireOnDidChange) { 13 | this.fireOnDidChange(set); 14 | } 15 | } 16 | } 17 | 18 | public removeEntry(key: K, value: V, fireOnDidChange = true): void { 19 | const set = this.getItem(key); 20 | if (set && set.has(value)) { 21 | set.delete(value); 22 | if (set.size === 0) { 23 | this.removeItem(key, false); 24 | } 25 | if (fireOnDidChange) { 26 | this.fireOnDidChange(set); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /extension/src/commands/FindTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { GradleTaskProvider } from "../tasks"; 3 | import { getFindTask } from "../util/input"; 4 | import { focusTaskInGradleTasksTree } from "../views/viewUtil"; 5 | import { Command } from "./Command"; 6 | 7 | export const COMMAND_FIND_TASK = "gradle.findTask"; 8 | 9 | export class FindTaskCommand extends Command { 10 | constructor( 11 | private readonly gradleTasksTreeView: vscode.TreeView, 12 | private readonly gradleTaskProvider: GradleTaskProvider 13 | ) { 14 | super(); 15 | } 16 | async run(): Promise { 17 | const foundTaskName = await getFindTask(this.gradleTaskProvider); 18 | if (foundTaskName) { 19 | const vscodeTask = this.gradleTaskProvider.getTasks().find((task) => task.name === foundTaskName); 20 | if (vscodeTask) { 21 | await focusTaskInGradleTasksTree(vscodeTask, this.gradleTasksTreeView); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/utils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | import { GradleTaskTreeItem } from "."; 6 | import { Icons } from "../../icons"; 7 | import { GradleTaskDefinition } from "../../tasks"; 8 | import { PinnedTasksTreeItem } from "./PinnedTasksTreeItem"; 9 | 10 | export function buildPinnedTaskTreeItem( 11 | parentTreeItem: PinnedTasksTreeItem, 12 | task: vscode.Task, 13 | icons: Icons 14 | ): GradleTaskTreeItem { 15 | const definition = task.definition as GradleTaskDefinition; 16 | definition.isPinned = true; 17 | const taskName = task.name; 18 | const pinnedTaskTreeItem = new GradleTaskTreeItem( 19 | parentTreeItem, 20 | task, 21 | taskName, 22 | definition.description || taskName, // tooltip 23 | "", // description 24 | icons, 25 | definition.javaDebug 26 | ); 27 | pinnedTaskTreeItem.setContext(); 28 | return pinnedTaskTreeItem; 29 | } 30 | -------------------------------------------------------------------------------- /extension/jdtls.ext/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /extension/src/test/integration/no-gradle/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from "assert"; 2 | import * as vscode from "vscode"; 3 | import { Api } from "../../../api"; 4 | import { EXTENSION_NAME } from "../../testUtil"; 5 | 6 | describe("without any build file or local gradle wrapper", () => { 7 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 8 | let extension: vscode.Extension | undefined; 9 | 10 | before(() => { 11 | extension = vscode.extensions.getExtension(EXTENSION_NAME); 12 | }); 13 | 14 | it("should be present", () => { 15 | assert.ok(extension); 16 | }); 17 | 18 | it("should not be activated", async () => { 19 | assert.ok(extension); 20 | assert.strictEqual(extension.isActive, false); 21 | // This promise never resolves. Seems like this behaviour was changed in vscode-1.45.0 22 | // const tasks = await vscode.tasks.fetchTasks({ 23 | // type: 'fooo', 24 | // }); 25 | // assert.strictEqual(tasks.length === 0, true); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /extension/src/commands/CloseAllTaskTerminalsCommand.ts: -------------------------------------------------------------------------------- 1 | import { confirmModal } from "../util/input"; 2 | import { TaskTerminalsStore } from "../stores"; 3 | import { Command } from "./Command"; 4 | 5 | export const COMMAND_CLOSE_ALL_TASK_TERMINALS = "gradle.closeAllTaskTerminals"; 6 | 7 | export class CloseAllTaskTerminalsCommand extends Command { 8 | constructor(private taskTerminalsStore: TaskTerminalsStore) { 9 | super(); 10 | } 11 | async run(): Promise { 12 | if ( 13 | this.taskTerminalsStore.getData().size && 14 | (await confirmModal("Are you sure you want to close all task terminals?")) 15 | ) { 16 | Array.from(this.taskTerminalsStore.getData().keys()).forEach((key) => { 17 | const terminalsSet = this.taskTerminalsStore.getItem(key); 18 | if (terminalsSet) { 19 | Array.from(terminalsSet).forEach((terminal) => terminal.dispose()); 20 | } 21 | }); 22 | this.taskTerminalsStore.clear(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extension/src/commands/RefreshCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleBuildContentProvider } from "../client/GradleBuildContentProvider"; 2 | import { GradleTaskProvider } from "../tasks"; 3 | import { GradleTasksTreeDataProvider, RecentTasksTreeDataProvider } from "../views"; 4 | import { Command } from "./Command"; 5 | export const COMMAND_REFRESH = "gradle.refresh"; 6 | 7 | export class RefreshCommand extends Command { 8 | constructor( 9 | private gradleTaskProvider: GradleTaskProvider, 10 | private gradleBuildContentProvider: GradleBuildContentProvider, 11 | private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider, 12 | private recentTasksTreeDataProvider: RecentTasksTreeDataProvider 13 | ) { 14 | super(); 15 | } 16 | async run(): Promise { 17 | this.gradleTaskProvider.clearTasksCache(); 18 | this.gradleBuildContentProvider.refresh(); 19 | void this.gradleTaskProvider.loadTasks(); 20 | this.gradleTasksTreeDataProvider.refresh(); 21 | this.recentTasksTreeDataProvider.refresh(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /extension/src/commands/PinTaskWithArgsCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTasksTreeDataProvider, GradleTaskTreeItem } from "../views"; 2 | import { GradleTaskDefinition } from "../tasks"; 3 | import { getTaskArgs } from "../util/input"; 4 | import { Command } from "./Command"; 5 | import { PinnedTasksStore } from "../stores"; 6 | 7 | export const COMMAND_PIN_TASK_WITH_ARGS = "gradle.pinTaskWithArgs"; 8 | 9 | export class PinTaskWithArgsCommand extends Command { 10 | constructor( 11 | private pinnedTasksStore: PinnedTasksStore, 12 | private gradleTasksTreeDataProvider: GradleTasksTreeDataProvider 13 | ) { 14 | super(); 15 | } 16 | async run(treeItem: GradleTaskTreeItem): Promise { 17 | if (treeItem && treeItem.task) { 18 | const args = await getTaskArgs(); 19 | if (args) { 20 | const definition = treeItem.task.definition as GradleTaskDefinition; 21 | this.pinnedTasksStore.addEntry(definition.id, args); 22 | this.gradleTasksTreeDataProvider.refresh(); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /extension/src/commands/ShowTaskTerminalCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { GradleTaskDefinition } from "../tasks"; 3 | import { Command } from "./Command"; 4 | import { TaskTerminalsStore } from "../stores"; 5 | 6 | export const COMMAND_SHOW_TASK_TERMINAL = "gradle.showTaskTerminal"; 7 | 8 | export class ShowTaskTerminalCommand extends Command { 9 | constructor(private taskTerminalsStore: TaskTerminalsStore) { 10 | super(); 11 | } 12 | async run(treeItem: GradleTaskTreeItem): Promise { 13 | if (treeItem && treeItem.task) { 14 | const definition = treeItem.task.definition as GradleTaskDefinition; 15 | const terminalsSet = this.taskTerminalsStore.getItem(definition.id + definition.args); 16 | if (terminalsSet) { 17 | const terminals = Array.from(terminalsSet); 18 | const mostRecentTerminal = terminals.pop(); 19 | if (mostRecentTerminal) { 20 | mostRecentTerminal.show(); 21 | } 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extension/syntaxes/GradleBuild.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Gradle Build", 3 | "scopeName": "source.gradle-build", 4 | "fileTypes": ["gradle-build"], 5 | "patterns": [ 6 | { 7 | "name": "FAILURE", 8 | "match": "(^FAILURE: .+$)", 9 | "captures": { 10 | "1": { "name": "invalid.illegal.failure" } 11 | } 12 | }, 13 | { 14 | "name": "error", 15 | "match": "(^\\d+\\serror$)", 16 | "captures": { 17 | "1": { "name": "invalid.illegal.error" } 18 | } 19 | }, 20 | { 21 | "name": "error.description", 22 | "match": "(error:\\s.+$)", 23 | "captures": { 24 | "1": { "name": "invalid.illegal.error.description" } 25 | } 26 | }, 27 | { 28 | "name": "BUILD FAILED", 29 | "match": "(^BUILD FAILED)", 30 | "captures": { 31 | "1": { "name": "invalid.illegal.bold.buildFailed" } 32 | } 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /API.md: -------------------------------------------------------------------------------- 1 | # Extension API 2 | 3 | ```ts 4 | interface ExtensionApi { 5 | runTask(opts: RunTaskOpts): Promise; 6 | cancelRunTask(opts: CancelTaskOpts): Promise; 7 | } 8 | ``` 9 | 10 | ## Installation 11 | 12 | ```bash 13 | npm install vscode-gradle --save 14 | ``` 15 | 16 | ## Usage 17 | 18 | ```ts 19 | import * as util from "util"; 20 | import { ExtensionApi as GradleApi, RunTaskOpts, Output } from "vscode-gradle"; 21 | 22 | const extension = vscode.extensions.getExtension("vscjava.vscode-gradle"); 23 | const gradleApi = extension!.exports as GradleApi; 24 | const runTaskOpts: RunTaskOpts = { 25 | projectFolder: "/absolute/path/to/project/root", 26 | taskName: "help", 27 | showOutputColors: false, 28 | onOutput: (output: Output): void => { 29 | const message = new util.TextDecoder("utf-8").decode( 30 | output.getOutputBytes_asU8() 31 | ); 32 | console.log(output.getOutputType(), message); 33 | }, 34 | }; 35 | await gradleApi.runTask(runTaskOpts); 36 | ``` 37 | 38 | Refer to [vscode-spotless-gradle](https://github.com/badsyntax/vscode-spotless-gradle) for example API usage. 39 | -------------------------------------------------------------------------------- /extension/src/commands/RunTasksCommand.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | import { GradleTaskProvider } from "../tasks"; 6 | import { getRunTasks } from "../util/input"; 7 | import { Command } from "./Command"; 8 | 9 | export const COMMAND_RUN_TASKS = "gradle.runTasks"; 10 | 11 | export class RunTasksCommand extends Command { 12 | constructor(private readonly gradleTaskProvider: GradleTaskProvider) { 13 | super(); 14 | } 15 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 16 | async run(item?: any): Promise { 17 | if (item?.uri) { 18 | const foundTaskName = await getRunTasks(this.gradleTaskProvider, item.uri); 19 | if (foundTaskName) { 20 | const vscodeTask = this.gradleTaskProvider.getTasks().find((task) => task.name === foundTaskName); 21 | if (vscodeTask) { 22 | await vscode.tasks.executeTask(vscodeTask); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Richard Willis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /extension/src/createProject/types.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import { TaskServerClient } from "../client"; 5 | 6 | export interface IProjectCreationMetadata { 7 | isAdvanced: boolean; 8 | totalSteps: number; 9 | projectType?: ProjectType; 10 | scriptDSL?: string; 11 | testFramework?: TestFramework; 12 | projectName: string; // default: folderName 13 | sourcePackageName?: string; //default: folderName 14 | targetFolder: string; 15 | steps: IProjectCreationStep[]; 16 | nextStep?: IProjectCreationStep; 17 | client: TaskServerClient; 18 | } 19 | 20 | export interface IProjectCreationStep { 21 | run(metadata: IProjectCreationMetadata): Promise; 22 | } 23 | 24 | export enum StepResult { 25 | NEXT, 26 | STOP, 27 | PREVIOUS, 28 | } 29 | 30 | export enum ProjectType { 31 | JAVA_APPLICATION = "java-application", 32 | JAVA_LIBRARY = "java-library", 33 | JAVA_GRADLE_PLUGIN = "java-gradle-plugin", 34 | } 35 | 36 | export enum TestFramework { 37 | TESTNG = "testng", 38 | SPOCK = "spock", 39 | JUNIT_JUPITER = "junit-jupiter", 40 | } 41 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/jpms/JpmsArgValue.java: -------------------------------------------------------------------------------- 1 | package com.microsoft.gradle.bs.importer.jpms; 2 | 3 | import java.util.Objects; 4 | 5 | public class JpmsArgValue { 6 | private final String module; 7 | 8 | private final String value; 9 | 10 | public JpmsArgValue(String module, String value) { 11 | this.module = module; 12 | this.value = value; 13 | } 14 | 15 | public String getModule() { 16 | return this.module; 17 | } 18 | 19 | public String getValue() { 20 | return this.value; 21 | } 22 | 23 | @Override 24 | public int hashCode() { 25 | return Objects.hash(module, value); 26 | } 27 | 28 | @Override 29 | public boolean equals(Object obj) { 30 | if (this == obj) { 31 | return true; 32 | } 33 | if (obj == null) { 34 | return false; 35 | } 36 | if (getClass() != obj.getClass()) { 37 | return false; 38 | } 39 | JpmsArgValue other = (JpmsArgValue) obj; 40 | return Objects.equals(module, other.module) && Objects.equals(value, other.value); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/ProjectDependencyTreeItem.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export class ProjectDependencyTreeItem extends vscode.TreeItem { 7 | private children: vscode.TreeItem[] | undefined; 8 | constructor( 9 | name: string, 10 | collapsibleState: vscode.TreeItemCollapsibleState, 11 | public readonly parentTreeItem: vscode.TreeItem, 12 | readonly projectPath: string, 13 | readonly projectName: string, 14 | iconPath: vscode.ThemeIcon = new vscode.ThemeIcon("folder-library") 15 | ) { 16 | super(name, collapsibleState); 17 | this.iconPath = iconPath; 18 | } 19 | 20 | public setChildren(children: vscode.TreeItem[]): void { 21 | this.children = children; 22 | } 23 | 24 | public getChildren(): vscode.TreeItem[] | undefined { 25 | return this.children; 26 | } 27 | 28 | public getProjectPath(): string { 29 | return this.projectPath; 30 | } 31 | 32 | public getProjectName(): string { 33 | return this.projectName; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Gradle: Build", 6 | "type": "shell", 7 | "problemMatcher": [], 8 | "command": "./gradlew", 9 | "windows": { 10 | "command": ".\\gradlew.bat" 11 | }, 12 | "args": [ 13 | "build", 14 | "-x", 15 | "test", 16 | ], 17 | "presentation": { 18 | "reveal": "always" 19 | }, 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | } 24 | }, 25 | { 26 | "label": "Gradle: Build Test", 27 | "type": "shell", 28 | "problemMatcher": [], 29 | "command": "./gradlew", 30 | "windows": { 31 | "command": ".\\gradlew.bat" 32 | }, 33 | "args": [ 34 | "build", 35 | "extension:buildDev", 36 | "-x", 37 | "extension:buildProd", 38 | "-x", 39 | "test", 40 | "-x", 41 | "npm-package:build" 42 | ], 43 | "presentation": { 44 | "reveal": "always" 45 | }, 46 | "group": { 47 | "kind": "build", 48 | "isDefault": true 49 | } 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /extension/src/stores/StoreMap.ts: -------------------------------------------------------------------------------- 1 | import { EventedStore } from "."; 2 | 3 | export abstract class StoreMap extends EventedStore { 4 | private readonly data = new Map(); 5 | 6 | public getItem(key: K): V | void { 7 | return this.data.get(key); 8 | } 9 | 10 | public getData(): Map { 11 | return this.data; 12 | } 13 | 14 | public get(key: K): V | undefined { 15 | return this.getData().get(key); 16 | } 17 | 18 | public clear(fireOnDidChange = true): void { 19 | this.data.clear(); 20 | if (fireOnDidChange) { 21 | this.fireOnDidChange(null); 22 | } 23 | } 24 | 25 | public setItem(key: K, value: V, fireOnDidChange = true): void { 26 | this.data.set(key, value); 27 | if (fireOnDidChange) { 28 | this.fireOnDidChange(value); 29 | } 30 | } 31 | 32 | public removeItem(key: K, fireOnDidChange = true): void { 33 | const item = this.data.get(key); 34 | if (item) { 35 | this.data.delete(key); 36 | if (fireOnDidChange) { 37 | this.fireOnDidChange(item); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/DependencyTreeItem.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | 6 | export class DependencyTreeItem extends vscode.TreeItem { 7 | private children: vscode.TreeItem[] | undefined; 8 | private omittedTreeItem: vscode.TreeItem | undefined; 9 | constructor( 10 | name: string, 11 | collapsibleState: vscode.TreeItemCollapsibleState, 12 | public readonly parentTreeItem: vscode.TreeItem, 13 | iconPath: vscode.ThemeIcon = new vscode.ThemeIcon("library") 14 | ) { 15 | super(name, collapsibleState); 16 | this.iconPath = iconPath; 17 | } 18 | 19 | public setChildren(children: vscode.TreeItem[]): void { 20 | this.children = children; 21 | } 22 | 23 | public getChildren(): vscode.TreeItem[] | undefined { 24 | return this.children; 25 | } 26 | 27 | public setOmittedTreeItem(item: vscode.TreeItem): void { 28 | this.omittedTreeItem = item; 29 | } 30 | 31 | public getOmittedTreeItem(): vscode.TreeItem | undefined { 32 | return this.omittedTreeItem; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /extension/resources/dark/circle-filled.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /extension/resources/light/circle-filled.svg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/java/com/microsoft/gradle/DefaultGradleClosure.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle; 5 | 6 | import com.microsoft.gradle.api.GradleClosure; 7 | import com.microsoft.gradle.api.GradleField; 8 | import com.microsoft.gradle.api.GradleMethod; 9 | import java.io.Serializable; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class DefaultGradleClosure implements GradleClosure, Serializable { 14 | private String name; 15 | private List methods; 16 | private List fields; 17 | 18 | public DefaultGradleClosure(String name, List methods, List fields) { 19 | this.name = name; 20 | this.methods = methods; 21 | this.fields = fields; 22 | } 23 | 24 | public DefaultGradleClosure(String name, List methods) { 25 | this(name, methods, Collections.emptyList()); 26 | } 27 | 28 | public String getName() { 29 | return this.name; 30 | } 31 | 32 | public List getMethods() { 33 | return this.methods; 34 | } 35 | 36 | public List getFields() { 37 | return this.fields; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /npm-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-gradle", 3 | "displayName": "Gradle Tasks", 4 | "description": "Type definitions for the Gradle Tasks vscode extension", 5 | "version": "0.0.0", 6 | "author": "Richard Willis ", 7 | "maintainers": [ 8 | "Richard Willis " 9 | ], 10 | "bugs": { 11 | "url": "https://github.com/badsyntax/vscode-gradle/issues" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/badsyntax/vscode-gradle/" 16 | }, 17 | "license": "MIT", 18 | "main": "./index.js", 19 | "types": "./index.ts", 20 | "engines": { 21 | "node": "^18.20.4", 22 | "npm": "^10.7.0" 23 | }, 24 | "scripts": { 25 | "compile": "tsc -p ." 26 | }, 27 | "dependencies": { 28 | "@grpc/grpc-js": "^1.6.7", 29 | "@types/google-protobuf": "^3.15.6", 30 | "@types/vscode": "^1.63.0" 31 | }, 32 | "devDependencies": { 33 | "@typescript-eslint/eslint-plugin": "^5.22.0", 34 | "@typescript-eslint/parser": "^5.22.0", 35 | "eslint": "^8.14.0", 36 | "eslint-config-prettier": "^8.5.0", 37 | "eslint-plugin-prettier": "^4.0.0", 38 | "prettier": "^2.6.2", 39 | "typescript": "^4.6.4" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /extension/src/commands/CancelTreeItemTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { GradleTaskTreeItem } from "../views"; 3 | import { COMMAND_CANCEL_BUILD } from "."; 4 | import { getRunTaskCommandCancellationKey } from "../client/CancellationKeys"; 5 | import { GradleTaskDefinition } from "../tasks"; 6 | import { getRunningGradleTask } from "../tasks/taskUtil"; 7 | import { Command } from "./Command"; 8 | export const COMMAND_CANCEL_TREE_ITEM_TASK = "gradle.cancelTreeItemTask"; 9 | 10 | export class CancelTreeItemTaskCommand extends Command { 11 | async run(treeItem: GradleTaskTreeItem): Promise { 12 | if (treeItem && treeItem.task) { 13 | // We get the running task as we could be cancelling a task that is running with args 14 | const runningTask = getRunningGradleTask(treeItem.task); 15 | if (!runningTask) { 16 | return; 17 | } 18 | const definition = runningTask.definition as GradleTaskDefinition; 19 | const cancellationKey = getRunTaskCommandCancellationKey(definition.projectFolder, runningTask.name); 20 | return vscode.commands.executeCommand(COMMAND_CANCEL_BUILD, cancellationKey, runningTask); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gradle-language-server/src/main/java/com/microsoft/gradle/handlers/DefaultDependenciesHandler.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.handlers; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import org.eclipse.lsp4j.DocumentSymbol; 9 | import org.eclipse.lsp4j.Range; 10 | 11 | public class DefaultDependenciesHandler { 12 | public class DefaultDependencyItem { 13 | private String name; 14 | private String configuration; 15 | private Range range; 16 | 17 | public DefaultDependencyItem(String name, String configuration, Range range) { 18 | this.name = name; 19 | this.configuration = configuration; 20 | this.range = range; 21 | } 22 | } 23 | 24 | public List getDefaultDependencies(List symbols) { 25 | List dependencies = new ArrayList<>(); 26 | for (DocumentSymbol symbol : symbols) { 27 | String configuration = symbol.getName(); 28 | String id = symbol.getDetail(); 29 | Range range = symbol.getRange(); 30 | DefaultDependencyItem item = new DefaultDependencyItem(id, configuration, range); 31 | dependencies.add(item); 32 | } 33 | return dependencies; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gradle-language-server/src/main/java/com/microsoft/gradle/semantictokens/TokenModifier.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle.semantictokens; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | import org.eclipse.lsp4j.SemanticTokenModifiers; 9 | 10 | public enum TokenModifier { 11 | 12 | DEFAULT_LIBRARY(SemanticTokenModifiers.DefaultLibrary); 13 | 14 | private String genericName; 15 | // See https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html 16 | private static List defaultLibrary = Arrays.asList("afterEvaluate", "allprojects", "ant", "apply", 17 | "artifacts", "beforeEvaluate", "buildscript", "configurations", "configure", "copy", "copySpec", 18 | "dependencies", "javaexec", "repositories", "subprojects", "task"); 19 | 20 | public final int bitmask = 1 << ordinal(); 21 | 22 | TokenModifier(String genericName) { 23 | this.genericName = genericName; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return genericName; 29 | } 30 | 31 | public static boolean isDefaultLibrary(String method) { 32 | if (TokenModifier.defaultLibrary.contains(method)) { 33 | return true; 34 | } 35 | return false; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/GradleDaemonTreeItem.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import * as path from "path"; 3 | import { DAEMON_ICON_MAP } from "../constants"; 4 | import { DaemonInfo } from "./models/DaemonInfo"; 5 | import { DaemonStatus } from "./models/DaemonStatus"; 6 | 7 | export class GradleDaemonTreeItem extends vscode.TreeItem { 8 | private status: string; 9 | constructor( 10 | private readonly context: vscode.ExtensionContext, 11 | public readonly label: string, 12 | private readonly daemonInfo: DaemonInfo 13 | ) { 14 | super(label, vscode.TreeItemCollapsibleState.None); 15 | const iconName = DAEMON_ICON_MAP[daemonInfo.getStatus()]; 16 | this.iconPath = { 17 | light: this.context.asAbsolutePath(path.join("resources", "light", iconName)), 18 | dark: this.context.asAbsolutePath(path.join("resources", "dark", iconName)), 19 | }; 20 | this.status = DaemonStatus[daemonInfo.getStatus()]; 21 | this.description = this.status; 22 | this.contextValue = this.status.toLowerCase(); 23 | this.tooltip = `${this.status} - ${daemonInfo.getInfo()}`; 24 | } 25 | 26 | public get pid(): string { 27 | return this.daemonInfo.getPid(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "out": false 4 | }, 5 | "search.exclude": { 6 | "out": true 7 | }, 8 | "typescript.tsc.autoDetect": "off", 9 | "eslint.validate": ["javascript", "typescript"], 10 | "eslint.workingDirectories": ["extension","npm-package"], 11 | "java.configuration.updateBuildConfiguration": "automatic", 12 | "cSpell.language": "en-GB", 13 | "cSpell.words": [ 14 | "Grpc", 15 | "Proto", 16 | "Protobuf", 17 | "linting" 18 | ], 19 | "editor.formatOnSave": false, 20 | "editor.codeActionsOnSave": { 21 | "source.fixAll.eslint": "explicit" 22 | }, 23 | "[markdown]": { 24 | "editor.defaultFormatter": "esbenp.prettier-vscode" 25 | }, 26 | "[json]": { 27 | "editor.defaultFormatter": "esbenp.prettier-vscode" 28 | }, 29 | "[yaml]": { 30 | "editor.defaultFormatter": "esbenp.prettier-vscode" 31 | }, 32 | "[java]": { 33 | "editor.defaultFormatter": "redhat.java", 34 | "editor.codeActionsOnSave": { 35 | "source.fixAll.spotlessGradle": "explicit" 36 | } 37 | }, 38 | "[xml]": { 39 | "editor.defaultFormatter": "esbenp.prettier-vscode" 40 | }, 41 | "files.insertFinalNewline": true, 42 | "files.trimTrailingWhitespace": true, 43 | "java.compile.nullAnalysis.mode": "disabled" 44 | } 45 | -------------------------------------------------------------------------------- /extension/src/rootProject/RootProject.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { sendInfo } from "vscode-extension-telemetry-wrapper"; 3 | import { Environment } from "../proto/gradle_pb"; 4 | import { isTest } from "../util"; 5 | 6 | export class RootProject { 7 | private environment?: Environment; 8 | private gradleVersion?: string; 9 | constructor(private readonly workspaceFolder: vscode.WorkspaceFolder, private readonly projectUri: vscode.Uri) {} 10 | 11 | public setEnvironment(environment: Environment): void { 12 | this.environment = environment; 13 | const gradleVersion = environment.getGradleEnvironment()?.getGradleVersion(); 14 | if (gradleVersion && gradleVersion !== this.gradleVersion) { 15 | this.gradleVersion = gradleVersion; 16 | if (!isTest()) { 17 | sendInfo("", { name: "changeGradleVersion", gradleVersion: gradleVersion }); 18 | } 19 | } 20 | } 21 | 22 | public getEnvironment(): Environment | undefined { 23 | return this.environment; 24 | } 25 | 26 | public getWorkspaceFolder(): vscode.WorkspaceFolder { 27 | return this.workspaceFolder; 28 | } 29 | 30 | public getProjectUri(): vscode.Uri { 31 | return this.projectUri; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/java/builder/jdtbuilder/ICompilationUnitLocator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2007, 2009 BEA Systems, Inc. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Copied from https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ICompilationUnitLocator.java 12 | * 13 | * Contributors: 14 | * wharley@bea.com - initial API and implementation 15 | * 16 | *******************************************************************************/ 17 | 18 | package com.microsoft.java.builder.jdtbuilder; 19 | 20 | import org.eclipse.core.resources.IFile; 21 | import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; 22 | 23 | /** 24 | * Used to convert an IFile into an ICompilationUnit, 25 | * for clients outside of this package. 26 | * @since 3.3 27 | */ 28 | public interface ICompilationUnitLocator { 29 | public ICompilationUnit fromIFile(IFile file); 30 | } 31 | -------------------------------------------------------------------------------- /extension/test-fixtures/tool-options-provider-test-extension/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tooloptionstest", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "tooloptionstest", 9 | "version": "1.0.0", 10 | "devDependencies": { 11 | "@types/vscode": "^1.76.0", 12 | "typescript": "^5.6.3" 13 | }, 14 | "engines": { 15 | "vscode": "^1.76.0" 16 | } 17 | }, 18 | "node_modules/@types/vscode": { 19 | "version": "1.96.0", 20 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.96.0.tgz", 21 | "integrity": "sha512-qvZbSZo+K4ZYmmDuaodMbAa67Pl6VDQzLKFka6rq+3WUTY4Kro7Bwoi0CuZLO/wema0ygcmpwow7zZfPJTs5jg==", 22 | "dev": true, 23 | "license": "MIT" 24 | }, 25 | "node_modules/typescript": { 26 | "version": "5.7.2", 27 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", 28 | "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", 29 | "dev": true, 30 | "license": "Apache-2.0", 31 | "bin": { 32 | "tsc": "bin/tsc", 33 | "tsserver": "bin/tsserver" 34 | }, 35 | "engines": { 36 | "node": ">=14.17" 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.microsoft.gradle.bs.importer 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.m2e.core.maven2Nature 31 | org.eclipse.pde.PluginNature 32 | org.eclipse.jdt.core.javanature 33 | 34 | 35 | 36 | 1690177359886 37 | 38 | 30 39 | 40 | org.eclipse.core.resources.regexFilterMatcher 41 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /extension/src/commands/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./CancelBuildCommand"; 2 | export * from "./CancelTreeItemTaskCommand"; 3 | export * from "./CancellingTreeItemTaskCommand"; 4 | export * from "./UnpinAllTasksCommand"; 5 | export * from "./ClearAllRecentTasksCommand"; 6 | export * from "./CloseAllTaskTerminalsCommand"; 7 | export * from "./CloseTaskTerminalsCommand"; 8 | export * from "./DebugTaskCommand"; 9 | export * from "./DebugTaskWithArgsCommand"; 10 | export * from "./ExplorerFlatCommand"; 11 | export * from "./ExplorerTreeCommand"; 12 | export * from "./LoadTasksCommand"; 13 | export * from "./OpenBuildFileCommand"; 14 | export * from "./OpenSettingsCommand"; 15 | export * from "./PinTaskCommand"; 16 | export * from "./PinTaskWithArgsCommand"; 17 | export * from "./RefreshCommand"; 18 | export * from "./RefreshDaemonStatusCommand"; 19 | export * from "./UnpinTaskCommand"; 20 | export * from "./RemoveRecentTaskCommand"; 21 | export * from "./RenderTaskCommand"; 22 | export * from "./RestartTaskCommand"; 23 | export * from "./RunTaskCommand"; 24 | export * from "./RunTaskWithArgsCommand"; 25 | export * from "./ShowLogsCommand"; 26 | export * from "./ShowTaskTerminalCommand"; 27 | export * from "./ShowTasksCommand"; 28 | export * from "./StopDaemonCommand"; 29 | export * from "./StopDaemonsCommand"; 30 | export * from "./RunBuildCommand"; 31 | export * from "./FindTaskCommand"; 32 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/java/builder/jdtbuilder/AdditionalTypeCollection.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2010 IBM Corporation and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Copied from https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AdditionalTypeCollection.java 12 | * 13 | * Contributors: 14 | * IBM Corporation - initial API and implementation 15 | *******************************************************************************/ 16 | package com.microsoft.java.builder.jdtbuilder; 17 | 18 | public class AdditionalTypeCollection extends ReferenceCollection { 19 | 20 | char[][] definedTypeNames; 21 | 22 | protected AdditionalTypeCollection(char[][] definedTypeNames, char[][][] qualifiedReferences, char[][] simpleNameReferences, char[][] rootReferences) { 23 | super(qualifiedReferences, simpleNameReferences, rootReferences); 24 | this.definedTypeNames = definedTypeNames; // do not bother interning member type names (i.e. 'A$M') 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/java/builder/jdtbuilder/MissingSourceFileException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2009 IBM Corporation and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Copied from https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingSourceFileException.java 12 | * 13 | * Contributors: 14 | * IBM Corporation - initial API and implementation 15 | *******************************************************************************/ 16 | package com.microsoft.java.builder.jdtbuilder; 17 | 18 | /** 19 | * Exception thrown when the build should be aborted because a source file is missing/empty. 20 | */ 21 | public class MissingSourceFileException extends RuntimeException { 22 | 23 | protected String missingSourceFile; 24 | private static final long serialVersionUID = -1416609004971115719L; // backward compatible 25 | 26 | public MissingSourceFileException(String missingSourceFile) { 27 | this.missingSourceFile = missingSourceFile; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /extension/src/bs/GradleBuildLinkProvider.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import { DocumentLink, DocumentLinkProvider, ProviderResult, Range, TextDocument, Uri } from "vscode"; 5 | 6 | export class GradleBuildLinkProvider implements DocumentLinkProvider { 7 | provideDocumentLinks(document: TextDocument): ProviderResult { 8 | const links: DocumentLink[] = []; 9 | const content = document.getText(); 10 | let searchPosition = 0; 11 | const lines = content.split(/\r?\n/g); 12 | for (const line of lines) { 13 | const match = line.match(/(.*\.java):(\d+)/); 14 | if (match) { 15 | const startOffset = content.indexOf(match[0], searchPosition); 16 | const start = document.positionAt(startOffset); 17 | const endOffset = startOffset + match[0].length; 18 | const end = document.positionAt(endOffset); 19 | searchPosition += endOffset; 20 | 21 | const file = match[1]; 22 | const line = parseInt(match[2]); 23 | const uri = Uri.file(file).with({ fragment: `L${line}` }); 24 | links.push(new DocumentLink(new Range(start, end), uri)); 25 | // TODO: support column recognition 26 | } 27 | } 28 | return links; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /extension/src/stores/PinnedTasksStore.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { TaskArgs, TaskId } from "./types"; 3 | import { TaskStore } from "."; 4 | 5 | interface WorkspaceStateTasks { 6 | [key: string]: TaskArgs[]; 7 | } 8 | 9 | const toWorkspaceStateTasks = (map: Map>): WorkspaceStateTasks => { 10 | return Array.from(map.keys()).reduce((workspaceStateTasks: WorkspaceStateTasks, key: string) => { 11 | workspaceStateTasks[key] = Array.from(map.get(key)!.values()); 12 | return workspaceStateTasks; 13 | }, {}); 14 | }; 15 | 16 | export class PinnedTasksStore extends TaskStore { 17 | constructor(private readonly context: vscode.ExtensionContext) { 18 | super(); 19 | const pinnedTasks = this.context.workspaceState.get("pinnedTasks", {}) as WorkspaceStateTasks; 20 | if (!pinnedTasks || Array.isArray(pinnedTasks) || typeof pinnedTasks !== "object") { 21 | return; 22 | } 23 | Object.keys(pinnedTasks).forEach((taskId: TaskId) => { 24 | this.setItem(taskId, new Set(pinnedTasks[taskId]), false); 25 | }); 26 | } 27 | 28 | public async fireOnDidChange(): Promise { 29 | const workspaceStateTasks: WorkspaceStateTasks = toWorkspaceStateTasks(this.getData()); 30 | await this.context.workspaceState.update("pinnedTasks", workspaceStateTasks); 31 | super.fireOnDidChange(null); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /extension/src/util/decorators.ts: -------------------------------------------------------------------------------- 1 | // Taken from https://github.com/microsoft/vscode/blob/main/src/vs/base/common/decorators.ts 2 | 3 | /* eslint-disable @typescript-eslint/no-explicit-any */ 4 | /* eslint-disable @typescript-eslint/ban-types */ 5 | export function createDecorator(mapFn: (fn: Function, key: string) => Function): Function { 6 | return (_target: any, key: string, descriptor: any): void => { 7 | let fnKey: string | null = null; 8 | let fn: Function | null = null; 9 | 10 | if (typeof descriptor.value === "function") { 11 | fnKey = "value"; 12 | fn = descriptor.value; 13 | } else if (typeof descriptor.get === "function") { 14 | fnKey = "get"; 15 | fn = descriptor.get; 16 | } 17 | 18 | if (!fn) { 19 | throw new Error("not supported"); 20 | } 21 | 22 | descriptor[fnKey!] = mapFn(fn, key); 23 | }; 24 | } 25 | 26 | export interface DebounceReducer { 27 | (previousValue: T, ...args: any[]): T; 28 | } 29 | 30 | export function debounce(delay: number): Function { 31 | return createDecorator((fn, key) => { 32 | const timerKey = `$debounce$${key}`; 33 | return function (this: any, ...args: any[]): void { 34 | clearTimeout(this[timerKey]); 35 | this[timerKey] = setTimeout(() => { 36 | fn.apply(this, args); 37 | }, delay); 38 | }; 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/handlers/CancelBuildsHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.badsyntax.gradle.handlers; 2 | 3 | import com.github.badsyntax.gradle.CancelBuildsReply; 4 | import com.github.badsyntax.gradle.GradleBuildCancellation; 5 | import com.github.badsyntax.gradle.exceptions.GradleCancellationException; 6 | import io.grpc.stub.StreamObserver; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | public class CancelBuildsHandler { 11 | private static final Logger logger = LoggerFactory.getLogger(CancelBuildsHandler.class.getName()); 12 | 13 | private StreamObserver responseObserver; 14 | 15 | public CancelBuildsHandler(StreamObserver responseObserver) { 16 | this.responseObserver = responseObserver; 17 | } 18 | 19 | public void run() { 20 | try { 21 | GradleBuildCancellation.cancelBuilds(); 22 | replyWithCancelledSuccess(); 23 | } catch (GradleCancellationException e) { 24 | logger.error(e.getMessage()); 25 | replyWithCancelError(e); 26 | } finally { 27 | responseObserver.onCompleted(); 28 | } 29 | } 30 | 31 | private void replyWithCancelledSuccess() { 32 | responseObserver.onNext(CancelBuildsReply.newBuilder().setMessage("Cancel builds requested").build()); 33 | } 34 | 35 | private void replyWithCancelError(Exception e) { 36 | responseObserver.onNext(CancelBuildsReply.newBuilder().setMessage(e.getMessage()).build()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.microsoft.gradle.jdtls.ext 7 | gradle-jdtls-ext-parent 8 | 0.5.4 9 | 10 | com.microsoft.gradle.bs.importer 11 | eclipse-plugin 12 | ${base.name} :: Gradle Build Server Importer 13 | 14 | 15 | 16 | 17 | 18 | org.apache.maven.plugins 19 | maven-dependency-plugin 20 | 21 | 22 | 23 | ch.epfl.scala 24 | bsp4j 25 | 2.1.0-M4 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /extension/src/commands/OpenBuildFileCommand.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import * as path from "path"; 3 | import * as fse from "fs-extra"; 4 | import { GradleTaskTreeItem } from "../views"; 5 | import { Command } from "./Command"; 6 | import { GRADLE_BUILD_FILE_NAMES } from "../constant"; 7 | 8 | export const COMMAND_OPEN_BUILD_FILE = "gradle.openBuildFile"; 9 | 10 | async function run(path: string): Promise { 11 | await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(path)); 12 | } 13 | 14 | export class OpenBuildFileCommand extends Command { 15 | async run(item: GradleTaskTreeItem | { uri: string }): Promise { 16 | if (item instanceof GradleTaskTreeItem) { 17 | return run(item.task.definition.buildFile); 18 | } else if (item.uri) { 19 | const buildFilePath = await ensureBuildFilePath(item.uri); 20 | if (buildFilePath) { 21 | return run(buildFilePath); 22 | } 23 | } 24 | } 25 | } 26 | 27 | export async function ensureBuildFilePath(projectUri: string): Promise { 28 | const projectFsPath = vscode.Uri.parse(projectUri).fsPath; 29 | for (const buildFileName of GRADLE_BUILD_FILE_NAMES) { 30 | const buildFilePath: string = path.join(projectFsPath, buildFileName); 31 | if (await fse.pathExists(buildFilePath)) { 32 | return buildFilePath; 33 | } 34 | } 35 | return undefined; 36 | } 37 | -------------------------------------------------------------------------------- /extension/src/commands/StopDaemonCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleDaemonTreeItem } from "../views"; 2 | import { confirmModal } from "../util/input"; 3 | import { logger } from "../logger"; 4 | import { Command } from "./Command"; 5 | import { execAsync } from "../util/execAsync"; 6 | import * as vscode from "vscode"; 7 | import { COMMAND_REFRESH_DAEMON_STATUS } from "./RefreshDaemonStatusCommand"; 8 | 9 | export const COMMAND_STOP_DAEMON = "gradle.stopDaemon"; 10 | 11 | export class StopDaemonCommand extends Command { 12 | constructor() { 13 | super(); 14 | } 15 | async run(treeItem: GradleDaemonTreeItem): Promise { 16 | if (!(await confirmModal("Are you sure you want to stop the daemon?"))) { 17 | return; 18 | } 19 | const pid = treeItem.pid; 20 | try { 21 | await this.stopDaemon(pid); 22 | logger.info(`Successfully stopped daemon with PID ${pid}.`); 23 | } catch (error) { 24 | logger.error(`Failed to stop daemon with PID ${pid}: ${error.message}.`); 25 | } 26 | } 27 | 28 | async stopDaemon(pid: string): Promise { 29 | if (!pid) { 30 | throw new Error("PID is required to stop the daemon."); 31 | } 32 | 33 | const command = process.platform === "win32" ? `taskkill /PID ${pid} /F` : `kill ${pid}`; 34 | await execAsync(command); 35 | await vscode.commands.executeCommand(COMMAND_REFRESH_DAEMON_STATUS); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /extension/src/views/gradleTasks/GradleTaskTreeItem.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { COMMAND_RUN_TASK_DOUBLE_CLICK } from "../../commands"; 3 | import { Icons } from "../../icons"; 4 | import { TASK_STATE_RUNNING_REGEX } from "../constants"; 5 | import { getTreeItemState } from "../viewUtil"; 6 | 7 | export class GradleTaskTreeItem extends vscode.TreeItem { 8 | constructor( 9 | public readonly parentTreeItem: vscode.TreeItem, 10 | public readonly task: vscode.Task, 11 | public readonly label: string, 12 | public tooltip: string, 13 | public description: string, 14 | protected readonly icons: Icons, 15 | protected readonly debuggable: boolean 16 | ) { 17 | super(label, vscode.TreeItemCollapsibleState.None); 18 | this.command = { 19 | title: "Run Task", 20 | command: COMMAND_RUN_TASK_DOUBLE_CLICK, 21 | arguments: [this], 22 | }; 23 | } 24 | 25 | public setContext(): void { 26 | this.contextValue = getTreeItemState(this.task, this.task.definition.args); 27 | this.setIconState(); 28 | } 29 | 30 | protected setIconState(): void { 31 | const { iconPathRunning, iconPathIdle } = this.icons; 32 | if (this.contextValue && TASK_STATE_RUNNING_REGEX.test(this.contextValue)) { 33 | this.iconPath = iconPathRunning; 34 | } else { 35 | this.iconPath = iconPathIdle; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /extension/src/server/serverUtil.ts: -------------------------------------------------------------------------------- 1 | import { checkEnvJavaExecutable, findValidJavaHome, getRedHatJavaEmbeddedJRE } from "../util/config"; 2 | import { GRADLE_SERVER_BASE_JVM_OPTS } from "../constant"; 3 | 4 | export function getGradleServerCommand(): string { 5 | const platform = process.platform; 6 | if (platform === "win32") { 7 | return "gradle-server.bat"; 8 | } else if (platform === "linux" || platform === "darwin") { 9 | return "gradle-server"; 10 | } else { 11 | throw new Error("Unsupported platform"); 12 | } 13 | } 14 | 15 | export interface ProcessEnv { 16 | [key: string]: string | undefined; 17 | } 18 | 19 | export function quoteArg(arg: string): string { 20 | return `"${arg}"`; 21 | } 22 | 23 | export async function getGradleServerEnv(): Promise { 24 | const javaHome = getRedHatJavaEmbeddedJRE() || (await findValidJavaHome()); 25 | const env = { ...process.env }; 26 | if (javaHome) { 27 | Object.assign(env, { 28 | VSCODE_JAVA_HOME: javaHome, 29 | }); 30 | if (env["DEBUG_GRADLE_SERVER"] === "true") { 31 | env.GRADLE_SERVER_OPTS = 32 | "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8089 " + GRADLE_SERVER_BASE_JVM_OPTS; 33 | } else { 34 | env.GRADLE_SERVER_OPTS = GRADLE_SERVER_BASE_JVM_OPTS; 35 | } 36 | } else if (!checkEnvJavaExecutable()) { 37 | return undefined; 38 | } 39 | return env; 40 | } 41 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/java/builder/jdtbuilder/AbortIncrementalBuildException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Copied from https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbortIncrementalBuildException.java 12 | * 13 | * Contributors: 14 | * IBM Corporation - initial API and implementation 15 | *******************************************************************************/ 16 | package com.microsoft.java.builder.jdtbuilder; 17 | 18 | /** 19 | * Exception thrown when an incremental builder cannot find a .class file. 20 | * Its possible the type can no longer be found because it was renamed inside its existing 21 | * source file. 22 | */ 23 | public class AbortIncrementalBuildException extends RuntimeException { 24 | 25 | protected String qualifiedTypeName; 26 | private static final long serialVersionUID = -8874662133883858502L; // backward compatible 27 | 28 | public AbortIncrementalBuildException(String qualifiedTypeName) { 29 | this.qualifiedTypeName = qualifiedTypeName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /extension/src/client/utils.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import * as vscode from "vscode"; 5 | import { GradleBuild, GradleProject } from "../proto/gradle_pb"; 6 | import { RootProject } from "../rootProject"; 7 | import { RootProjectsStore } from "../stores"; 8 | 9 | export function findGradleProjectFromBuild(projectPath: string, gradleBuild: GradleBuild): GradleProject | undefined { 10 | const rootProject = gradleBuild.getProject(); 11 | if (!rootProject || !rootProject.getIsRoot()) { 12 | return undefined; 13 | } 14 | return findGradleProject(projectPath, rootProject); 15 | } 16 | 17 | function findGradleProject(projectPath: string, project: GradleProject): GradleProject | undefined { 18 | if (vscode.Uri.file(project.getProjectpath()).fsPath === projectPath) { 19 | return project; 20 | } 21 | for (const subProject of project.getProjectsList()) { 22 | const result = findGradleProject(projectPath, subProject); 23 | if (result) { 24 | return result; 25 | } 26 | } 27 | return undefined; 28 | } 29 | 30 | export async function findRootProject( 31 | rootProjectStore: RootProjectsStore, 32 | projectPath: string 33 | ): Promise { 34 | for (const rootProject of await rootProjectStore.getProjectRoots()) { 35 | if (projectPath.startsWith(rootProject.getProjectUri().fsPath)) { 36 | return rootProject; 37 | } 38 | } 39 | return undefined; 40 | } 41 | -------------------------------------------------------------------------------- /extension/src/views/constants.ts: -------------------------------------------------------------------------------- 1 | import { DaemonStatus } from "./gradleDaemons/models/DaemonStatus"; 2 | 3 | export const ICON_LOADING = "loading.svg"; 4 | export const ICON_GRADLE_TASK = "script.svg"; 5 | export const ICON_DAEMON_BUSY = "circle-filled.svg"; 6 | export const ICON_DAEMON_IDLE = "circle-outline.svg"; 7 | export const ICON_DAEMON_STOPPED = "close.svg"; 8 | 9 | export const GRADLE_CONTAINER_VIEW = "gradleContainerView"; 10 | export const GRADLE_TASKS_VIEW = "gradleTasksView"; 11 | export const GRADLE_DEFAULT_PROJECTS_VIEW = "gradleDefaultProjectsView"; 12 | export const GRADLE_DAEMONS_VIEW = "gradleDaemonsView"; 13 | export const RECENT_TASKS_VIEW = "recentTasksView"; 14 | 15 | export const TREE_ITEM_STATE_TASK_RUNNING = "runningTask"; 16 | export const TREE_ITEM_STATE_TASK_DEBUG_RUNNING = "runningDebugTask"; 17 | export const TREE_ITEM_STATE_TASK_CANCELLING = "cancellingTask"; 18 | export const TREE_ITEM_STATE_TASK_IDLE = "task"; 19 | export const TREE_ITEM_STATE_TASK_DEBUG_IDLE = "debugTask"; 20 | export const TREE_ITEM_STATE_TASK_PINNED_PREFIX = "pinned"; 21 | export const TREE_ITEM_STATE_NO_TASKS = "notasks"; 22 | export const TREE_ITEM_STATE_FOLDER = "folder"; 23 | 24 | export const TASK_STATE_RUNNING_REGEX = new RegExp(`^${TREE_ITEM_STATE_TASK_RUNNING}`); 25 | 26 | export const DAEMON_ICON_MAP = { 27 | [DaemonStatus.BUSY]: ICON_DAEMON_BUSY, 28 | [DaemonStatus.IDLE]: ICON_DAEMON_IDLE, 29 | [DaemonStatus.STOPPED]: ICON_DAEMON_STOPPED, 30 | [DaemonStatus.STOPPING]: ICON_DAEMON_STOPPED, 31 | [DaemonStatus.CANCELED]: ICON_DAEMON_STOPPED, 32 | }; 33 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/java/builder/jdtbuilder/ProblemFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. 3 | * 4 | * This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * https://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | * 11 | * Copied from https://github.com/eclipse-jdt/eclipse.jdt.core/blob/master/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ProblemFactory.java 12 | * 13 | * Contributors: 14 | * IBM Corporation - initial API and implementation 15 | *******************************************************************************/ 16 | package com.microsoft.java.builder.jdtbuilder; 17 | 18 | import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; 19 | import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; 20 | 21 | import java.util.*; 22 | 23 | public class ProblemFactory extends DefaultProblemFactory { 24 | 25 | static SimpleLookupTable factories = new SimpleLookupTable(5); 26 | 27 | private ProblemFactory(Locale locale) { 28 | super(locale); 29 | } 30 | 31 | public static ProblemFactory getProblemFactory(Locale locale) { 32 | ProblemFactory factory = (ProblemFactory) factories.get(locale); 33 | if (factory == null) 34 | factories.put(locale, factory = new ProblemFactory(locale)); 35 | return factory; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /extension/src/commands/RunTaskCommand.ts: -------------------------------------------------------------------------------- 1 | import { GradleTaskTreeItem } from "../views"; 2 | import { runTask } from "../tasks/taskUtil"; 3 | import { Command } from "./Command"; 4 | import { RootProjectsStore } from "../stores"; 5 | import { TaskServerClient } from "../client"; 6 | import { DoubleClickChecker } from "../util/DoubleClickChecker"; 7 | 8 | export const COMMAND_RUN_TASK = "gradle.runTask"; 9 | export const COMMAND_RUN_TASK_DOUBLE_CLICK = "gradle.runTaskDoubleClick"; 10 | 11 | async function run(treeItem: GradleTaskTreeItem, rootProjectsStore: RootProjectsStore, client: TaskServerClient) { 12 | if (treeItem && treeItem.task) { 13 | await runTask(rootProjectsStore, treeItem.task, client); 14 | } 15 | } 16 | 17 | export class RunTaskCommand extends Command { 18 | constructor(private rootProjectsStore: RootProjectsStore, private client: TaskServerClient) { 19 | super(); 20 | } 21 | 22 | async run(treeItem: GradleTaskTreeItem): Promise { 23 | run(treeItem, this.rootProjectsStore, this.client); 24 | } 25 | } 26 | 27 | export class RunTaskDoubleClickCommand extends Command { 28 | private doubleClickChecker: DoubleClickChecker; 29 | 30 | constructor(private rootProjectsStore: RootProjectsStore, private client: TaskServerClient) { 31 | super(); 32 | this.doubleClickChecker = new DoubleClickChecker(); 33 | } 34 | 35 | async run(treeItem: GradleTaskTreeItem): Promise { 36 | if (this.doubleClickChecker.checkDoubleClick(treeItem)) { 37 | return run(treeItem, this.rootProjectsStore, this.client); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /extension/src/client/GradleBuildContentProvider.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | import AwaitLock from "await-lock"; 5 | import { TaskServerClient } from "."; 6 | import { syncGradleBuild } from "../languageServer/languageServer"; 7 | import { GradleBuild } from "../proto/gradle_pb"; 8 | import { RootProject } from "../rootProject"; 9 | import { getGradleConfig } from "../util/config"; 10 | 11 | const lock = new AwaitLock(); 12 | 13 | export class GradleBuildContentProvider { 14 | private cachedBuild: Map = new Map(); 15 | 16 | constructor(private readonly client: TaskServerClient) {} 17 | 18 | public async getGradleBuild(rootProject: RootProject): Promise { 19 | await lock.acquireAsync(); 20 | try { 21 | const projectPath = rootProject.getProjectUri().fsPath; 22 | if (this.cachedBuild.has(projectPath)) { 23 | return this.cachedBuild.get(projectPath); 24 | } 25 | const gradleBuild = await this.client.getBuild(rootProject, getGradleConfig()); 26 | if (gradleBuild) { 27 | await syncGradleBuild(gradleBuild); 28 | this.cachedBuild.set(projectPath, gradleBuild); 29 | } 30 | return gradleBuild; 31 | } finally { 32 | lock.release(); 33 | } 34 | } 35 | 36 | public refresh(): void { 37 | this.cachedBuild.clear(); 38 | } 39 | 40 | public getCachedBuild(): Map { 41 | return this.cachedBuild; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /extension/src/views/gradleDaemons/services/GradleLocalInstallation.ts: -------------------------------------------------------------------------------- 1 | import { GradleExecution } from "./GradleExecution"; 2 | import { execAsync } from "../../../util/execAsync"; 3 | import { getConfigJavaImportGradleJavaHome } from "../../../util/config"; 4 | import { logger } from "../../../logger"; 5 | import * as path from "path"; 6 | 7 | export class GradleLocalInstallation implements GradleExecution { 8 | private gradleExecPath: string; 9 | 10 | constructor(gradleHomePath: string) { 11 | const exeName = process.platform === "win32" ? "gradle.bat" : "gradle"; 12 | // Resolve the executable inside the Gradle home "bin" directory. 13 | this.gradleExecPath = `"${path.join(gradleHomePath, "bin", exeName)}"`; 14 | } 15 | 16 | public async exec(args: string[]): Promise { 17 | if (args.length === 0) { 18 | throw new Error("No gradle args supplied"); 19 | } 20 | 21 | const quotedArgs = args.map((arg) => `"${arg}"`).join(" "); 22 | const command = `${this.gradleExecPath} ${quotedArgs}`; 23 | 24 | try { 25 | const jdkPath = getConfigJavaImportGradleJavaHome(); 26 | const env = jdkPath ? { ...process.env, JAVA_HOME: jdkPath } : process.env; 27 | 28 | const { stdout, stderr } = await execAsync(command, { env }); 29 | if (stderr) { 30 | logger.error(stderr); 31 | } 32 | return stdout; 33 | } catch (error) { 34 | logger.error(error.message); 35 | throw new Error(`Error running gradle local installation: ${error.message}`); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/ch/epfl/scala/bsp4j/extended/TestStartEx.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package ch.epfl.scala.bsp4j.extended; 5 | 6 | import java.util.Objects; 7 | 8 | import org.eclipse.lsp4j.jsonrpc.validation.NonNull; 9 | 10 | import ch.epfl.scala.bsp4j.TestStart; 11 | 12 | /** 13 | * Extended {@link TestStart}, which contains the Suite, class, method. 14 | * {@link TestStart} only contains file location which Gradle doesn't have. 15 | */ 16 | public class TestStartEx extends TestStart { 17 | 18 | private TestName testName; 19 | 20 | /** 21 | * Create a new instance of {@link TestStartEx}. 22 | */ 23 | public TestStartEx(@NonNull String displayName, @NonNull TestName testName) { 24 | super(displayName); 25 | this.testName = testName; 26 | } 27 | 28 | public TestName getTestName() { 29 | return testName; 30 | } 31 | 32 | public void setTestName(TestName testName) { 33 | this.testName = testName; 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | final int prime = 31; 39 | int result = super.hashCode(); 40 | result = prime * result + Objects.hashCode(testName); 41 | return result; 42 | } 43 | 44 | @Override 45 | public boolean equals(Object obj) { 46 | if (this == obj) { 47 | return true; 48 | } 49 | if (!super.equals(obj)) { 50 | return false; 51 | } 52 | if (getClass() != obj.getClass()) { 53 | return false; 54 | } 55 | TestStartEx other = (TestStartEx) obj; 56 | return Objects.equals(testName, other.testName); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/java/com/microsoft/gradle/DefaultGradleDependencyNode.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle; 5 | 6 | import com.microsoft.gradle.api.GradleDependencyNode; 7 | import com.microsoft.gradle.api.GradleDependencyType; 8 | import java.io.Serializable; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class DefaultGradleDependencyNode implements GradleDependencyNode, Serializable { 13 | private String name; 14 | private GradleDependencyType type; 15 | private List children; 16 | 17 | public DefaultGradleDependencyNode(String name, GradleDependencyType type, List children) { 18 | this.name = name; 19 | this.type = type; 20 | this.children = children; 21 | } 22 | 23 | public DefaultGradleDependencyNode(String name, GradleDependencyType type) { 24 | this.name = name; 25 | this.type = type; 26 | this.children = new ArrayList<>(); 27 | } 28 | 29 | public String getName() { 30 | return this.name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public GradleDependencyType getType() { 38 | return this.type; 39 | } 40 | 41 | public void setType(GradleDependencyType type) { 42 | this.type = type; 43 | } 44 | 45 | public List getChildren() { 46 | return this.children; 47 | } 48 | 49 | public void setChildren(List children) { 50 | this.children = children; 51 | } 52 | 53 | public void addChildren(GradleDependencyNode child) { 54 | this.children.add(child); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /gradle-server/src/main/java/com/github/badsyntax/gradle/handlers/CancelBuildHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.badsyntax.gradle.handlers; 2 | 3 | import com.github.badsyntax.gradle.CancelBuildReply; 4 | import com.github.badsyntax.gradle.CancelBuildRequest; 5 | import com.github.badsyntax.gradle.GradleBuildCancellation; 6 | import com.github.badsyntax.gradle.exceptions.GradleCancellationException; 7 | import io.grpc.stub.StreamObserver; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | public class CancelBuildHandler { 12 | private static final Logger logger = LoggerFactory.getLogger(CancelBuildHandler.class.getName()); 13 | 14 | private CancelBuildRequest req; 15 | private StreamObserver responseObserver; 16 | 17 | public CancelBuildHandler(CancelBuildRequest req, StreamObserver responseObserver) { 18 | this.req = req; 19 | this.responseObserver = responseObserver; 20 | } 21 | 22 | public void run() { 23 | try { 24 | GradleBuildCancellation.cancelBuild(req.getCancellationKey()); 25 | replyWithCancelledSuccess(); 26 | } catch (GradleCancellationException e) { 27 | logger.error(e.getMessage()); 28 | replyWithCancelError(e); 29 | } finally { 30 | responseObserver.onCompleted(); 31 | } 32 | } 33 | 34 | private void replyWithCancelledSuccess() { 35 | responseObserver.onNext( 36 | CancelBuildReply.newBuilder().setMessage("Cancel build requested").setBuildRunning(true).build()); 37 | } 38 | 39 | private void replyWithCancelError(Exception e) { 40 | responseObserver 41 | .onNext(CancelBuildReply.newBuilder().setMessage(e.getMessage()).setBuildRunning(false).build()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /extension/resources/light/loading.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /gradle-language-server/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java" 3 | id "application" 4 | } 5 | 6 | java { 7 | sourceCompatibility = JavaVersion.VERSION_17 8 | targetCompatibility = JavaVersion.VERSION_17 9 | } 10 | 11 | repositories { 12 | mavenCentral() 13 | maven { 14 | url "https://groovy.jfrog.io/artifactory/plugins-release" 15 | } 16 | } 17 | 18 | application { 19 | applicationName = "gradle-language-server" 20 | mainClass = "com.microsoft.gradle.GradleLanguageServer" 21 | } 22 | 23 | dependencies { 24 | implementation "org.eclipse.lsp4j:org.eclipse.lsp4j:0.19.0" 25 | implementation "org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.19.0" 26 | implementation "org.codehaus.groovy:groovy-eclipse-batch:4.0.16-03" 27 | implementation "com.google.code.gson:gson:2.9.1" 28 | implementation "org.apache.bcel:bcel:6.6.1" 29 | testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1" 30 | testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1" 31 | } 32 | 33 | ext.mainClass = "com.microsoft.gradle.GradleLanguageServer" 34 | 35 | def mainJavaDir = 'src/main/java'; 36 | def mainResourcesDir = 'src/main/resources'; 37 | 38 | sourceSets { 39 | main { 40 | java { 41 | srcDirs mainJavaDir 42 | } 43 | resources { 44 | srcDirs mainResourcesDir 45 | } 46 | } 47 | } 48 | 49 | test { 50 | useJUnitPlatform() 51 | } 52 | 53 | spotless { 54 | java { 55 | importOrder() 56 | eclipse() 57 | removeUnusedImports() 58 | trimTrailingWhitespace() 59 | targetExclude "build/**" 60 | } 61 | } 62 | 63 | compileJava.dependsOn 'spotlessCheck' 64 | 65 | project.tasks.named("processResources") { 66 | duplicatesStrategy = 'include' 67 | } 68 | -------------------------------------------------------------------------------- /extension/resources/dark/loading.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/java/com/microsoft/gradle/DefaultGradleTask.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | package com.microsoft.gradle; 5 | 6 | import com.microsoft.gradle.api.GradleTask; 7 | import java.io.Serializable; 8 | 9 | public class DefaultGradleTask implements Serializable, GradleTask { 10 | private String name; 11 | private String group; 12 | private String path; 13 | private String project; 14 | private String buildFile; 15 | private String rootProject; 16 | private String description; 17 | private boolean debuggable; 18 | 19 | public DefaultGradleTask(String name, String group, String path, String project, String buildFile, 20 | String rootProject, String description, boolean debuggable) { 21 | this.name = name; 22 | this.group = group; 23 | this.path = path; 24 | this.project = project; 25 | this.buildFile = buildFile; 26 | this.rootProject = rootProject; 27 | this.description = description; 28 | this.debuggable = debuggable; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public String getGroup() { 36 | return group; 37 | } 38 | 39 | public String getPath() { 40 | return path; 41 | } 42 | 43 | public String getProject() { 44 | return project; 45 | } 46 | 47 | public String getBuildFile() { 48 | return buildFile; 49 | } 50 | 51 | public String getRootProject() { 52 | return rootProject; 53 | } 54 | 55 | public String getDescription() { 56 | return description; 57 | } 58 | 59 | public boolean getDebuggable() { 60 | return debuggable; 61 | } 62 | 63 | public void setDebuggable(boolean debuggable) { 64 | this.debuggable = debuggable; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /extension/src/tasks/GradleTaskManager.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from "vscode"; 2 | import { isGradleTask, getRunningGradleTasks } from "./taskUtil"; 3 | 4 | export class GradleTaskManager implements vscode.Disposable { 5 | private readonly _onDidStartTask: vscode.EventEmitter = new vscode.EventEmitter(); 6 | private readonly _onDidEndTask: vscode.EventEmitter = new vscode.EventEmitter(); 7 | private readonly _onDidEndAllTasks: vscode.EventEmitter = new vscode.EventEmitter(); 8 | 9 | public readonly onDidStartTask: vscode.Event = this._onDidStartTask.event; 10 | public readonly onDidEndTask: vscode.Event = this._onDidEndTask.event; 11 | public readonly onDidEndAllTasks: vscode.Event = this._onDidEndAllTasks.event; 12 | 13 | constructor(private readonly context: vscode.ExtensionContext) { 14 | this.context.subscriptions.push( 15 | vscode.tasks.onDidStartTask((e: vscode.TaskStartEvent) => { 16 | if (isGradleTask(e.execution.task)) { 17 | this._onDidStartTask.fire(e.execution.task); 18 | } 19 | }), 20 | vscode.tasks.onDidEndTask((e: vscode.TaskEndEvent) => { 21 | if (isGradleTask(e.execution.task)) { 22 | this._onDidEndTask.fire(e.execution.task); 23 | if (getRunningGradleTasks().length === 0) { 24 | this._onDidEndAllTasks.fire(null); 25 | } 26 | } 27 | }) 28 | ); 29 | } 30 | 31 | public dispose(): void { 32 | this._onDidStartTask.dispose(); 33 | this._onDidEndAllTasks.dispose(); 34 | } 35 | } 36 | --------------------------------------------------------------------------------