Skip to content

Commit

Permalink
fix bug of using ./mvnw as maven executable (#75)
Browse files Browse the repository at this point in the history
* fix bug of using `./mvnw` as maven executable

* fix for no-workspace situation
  • Loading branch information
Eskibear authored Jul 12, 2018
1 parent dec2a54 commit 57b7371
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to the "vscode-maven" extension will be documented in this f
- [Change Log](#change-log)
- [Unreleased](#unreleased)
- [Released](#released)
- [0.9.2](#092)
- [0.9.1](#091)
- [0.9.0](#090)
- [0.8.0](#080)
- [0.7.0](#070)
Expand All @@ -15,6 +17,9 @@ All notable changes to the "vscode-maven" extension will be documented in this f
## Unreleased

## Released
### 0.9.2
- Fixed bug of using `./mvnw` as maven executable.

### 0.9.1
- Fetch list of popular archetypes on the fly. [#63](https://github.com/Microsoft/vscode-maven/pull/63)
- Guide users to setup correct mvn executable path when error occurs. [#66](https://github.com/Microsoft/vscode-maven/pull/66)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-maven",
"displayName": "Maven for Java",
"description": "Manage maven projects, execute goals, generate project from archetype, improve user experience for Java developers.",
"version": "0.9.1",
"version": "0.9.2",
"icon": "resources/logo.png",
"publisher": "vscjava",
"aiKey": "7c4292ac-8ca8-4e02-9f1c-0b73e1eeeca4",
Expand All @@ -17,7 +17,7 @@
"Maven",
"Java"
],
"homepage": "https://github.com/Microsoft/vscode-maven/blob/v0.9.1/README.md",
"homepage": "https://github.com/Microsoft/vscode-maven/blob/v0.9.2/README.md",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-maven.git"
Expand Down
14 changes: 12 additions & 2 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,20 @@ export namespace Utils {
}

export function getMavenVersion(): Promise<void> {
return new Promise<void>((resolve, reject) => {
return new Promise<void>(async (resolve, reject) => {
const customEnv: {} = VSCodeUI.setupEnvironment();
const mvnExecutablePath: string = workspace.getConfiguration("maven.executable").get<string>("path") || "mvn";
let mvnExecutableAbsolutePath: string = mvnExecutablePath;
if (workspace.workspaceFolders && workspace.workspaceFolders.length) {
for (const ws of workspace.workspaceFolders) {
if (await fse.exists(path.resolve(ws.uri.fsPath, mvnExecutablePath))) {
mvnExecutableAbsolutePath = path.resolve(ws.uri.fsPath, mvnExecutablePath);
break;
}
}
}
const execOptions: child_process.ExecOptions = {
cwd: path.dirname(workspace.getConfiguration("maven.executable").get<string>("path") || ""), /* fix for `mvnw --version` */
cwd: mvnExecutableAbsolutePath && path.dirname(mvnExecutableAbsolutePath),
env: Object.assign({}, process.env, customEnv)
};
child_process.exec(
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export function deactivate(): void {
// private helpers
async function checkMavenAvailablility(): Promise<void> {
try {
await Utils.getMavenVersion();
if (vscode.workspace.workspaceFolders) {
await Utils.getMavenVersion();
}
} catch (error) {
const OPTION_SHOW_FAQS: string = "Show FAQs";
const OPTION_OPEN_SETTINGS: string = "Open Settings";
Expand Down

0 comments on commit 57b7371

Please sign in to comment.