6
6
import * as fse from 'fs-extra' ;
7
7
import * as path from 'path' ;
8
8
import * as vscode from 'vscode' ;
9
- import { MessageItem } from 'vscode' ;
10
9
import { UserCancelledError } from 'vscode-azureextensionui' ;
11
10
import { AzureAccount } from '../azure-account.api' ;
12
11
import { DialogResponses } from '../DialogResponses' ;
@@ -20,6 +19,7 @@ import { TemplateData } from '../templates/TemplateData';
20
19
import { cpUtils } from '../utils/cpUtils' ;
21
20
import * as fsUtil from '../utils/fs' ;
22
21
import { getJavaClassName , validateJavaFunctionName , validatePackageName } from '../utils/javaNameUtils' ;
22
+ import { mavenUtils } from '../utils/mavenUtils' ;
23
23
import { projectUtils } from '../utils/projectUtils' ;
24
24
import * as workspaceUtil from '../utils/workspace' ;
25
25
import { VSCodeUI } from '../VSCodeUI' ;
@@ -54,7 +54,7 @@ function validateTemplateName(rootPath: string, name: string | undefined, langua
54
54
async function validateIsFunctionApp ( telemetryProperties : { [ key : string ] : string ; } , outputChannel : vscode . OutputChannel , functionAppPath : string , ui : IUserInterface ) : Promise < void > {
55
55
if ( requiredFunctionAppFiles . find ( ( file : string ) => ! fse . existsSync ( path . join ( functionAppPath , file ) ) ) !== undefined ) {
56
56
const message : string = localize ( 'azFunc.notFunctionApp' , 'The selected folder is not a function app project. Initialize Project?' ) ;
57
- const result : MessageItem | undefined = await vscode . window . showWarningMessage ( message , DialogResponses . yes , DialogResponses . skipForNow , DialogResponses . cancel ) ;
57
+ const result : vscode . MessageItem | undefined = await vscode . window . showWarningMessage ( message , DialogResponses . yes , DialogResponses . skipForNow , DialogResponses . cancel ) ;
58
58
if ( result === DialogResponses . yes ) {
59
59
await createNewProject ( telemetryProperties , outputChannel , functionAppPath , false , ui ) ;
60
60
} else if ( result === undefined ) {
@@ -166,6 +166,9 @@ export async function createFunction(
166
166
167
167
let newFilePath : string ;
168
168
if ( languageType === TemplateLanguage . Java ) {
169
+ if ( ! ( await mavenUtils . isMavenInstalled ( functionAppPath ) ) ) {
170
+ throw new Error ( localize ( 'azFunc.mvnNotFound' , 'Failed to find "maven" on path.' ) ) ;
171
+ }
169
172
outputChannel . show ( ) ;
170
173
await cpUtils . executeCommand (
171
174
outputChannel ,
0 commit comments