├── .gitignore
├── icon.png
├── typings
├── node.d.ts
└── vscode-typings.d.ts
├── images
└── main.png
├── README.md
├── .vscodeignore
├── tsconfig.json
├── .vscode
├── settings.json
├── launch.json
└── tasks.json
├── test
├── extension.test.ts
└── index.ts
├── package.json
└── src
└── extension.ts
/.gitignore:
--------------------------------------------------------------------------------
1 | out
2 | node_modules
3 | *.vsix
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steam/vscode-gradle/master/icon.png
--------------------------------------------------------------------------------
/typings/node.d.ts:
--------------------------------------------------------------------------------
1 | ///
--------------------------------------------------------------------------------
/images/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steam/vscode-gradle/master/images/main.png
--------------------------------------------------------------------------------
/typings/vscode-typings.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VSCode-Gradle
2 | This extension provides support to run _gradle_ tasks.
3 |
4 | 
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | out/test/**
4 | test/**
5 | src/**
6 | **/*.map
7 | .gitignore
8 | tsconfig.json
9 | vsc-extension-quickstart.md
10 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "outDir": "out",
6 | "lib": [
7 | "es6"
8 | ],
9 | "sourceMap": true,
10 | "rootDir": "."
11 | },
12 | "exclude": [
13 | "node_modules",
14 | ".vscode-test"
15 | ]
16 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.exclude": {
4 | "out": false // set this to true to hide the "out" folder with the compiled JS files
5 | },
6 | "search.exclude": {
7 | "out": true // set this to false to include "out" folder in search results
8 | },
9 | "typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
10 | }
--------------------------------------------------------------------------------
/test/extension.test.ts:
--------------------------------------------------------------------------------
1 | //
2 | // Note: This example test is leveraging the Mocha test framework.
3 | // Please refer to their documentation on https://mochajs.org/ for help.
4 | //
5 |
6 | // The module 'assert' provides assertion methods from node
7 | import * as assert from 'assert';
8 |
9 | // You can import and use all API from the 'vscode' module
10 | // as well as import your extension to test it
11 | import * as vscode from 'vscode';
12 | import * as myExtension from '../src/extension';
13 |
14 | // Defines a Mocha test suite to group tests of similar kind together
15 | suite("Extension Tests", () => {
16 |
17 | // Defines a Mocha unit test
18 | test("Something 1", () => {
19 | assert.equal(-1, [1, 2, 3].indexOf(5));
20 | assert.equal(-1, [1, 2, 3].indexOf(0));
21 | });
22 | });
--------------------------------------------------------------------------------
/test/index.ts:
--------------------------------------------------------------------------------
1 | //
2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
3 | //
4 | // This file is providing the test runner to use when running extension tests.
5 | // By default the test runner in use is Mocha based.
6 | //
7 | // You can provide your own test runner if you want to override it by exporting
8 | // a function run(testRoot: string, clb: (error:Error) => void) that the extension
9 | // host can call to run the tests. The test runner is expected to use console.log
10 | // to report the results back to the caller. When the tests are finished, return
11 | // a possible error to the callback or null if none.
12 |
13 | var testRunner = require('vscode/lib/testrunner');
14 |
15 | // You can directly control Mocha options by uncommenting the following lines
16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
17 | testRunner.configure({
18 | ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
19 | useColors: true // colored output from test results
20 | });
21 |
22 | module.exports = testRunner;
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that compiles the extension and then opens it inside a new window
2 | {
3 | "version": "0.1.0",
4 | "configurations": [
5 | {
6 | "name": "Launch Extension",
7 | "type": "extensionHost",
8 | "request": "launch",
9 | "runtimeExecutable": "${execPath}",
10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
11 | "stopOnEntry": false,
12 | "sourceMaps": true,
13 | "outDir": "${workspaceRoot}/out/src",
14 | "preLaunchTask": "npm"
15 | },
16 | {
17 | "name": "Launch Tests",
18 | "type": "extensionHost",
19 | "request": "launch",
20 | "runtimeExecutable": "${execPath}",
21 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
22 | "stopOnEntry": false,
23 | "sourceMaps": true,
24 | "outDir": "${workspaceRoot}/out/test",
25 | "preLaunchTask": "npm"
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | // Available variables which can be used inside of strings.
2 | // ${workspaceRoot}: the root folder of the team
3 | // ${file}: the current opened file
4 | // ${fileBasename}: the current opened file's basename
5 | // ${fileDirname}: the current opened file's dirname
6 | // ${fileExtname}: the current opened file's extension
7 | // ${cwd}: the current working directory of the spawned process
8 |
9 | // A task runner that calls a custom npm script that compiles the extension.
10 | {
11 | "version": "0.1.0",
12 |
13 | // we want to run npm
14 | "command": "npm",
15 |
16 | // the command is a shell script
17 | "isShellCommand": true,
18 |
19 | // show the output window only if unrecognized errors occur.
20 | "showOutput": "silent",
21 |
22 | // we run the custom script "compile" as defined in package.json
23 | "args": ["run", "compile", "--loglevel", "silent"],
24 |
25 | // The tsc compiler is started in watching mode
26 | "isWatching": true,
27 |
28 | // use the standard tsc in watch mode problem matcher to find compile problems in the output.
29 | "problemMatcher": "$tsc-watch"
30 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Gradle",
3 | "description": "Run gradle tasks from within Visual Studio Code",
4 | "version": "1.0.0",
5 | "publisher": "cazzar09",
6 | "icon": "icon.png",
7 | "readme": "README.md",
8 | "author": {"name": "Cayde Dixon", "url": "http://cazzar.net", "email": "me@cazzar.net"},
9 | "maintainers": [{"name": "Cayde Dixon", "url": "http://cazzar.net", "email": "me@cazzar.net"}],
10 | "bugs": {
11 | "email": "me@cazzar.net",
12 | "url": "https://github.com/Cazzar/vscode-gradle/issues"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/Cazzar/vscode-gradle/"
17 | },
18 | "license": "MIT",
19 | "engines": {
20 | "vscode": "^1.5.1"
21 | },
22 | "categories": [
23 | "Other"
24 | ],
25 | "activationEvents": [
26 | "onCommand:gradle"
27 | ],
28 | "main": "./out/src/extension",
29 | "contributes": {
30 | "commands": [{
31 | "command": "gradle",
32 | "title": "Gradle"
33 | }],
34 | "configuration": {
35 | "type": "object",
36 | "title": "Gradle configuration",
37 | "properties": {
38 | "gradle.useCommand": {
39 | "type": "string",
40 | "default": "gradlew",
41 | "description": "use this command to run gradle."
42 | }
43 | }
44 | }
45 | },
46 | "scripts": {
47 | "vscode:prepublish": "tsc -p ./",
48 | "compile": "tsc -watch -p ./",
49 | "postinstall": "node ./node_modules/vscode/bin/install"
50 | },
51 | "devDependencies": {
52 | "typescript": "^2.0.3",
53 | "vscode": "^1.0.0",
54 | "mocha": "^2.3.3",
55 | "@types/node": "^6.0.40",
56 | "@types/mocha": "^2.2.32"
57 | }
58 | }
--------------------------------------------------------------------------------
/src/extension.ts:
--------------------------------------------------------------------------------
1 | import {window, workspace, commands, ExtensionContext, QuickPickItem, OutputChannel, Disposable} from 'vscode';
2 | import * as proc from 'child_process'
3 |
4 | var cacheNeeded: boolean = true;
5 |
6 | var TaskCache: QuickPickItem[] = [];
7 | var outputChannel: OutputChannel = null;
8 |
9 | export function activate(context: ExtensionContext) {
10 | // const cwd = workspace.rootPath;
11 | outputChannel = window.createOutputChannel("Gradle")
12 | const disposable = commands.registerCommand('gradle', () => {
13 |
14 | return window.showQuickPick(list()).then((task: QuickPickItem) => {
15 | var statusbar: Disposable = window.setStatusBarMessage("Running...")
16 | outputChannel.show();
17 | var process = proc.exec(
18 | cmd() + " " + task.label,
19 | {cwd: workspace.rootPath},
20 | (err, stdout, stderr) => {
21 | if (err) window.showErrorMessage("An error occured");
22 | else window.showInformationMessage("Success!");
23 | outputChannel.append(stdout);
24 | });
25 | process.stdout.on("data", data => outputChannel.append(data.toString()));
26 | process.stderr.on("data", data => outputChannel.append("[ERR] " + data));
27 | statusbar.dispose();
28 | })
29 | });
30 |
31 | context.subscriptions.push(disposable);
32 | }
33 |
34 | function cmd(): string { return workspace.getConfiguration().get("gradle.useCommand", "gradlew"); }
35 |
36 | function list(): Thenable {
37 | const regex = /$\s*([a-z0-9]+)\s-\s(.*)$/mgi;
38 |
39 | return new Promise(resolve => {
40 | if (cacheNeeded) {
41 | outputChannel.show();
42 | var process = proc.exec(cmd() + " tasks", {cwd: workspace.rootPath}, (err, stdout, stderr) => {
43 | if (err) { return resolve([])}
44 | var match: RegExpExecArray;
45 | var items: QuickPickItem[] = [];
46 |
47 | while ((match = regex.exec(stdout.toString())) !== null) {
48 | items.push({
49 | label: match[1],
50 | description: match[2],
51 | })
52 | }
53 |
54 | TaskCache = items;
55 | // cacheNeeded = false; //Maybe I'll implement this later...
56 | return resolve(items);
57 | });
58 | process.stdout.on("data", data => outputChannel.append(data.toString()));
59 | process.stderr.on("data", data => outputChannel.append("[ERR] " + data));
60 |
61 | }
62 | else return resolve(TaskCache);
63 | })
64 | }
--------------------------------------------------------------------------------