-
Notifications
You must be signed in to change notification settings - Fork 136
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
Support create java function project & add java function #66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the plan for create Function? If the user has to interact with the terminal, then I don't think the behavior is ship-able. We should at least display quick picks for the type of template
src/utils/workspace.ts
Outdated
@@ -32,3 +35,15 @@ export function isFolderOpenInWorkspace(fsPath: string): boolean { | |||
return false; | |||
} | |||
} | |||
|
|||
export function getProjectType(projectPath: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is for 'workspace' utilities, but this function doesn't use vscode.workspace at all. Just move it into 'createFunction' (the only place it's used)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll use this method again for deploying Java functions. How about making a new file called 'project.ts' and move to it?
src/utils/executor.ts
Outdated
terminal.sendText(command, addNewLine); | ||
} | ||
|
||
export async function executeCommand(outputChannel: vscode.OutputChannel, workingDirectory: string, command: string, ...args: string[]): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use cpUtils.executeCommand instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
'-B' // in Batch Mode | ||
); | ||
|
||
functionAppPath = path.join(functionAppPath, artifactId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you were going to file an issue for this? It's really annoying and we need to make sure we fix it before release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the extra folder of artifactId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break; | ||
default: | ||
// the maven archetype contains these files, so not check them when language is Java | ||
const hostJsonPath: string = path.join(functionAppPath, 'host.json'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the maven archetype have these files? Shouldn't it let VS Code (or the func cli) handle it? Same with the .gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you own the maven archetype or does someone else? I thought you guys created it
src/utils/executor.ts
Outdated
const terminal: vscode.Terminal = vscode.window.createTerminal('Azure Functions'); | ||
|
||
export function runCommandInTerminal(command: string, addNewLine: boolean = true): void { | ||
terminal.show(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't like using terminal because then you have no idea when the command finishes
src/utils/workspace.ts
Outdated
|
||
export function getProjectType(projectPath: string): string { | ||
let language: string = TemplateLanguage.JavaScript; | ||
fse.readdirSync(projectPath).forEach((file: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use async methods wherever possible (in this case, you would use readdir
instead of readdirsync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using fse.pathExists()
.
src/utils/workspace.ts
Outdated
let language: string = TemplateLanguage.JavaScript; | ||
fse.readdirSync(projectPath).forEach((file: string) => { | ||
const stat: fse.Stats = fse.statSync(path.join(projectPath, file)); | ||
// Currently checking the existing pom.xml to determine whether the function project is Java language based. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't pom.xml at the root of the project? Couldn't you just do fse.pathExists(path.join(projectPath, 'pom.xml'))
?
If it's not always at the root, then we need to find a different way to detect Java projects - iterating through an entire folder has bad performance for the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's at the root path. I like the idea of using fse.pathExists()
test/createNewProject.test.ts
Outdated
assert.equal(inputs.length, 0, 'Not all inputs were used.'); | ||
} | ||
|
||
async function testInitFileExist(projectPath: string): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: testProjectFilesExist
(I don't know what InitFile
means)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense.
src/commands/createFunction.ts
Outdated
|
||
if (template.bindingType !== 'httpTrigger') { | ||
await localAppSettings.validateAzureWebJobsStorage(); | ||
const languageType: string = workspaceUtil.getProjectType(functionAppPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you infer the project type? I can easily create C# and JavaScript functions in the same project from the command line today.
Shouldn't I be able to create 'Java' and 'JavaScript' functions in the same project from VS Code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about let the user choose the language he/she wants to add by showing Picks?
src/utils/executor.ts
Outdated
|
||
import * as vscode from 'vscode'; | ||
|
||
const terminal: vscode.Terminal = vscode.window.createTerminal('Azure Functions'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user closes/deletes the 'Azure Functions' terminal, then create new project will fail every time until they restart VS Code
'-B' // in Batch Mode | ||
); | ||
|
||
functionAppPath = path.join(functionAppPath, artifactId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think running in a terminal is a feature-blocker. Sent an email offline.
In the future, it would be better to do one PR for each feature. I'm sorry connect(); distracted us from getting this in last week, but I think the 'Create new Java Project' feature is good-to-go and it's just being blocked by issues with 'Create new Java function'
This PR add the following feature:
For creating java function project, we leverage maven archetype.
For adding java function, we leverage azure function maven plugin. The reason we call it in terminal is that the maven plugin does not support batch mode for this maven goal.
As to the tasks.json file for Java function, we do not use
dependOn
for tasks because this may causepreLaunchTask cannot be tracked
error in VS Code 1.18 (see issue here).------------- Update on Wed Nov 15 2017 09:12:33 GMT+0800 -------------
Remove the add Java function part, since the Maven plugin not support adding java function non-interactively.