Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support run build from tasks #660

Merged
merged 5 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions extension.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ export { contextManager } from "./src/contextManager";
export { DependencyExplorer } from "./src/views/dependencyExplorer";
export { Commands } from "./src/commands";
export { LanguageServerMode } from "./src/languageServerApi/LanguageServerMode";

// tasks
export { BuildTaskProvider, categorizePaths, getFinalPaths } from "./src/tasks/build/buildTaskProvider";
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,40 @@
"description": "%taskDefinitions.java.project.exportJar.elements%"
}
}
},
{
"type": "java (build)",
"properties": {
"paths": {
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"enum": [
"${workspace}",
"!<path>"
],
"enumDescriptions": [
"%taskDefinitions.java.project.build.path.workspace%",
"%taskDefinitions.java.project.build.path.exclude%"
]
}
]
},
"default": [
"${workspace}"
],
"description": "%taskDefinitions.java.project.build.path%"
},
"isFullBuild": {
"type": "boolean",
"default": "true",
"description": "%taskDefinitions.java.project.build.isFullBuild%"
}
}
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"taskDefinitions.java.project.exportJar.testCompileOutput": "The folders containing output class files in the test scope.",
"taskDefinitions.java.project.exportJar.dependencies": "The artifact dependencies in the runtime scope.",
"taskDefinitions.java.project.exportJar.testDependencies": "The artifact dependencies in the test scope.",
"taskDefinitions.java.project.build.path": "The project root paths that will be built. Both absolute path and relative path to the workspace folder are supported.",
"taskDefinitions.java.project.build.path.workspace": "All the projects in workspace.",
"taskDefinitions.java.project.build.path.exclude": "The path after '!' will be excluded from the paths to be built.",
"taskDefinitions.java.project.build.isFullBuild": "Whether to execute a clean build or not.",
"viewsWelcome.workbench.createNewJavaProject": "You can also [open a Java project folder](command:_java.project.open), or create a new Java project by clicking the button below.\n[Create Java Project](command:java.project.create)",
"viewsWelcome.workbench.noJavaProject": "No Java projects found in the current workspace. You can [open a Java project folder](command:_java.project.open), or create a new Java project by clicking the button below.\n[Create Java Project](command:java.project.create)",
"viewsWelcome.workbench.inLightWeightMode": "To view the projects, you can import the projects into workspace.\n[Import Projects](command:java.server.mode.switch?%5B%22Standard%22,true%5D)",
Expand Down
4 changes: 4 additions & 0 deletions package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"taskDefinitions.java.project.exportJar.testCompileOutput": "在 test scope 内包含输出的 class 文件的文件夹。",
"taskDefinitions.java.project.exportJar.dependencies": "在 runtime scope 内的依赖。",
"taskDefinitions.java.project.exportJar.testDependencies": "在 test scope 内的依赖。",
"taskDefinitions.java.project.build.path": "被构建项目的根目录路径。绝对路径或者相对于工作空间目录的相对路径都可以使用。",
"taskDefinitions.java.project.build.path.workspace": "工作空间中的所有项目。",
"taskDefinitions.java.project.build.path.exclude": "'!' 后的路径将会从待构建项目路径中移除。",
"taskDefinitions.java.project.build.isFullBuild": "是否要重新构建项目。",
"viewsWelcome.workbench.createNewJavaProject": "您也可以[打开一个 Java 项目目录](command:_java.project.open),或点击下方按钮创建一个新的 Java 项目。\n[创建 Java 项目](command:java.project.create)",
"viewsWelcome.workbench.noJavaProject": "当前工作空间未发现 Java 项目,您可以[打开一个 Java 项目目录](command:_java.project.open),或点击下方按钮创建一个新的 Java 项目。\n[创建 Java 项目](command:java.project.create)",
"viewsWelcome.workbench.inLightWeightMode": "要浏览项目信息,你可以将项目导入到工作空间中。\n[导入项目](command:java.server.mode.switch?%5B%22Standard%22,true%5D)",
Expand Down
2 changes: 1 addition & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function handleBuildFailure(operationId: string, err: any): Promise<boolea
return false;
}

function checkErrorsReportedByJavaExtension(): boolean {
export function checkErrorsReportedByJavaExtension(): boolean {
const problems = languages.getDiagnostics() || [];
for (const problem of problems) {
const fileName = basename(problem[0].fsPath || "");
Expand Down
8 changes: 8 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,18 @@ export namespace Commands {

export const WORKBENCH_ACTION_FILES_OPENFILEFOLDER = "workbench.action.files.openFileFolder";

export const WORKBENCH_VIEW_PROBLEMS = "workbench.actions.view.problems";

/**
* Commands from JLS
*/
export const LIST_SOURCEPATHS = "java.project.listSourcePaths";

export const COMPILE_WORKSPACE = "java.workspace.compile";

export const GET_ALL_PROJECTS = "java.project.getAll";

export const BUILD_PROJECT = "java.project.build";
}

export function executeJavaLanguageServerCommand(...rest: any[]) {
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { commands, Extension, ExtensionContext, extensions, tasks, Uri, workspace } from "vscode";
import { dispose as disposeTelemetryWrapper, initializeFromJsonFile, instrumentOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
import { Commands, contextManager } from "../extension.bundle";
import { BuildTaskProvider } from "./tasks/build/buildTaskProvider";
import { Context, ExtensionName } from "./constants";
import { LibraryController } from "./controllers/libraryController";
import { ProjectController } from "./controllers/projectController";
Expand Down Expand Up @@ -38,6 +39,7 @@ async function activateExtension(_operationId: string, context: ExtensionContext
context.subscriptions.push(contextManager);
context.subscriptions.push(syncHandler);
context.subscriptions.push(tasks.registerTaskProvider(ExportJarTaskProvider.exportJarType, new ExportJarTaskProvider()));
context.subscriptions.push(tasks.registerTaskProvider(BuildTaskProvider.type, new BuildTaskProvider()));
}

// this method is called when your extension is deactivated
Expand Down
4 changes: 4 additions & 0 deletions src/java/jdtls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export namespace Jdtls {
return await commands.executeCommand(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.JAVA_PROJECT_LIST, params) || [];
}

export async function getProjectUris(): Promise<string[]> {
return await commands.executeCommand(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.GET_ALL_PROJECTS) || [];
}

export async function refreshLibraries(params: string): Promise<boolean | undefined> {
return commands.executeCommand(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.JAVA_PROJECT_REFRESH_LIB_SERVER, params);
}
Expand Down
Loading