Support to create project with specific archetype version (#357)

* can create project with specific archetype version

* update archetype list

* update changelog

* update testplan
This commit is contained in:
Yan Zhang 2019-07-01 11:20:29 +08:00 коммит произвёл GitHub
Родитель 6cd3f33a94
Коммит 3c36c1eb8c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 38 добавлений и 20 удалений

Просмотреть файл

@ -3,7 +3,9 @@ All notable changes to the "vscode-maven" extension will be documented in this f
## 0.18.0
#### Added
- Fallback to use an embedded Maven wrapper if no availble Maven executable is found. [PR#344](https://github.com/microsoft/vscode-maven/pull/344)
- For Maven project creation:
- Fallback to use an embedded Maven wrapper if no availble Maven executable is found. [PR#344](https://github.com/microsoft/vscode-maven/pull/344)
- Support to select archetype version. [#354](https://github.com/microsoft/vscode-maven/issues/354)
- Refresh explorer when config `maven.pomfile.globPattern` changes. [#334](https://github.com/microsoft/vscode-maven/issues/334)
#### Changed

Просмотреть файл

@ -89,26 +89,28 @@
## Maven Archetypes
### Generate project from maven archetypes
1. Right-click a target folder in file explorer view.
2. Click `Generate from Maven Archetype`.
2. Click `Create Maven Project`.
3. Verify:
1. It should show a dropdown list of popular maven archetypes.
2. The first item is `More ...`.
4. Select one of the listed archetype.
5. Select the target folder in the popup dialog.
6. Verify:
5. Select one of the listed version.
6. Select the target folder in the popup dialog.
7. Verify:
1. It opens an integrated terminal, and navigates to the target folder you previously selected.
2. It issues the corresponding maven command (archetype:generate) with correct parameters.
3. You can interactively continue to fill in missing params in the terminal to complete the task.
### Generate project from maven archetypes (for empty workspace)
1. Open Command Palette.
2. Click `Maven: Generate from Maven Archetype`.
2. Click `Maven: Create Maven Project`.
3. Verify:
1. It should show a dropdown list of popular maven archetypes.
2. The first item is `More ...`.
4. Select one of the listed archetype.
5. Select the target folder in the popup dialog.
6. Verify:
5. Select one of the listed version.
6. Select the target folder in the popup dialog.
7. Verify:
1. It opens an integrated terminal, and navigates to the target folder you previously selected.
2. It issues the corresponding maven command (archetype:generate) with correct parameters.
3. You can interactively continue to fill in missing params in the terminal to complete the task.
@ -124,7 +126,7 @@
## Executable related
### Maven Wrapper support
1. Clone code https://github.com/Microsoft/todo-app-java-on-azure.git
2. Test `clean`, `Generate project from Maven Archetype` and `Effective POM`.
2. Test `clean`, `Create Maven Project` and `Effective POM`.
3. Verify:
1. It uses `./mvnw` in the root folder as executable, and no error occurs.
@ -134,10 +136,18 @@
3. Change value of `maven.executable.path` according to the maven executable absolute path.
* For maven executables, use path of `mvn` / `mvn.cmd`
* For maven wrapper, use path of `mvnw` / `mvnw.cmd`
4. Test `clean`, `Generate project from Maven Archetype` and `Effective POM`.
4. Test `clean`, `Create Maven Project` and `Effective POM`.
5. Verify:
1. Corresponding executable is used and commands can be successfully executed with no error.
### Fallback Embedded Maven Wrapper
1. Make sure `mvn` is not in `PATH`, i.e., you can not directly run `mvn`.
2. Launch VS Code without opening any folder.
3. Open Command Palette and click `Maven: Create Maven Project`.
4. Select archetype, version, and target folder.
5. Verify:
1. It should create project in the target folder.
## Pom.xml file watcher
The tree view of maven projects should update when any pom.xml is created/modified/deleted in the current workspace.

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -16,7 +16,7 @@ const REMOTE_ARCHETYPE_CATALOG_URL: string = "https://repo.maven.apache.org/mave
const POPULAR_ARCHETYPES_URL: string = "https://vscodemaventelemetry.blob.core.windows.net/public/popular_archetypes.json";
export namespace ArchetypeModule {
async function selectArchetype(): Promise<Archetype> {
async function selectArchetype(): Promise<{ artifactId: string, groupId: string, version: string }> {
let selectedArchetype: Archetype | undefined | null = await showQuickPickForArchetypes();
while (selectedArchetype === null) {
selectedArchetype = await showQuickPickForArchetypes(true);
@ -24,8 +24,14 @@ export namespace ArchetypeModule {
if (selectedArchetype === undefined) {
throw new OperationCanceledError("Archetype not selected.");
}
return selectedArchetype;
const version: string | undefined = await window.showQuickPick(selectedArchetype.versions, {
placeHolder: "Select a version ..."
});
if (version === undefined) {
throw new OperationCanceledError("Archetype version not selected.");
}
const { artifactId, groupId } = selectedArchetype;
return { artifactId, groupId, version };
}
async function chooseTargetFolder(entry: Uri | undefined): Promise<string> {
@ -40,11 +46,12 @@ export namespace ArchetypeModule {
return cwd;
}
async function executeInTerminalHandler(archetypeGroupId: string, archetypeArtifactId: string, targetFolder: string): Promise<void> {
async function executeInTerminalHandler(archetypeGroupId: string, archetypeArtifactId: string, archetypeVersion: string, targetFolder: string): Promise<void> {
const cmdArgs: string[] = [
"archetype:generate",
`-DarchetypeArtifactId="${archetypeArtifactId}"`,
`-DarchetypeGroupId="${archetypeGroupId}"`
`-DarchetypeGroupId="${archetypeGroupId}"`,
`-DarchetypeVersion="${archetypeVersion}"`
];
let mvnPath: string | undefined;
let cwd: string = targetFolder;
@ -58,8 +65,8 @@ export namespace ArchetypeModule {
export async function generateFromArchetype(entry: Uri | undefined, operationId: string): Promise<void> {
// select archetype.
const { artifactId, groupId } = await instrumentOperationStep(operationId, "selectArchetype", selectArchetype)();
sendInfo(operationId, { archetypeArtifactId: artifactId, archetypeGroupId: groupId });
const { artifactId, groupId, version } = await instrumentOperationStep(operationId, "selectArchetype", selectArchetype)();
sendInfo(operationId, { archetypeArtifactId: artifactId, archetypeGroupId: groupId, archetypeVersion: version });
// choose target folder.
let targetFolderHint: Uri | undefined;
@ -71,7 +78,7 @@ export namespace ArchetypeModule {
const cwd: string = await instrumentOperationStep(operationId, "chooseTargetFolder", chooseTargetFolder)(targetFolderHint);
// execute in terminal.
await instrumentOperationStep(operationId, "executeInTerminal", executeInTerminalHandler)(groupId, artifactId, cwd);
await instrumentOperationStep(operationId, "executeInTerminal", executeInTerminalHandler)(groupId, artifactId, version, cwd);
}
export async function updateArchetypeCatalog(): Promise<void> {

Просмотреть файл

@ -291,6 +291,5 @@
"no-switch-case-fall-through": false,
"typeof-compare": false
},
"rulesDirectory": "node_modules/tslint-microsoft-contrib/",
"defaultSeverity": "warning"
"rulesDirectory": "node_modules/tslint-microsoft-contrib/"
}