Коммит
91a3f59f73
|
@ -1,5 +1,6 @@
|
|||
# vscode-gradle
|
||||
|
||||
[![Build status](https://img.shields.io/github/workflow/status/badsyntax/vscode-gradle/Build)](https://github.com/badsyntax/vscode-gradle/actions?query=workflow%3ABuild)
|
||||
[![Marketplace Version](https://vsmarketplacebadge.apphb.com/version-short/richardwillis.vscode-gradle.svg)](https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-gradle)
|
||||
[![Installs](https://vsmarketplacebadge.apphb.com/installs-short/richardwillis.vscode-gradle.svg)](https://marketplace.visualstudio.com/items?itemName=richardwillis.vscode-gradle)
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ public class CliApp {
|
|||
this.targetFile = targetFile;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
public static void main(String[] args) throws CliAppException, IOException {
|
||||
if (args.length < 2) {
|
||||
throw new RuntimeException("No source directory and/or target file specified");
|
||||
throw new CliAppException("No source directory and/or target file specified");
|
||||
}
|
||||
String dirName = args[0];
|
||||
File sourceDir = new File(dirName);
|
||||
if (!sourceDir.exists()) {
|
||||
throw new RuntimeException("Source directory does not exist");
|
||||
throw new CliAppException("Source directory does not exist");
|
||||
}
|
||||
String targetFileName = args[1];
|
||||
File targetFile = new File(targetFileName);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.github.badsyntax.gradletasks;
|
||||
|
||||
public class CliAppException extends Exception {
|
||||
public CliAppException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CliAppException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* This Java source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package co.badsyntax.gradleapi;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AppTest {
|
||||
// @Test public void testAppHasAGreeting() {
|
||||
// App classUnderTest = new App();
|
||||
// assertNotNull("app should have a greeting", classUnderTest.getGreeting());
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package co.badsyntax.gradletasks;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.github.badsyntax.gradletasks.CliApp;
|
||||
import com.github.badsyntax.gradletasks.CliAppException;
|
||||
|
||||
public class CliAppTest {
|
||||
@Test
|
||||
public void testAppValidatesArguments() {
|
||||
final String exceptionMessage = "No source directory and/or target file specified";
|
||||
final String[] noArgs = {};
|
||||
try {
|
||||
CliApp.main(noArgs);
|
||||
fail("Should throw exception");
|
||||
} catch (CliAppException | IOException e) {
|
||||
assertEquals(exceptionMessage, e.getMessage());
|
||||
}
|
||||
|
||||
final String[] oneArg = {"onearg"};
|
||||
try {
|
||||
CliApp.main(oneArg);
|
||||
fail("Should throw exception");
|
||||
} catch (CliAppException | IOException e) {
|
||||
assertEquals(exceptionMessage, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,12 +34,15 @@ describe(fixtureName, () => {
|
|||
assert.equal(tasks.length > 0, true);
|
||||
});
|
||||
|
||||
it('should run a gradle task', async () => {
|
||||
it('should run a gradle task', done => {
|
||||
const task = tasks.find(task => task.name === 'hello');
|
||||
assert.ok(task);
|
||||
if (task) {
|
||||
await vscode.tasks.executeTask(task);
|
||||
}
|
||||
vscode.tasks.onDidEndTaskProcess(e => {
|
||||
if (e.execution.task === task) {
|
||||
done(e.exitCode === 0 ? undefined : 'Process error');
|
||||
}
|
||||
});
|
||||
vscode.tasks.executeTask(task!);
|
||||
});
|
||||
|
||||
it('should refresh tasks', async () => {
|
||||
|
@ -51,19 +54,17 @@ describe(fixtureName, () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('explorer', () => {});
|
||||
|
||||
describe('logging', () => {
|
||||
it('should show command statements in the outputchannel', async () => {
|
||||
const extension = vscode.extensions.getExtension(
|
||||
'richardwillis.vscode-gradle'
|
||||
);
|
||||
if (extension) {
|
||||
const outputChannel = extension.exports.outputChannel;
|
||||
sinon.replace(outputChannel, 'appendLine', sinon.fake());
|
||||
await vscode.commands.executeCommand('gradle.refresh');
|
||||
assert.ok(
|
||||
outputChannel.appendLine.calledWith(sinon.match(/Executing/))
|
||||
);
|
||||
}
|
||||
const outputChannel = extension!.exports.outputChannel;
|
||||
sinon.replace(outputChannel, 'appendLine', sinon.fake());
|
||||
await vscode.commands.executeCommand('gradle.refresh');
|
||||
assert.ok(outputChannel.appendLine.calledWith(sinon.match(/Executing/)));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,9 +18,7 @@ describe(fixtureName, () => {
|
|||
'richardwillis.vscode-gradle'
|
||||
);
|
||||
assert.ok(extension);
|
||||
if (extension) {
|
||||
assert.equal(extension.isActive, true);
|
||||
}
|
||||
assert.equal(extension!.isActive, true);
|
||||
});
|
||||
|
||||
describe('tasks', () => {
|
||||
|
@ -37,21 +35,22 @@ describe(fixtureName, () => {
|
|||
it('should run a gradle task', async () => {
|
||||
const task = tasks.find(task => task.name === 'hello');
|
||||
assert.ok(task);
|
||||
if (task) {
|
||||
await vscode.tasks.executeTask(task);
|
||||
}
|
||||
await vscode.tasks.executeTask(task!);
|
||||
});
|
||||
|
||||
it('should run a subproject gradle task', async () => {
|
||||
it('should run a subproject gradle task', done => {
|
||||
const task = tasks.find(
|
||||
task =>
|
||||
task.definition.script ===
|
||||
'subproject-example:sub-subproject-example:helloGroovySubSubProject'
|
||||
);
|
||||
assert.ok(task);
|
||||
if (task) {
|
||||
await vscode.tasks.executeTask(task);
|
||||
}
|
||||
vscode.tasks.onDidEndTaskProcess(e => {
|
||||
if (e.execution.task === task) {
|
||||
done(e.exitCode === 0 ? undefined : 'Process error');
|
||||
}
|
||||
});
|
||||
vscode.tasks.executeTask(task!);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,9 +31,7 @@ describe(fixtureName, () => {
|
|||
({ name }) => name === 'helloGroovyDefault'
|
||||
);
|
||||
assert.ok(groovyDefaultTask);
|
||||
if (groovyDefaultTask) {
|
||||
assert.equal(groovyDefaultTask.definition.project, 'gradle');
|
||||
}
|
||||
assert.equal(groovyDefaultTask!.definition.project, 'gradle');
|
||||
});
|
||||
|
||||
it('should load kotlin default build file tasks', () => {
|
||||
|
@ -41,9 +39,7 @@ describe(fixtureName, () => {
|
|||
({ name }) => name === 'helloKotlinDefault'
|
||||
);
|
||||
assert.ok(kotlinTask);
|
||||
if (kotlinTask) {
|
||||
assert.equal(kotlinTask.definition.project, 'gradle-kotlin');
|
||||
}
|
||||
assert.equal(kotlinTask!.definition.project, 'gradle-kotlin');
|
||||
});
|
||||
|
||||
it('should load groovy custom build file tasks', () => {
|
||||
|
@ -51,20 +47,21 @@ describe(fixtureName, () => {
|
|||
({ name }) => name === 'helloGroovyCustom'
|
||||
);
|
||||
assert.ok(groovyCustomTask);
|
||||
if (groovyCustomTask) {
|
||||
assert.equal(
|
||||
groovyCustomTask.definition.project,
|
||||
'gradle-groovy-custom-build-file'
|
||||
);
|
||||
}
|
||||
assert.equal(
|
||||
groovyCustomTask!.definition.project,
|
||||
'gradle-groovy-custom-build-file'
|
||||
);
|
||||
});
|
||||
|
||||
it('should successfully run a custom task', async () => {
|
||||
it('should successfully run a custom task', done => {
|
||||
const task = tasks.find(task => task.name === 'hello');
|
||||
assert.ok(task);
|
||||
if (task) {
|
||||
await vscode.tasks.executeTask(task);
|
||||
}
|
||||
vscode.tasks.onDidEndTaskProcess(e => {
|
||||
if (e.execution.task === task) {
|
||||
done(e.exitCode === 0 ? undefined : 'Process error');
|
||||
}
|
||||
});
|
||||
vscode.tasks.executeTask(task!);
|
||||
});
|
||||
|
||||
it('should refresh tasks', async () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче