RepoMicrosoftMicrosoftpublished Jan 10, 2018seen 16h

microsoft/vscode-maven

TypeScript

Open original ↗

Captured source

source ↗
published Jan 10, 2018seen 16hcaptured 16hhttp 200method plain

microsoft/vscode-maven

Description: VSCode extension "Maven for Java"

Language: TypeScript

License: NOASSERTION

Stars: 207

Forks: 107

Open issues: 114

Created: 2018-01-10T07:10:39Z

Pushed: 2026-06-26T02:49:42Z

Default branch: main

Fork: no

Archived: no

README:

Maven for Java

![Build status](https://dev.azure.com/mseng/VSJava/_build/latest?definitionId=11975)

Features

Maven extension for VS Code. It provides a project explorer and shortcuts to execute Maven commands, improving user experience for Java developers who use Maven.

  • Support to generate projects from Maven Archetype.
  • Support to generate effective POM.
  • Provide shortcuts to common goals, plugin goals and customized commands.
  • Preserve command history to fast re-run.

Requirements

  • Java
  • Maven / Maven Wrapper

For troubleshooting, please refer to the page [HERE](Troubleshooting.md).

Basic Usage

Maven Explorer

The extension scans pom.xml in your workspace, and displays all Maven projects and their modules in the sidebar.

![Screenshot](images/explorer.png)

Run Plugin Goals

The extension parse effective-pom of Maven projects, and displays all plugins and plugin goals hierarchically.

![Screenshot](images/plugin.gif)

POM File Editing

The extension provides Maven specific completion suggestions when editing POM files, including snippets and artifact hints.

![Screenshot](images/completion.gif)

Re-Run Historical Commands

It preserves history of goals for each project, so you can fast re-run previous long commands, e.g. mvn -Dparam1=value1 -Dparam2=value2 -Dparam3=value3 ... There are 2 entries for it:

  • Command Palette -> select Maven: History ... -> Select a project -> Select command from the history
  • Right-click on a project -> Click History ... -> Select command from the history

![Screenshot](images/history.gif)

Archetype Related

Generate from Maven Archetype

The extension loads archetypes listed in local/remote catalog. After selection, the extension sends mvn archetype:generate -D... to terminal. There are 2 entries for it:

  • Command Palette -> select Maven: Generate from Maven Archetype
  • Right-click on a folder -> Click Generate from Maven Archetype

![Screenshot](images/archetype.gif)

Update Maven Archetype Catalog

With following steps, you can update the local cache of Maven remote catalog. It takes some time to download meta data from Maven central repository.

Command Palette -> select Maven: Update Maven Archetype Catalog.

Additional Configurations

JAVA_HOME and Other Environment Variables

This extension executes Maven by opening a terminal session and then calling Maven in that session. Maven requires the JAVA_HOME environment variable to be set. Maven will also look for other variables such as MAVEN_OPTS. If you prefer not to set those variables permanently you can configure them, or any other environment variable, in settings:

{
"maven.terminal.customEnv": [
{
"environmentVariable": "MAVEN_OPTS", // variable name
"value": "-Xms1024m -Xmx4096m" // value
},
{
"environmentVariable": "JAVA_HOME", // variable name
"value": "C:\\Program Files\\Java\\jdk-9.0.4" // value
}
]
}

> Using a different JDK for Maven than your system default > > If mvn is picking up the wrong JDK (e.g. the system default JDK 17 is used even though your project targets JDK 1.8), set the JAVA_HOME entry in maven.terminal.customEnv to the JDK installation you want Maven to use. This setting is honored by every command this extension runs — both Maven commands launched in the integrated terminal and background commands such as effective-pom generation. > > The setting is per-folder, so in a multi-root workspace you can configure a different JDK for each folder via the folder's .vscode/settings.json. > > Already-open Maven terminals keep their environment from the moment they were created. After changing this setting, close any existing Maven terminal (or reload the window) so the next command picks up the new value.

Special Handling for JAVA_HOME

To run Maven with a specific JDK, set JAVA_HOME via maven.terminal.customEnv (see the section above). This value is applied to both terminal commands and background commands launched by this extension.

Default Options for Maven Command The usage of Maven executable is:

> usage: mvn [options] [] []

You can use maven.executable.options to specify default options for all your Maven commands executed in current project.

{
"maven.executable.options": "-o -s ./settings.xml" // work offline and use an alternative settings file. Can also be defined as an array of strings, e.g. ["-o", "-s ./settings.xml"]
}

Folder Exclusion for Searching POM Files

To speed up the searching of Maven projects, you can exclude folders in settings:

{
"maven.excludedFolders": [
"**/.*", // exclude hidden folders
"**/node_modules", // exclude node modules to speed up
"**/target" // exclude duplicated pom file in target folder
]
}

Customize Favorite Maven Commands

Specify a favorite command in settings:

{
"maven.terminal.favorites": [
{
"alias": "full-build without tests",
"command": "clean package -DskipTests"
}
]
}

Now right-click on an project item, and then click Favorite .... The option full-build without tests should show up.

Settings

| Name | Description | Default Value | |---|---|---| | maven.dependency.enableConflictDiagnostics | Specify whether to show diagnostics for conflict dependencies. | true | | maven.excludedFolders | Specifies file path pattern of folders to exclude while searching for Maven projects. | [ "**/.*", "**/node_modules", "**/target", "**/bin", "**/archetype-resources" ] | | maven.executable.preferMavenWrapper | Specifies whether you prefer to use Maven wrapper. If true, it tries using 'mvnw' by walking up the parent folders. If false, or 'mvnw' is not found, it tries 'mvn' in PATH instead. | true | | maven.executable.path | Specifies absolute path of your 'mvn' executable. When this value is empty, it tries using 'mvn' or 'mvnw' according to the value of 'maven.executable.preferMavenWrapper'. E.g. /usr/local/apache-maven-3.6.0/bin/mvn | | | maven.executable.options | Specifies default options for all mvn commands. E.g. -o -DskipTests | | | maven.explorer.projectName | Format of project node name...

Excerpt shown — open the source for the full document.

Notability

notability 1.0/10

Not AI-related, Maven extension for VS Code.