VSCode extension "Maven for Java"
Перейти к файлу
Yan Zhang 5ab5911fd3
use cmd /c to execute maven command in powershell (#112)
2018-07-26 09:53:04 +08:00
.github/ISSUE_TEMPLATE Update issue templates 2018-06-14 15:52:19 +08:00
.vscode generated by yo 2017-11-10 13:30:04 +08:00
images update README & CHANGELOG, use collapsed blocks (#106) 2018-07-23 14:48:38 +08:00
resources support archetype from local-catalog (#86) 2018-07-17 16:11:39 +08:00
src use cmd /c to execute maven command in powershell (#112) 2018-07-26 09:53:04 +08:00
.gitignore Better maven archetype experience (#35) 2017-12-14 16:59:10 +08:00
.travis.yml fix travis 2017-12-06 12:09:21 +08:00
.vscodeignore Update documentation (#90) 2018-07-18 18:15:50 +08:00
CHANGELOG.md update README & CHANGELOG, use collapsed blocks (#106) 2018-07-23 14:48:38 +08:00
LICENSE.txt Update LICENSE.txt 2018-02-11 09:55:26 +08:00
README.md update Troubleshooting.md (#107) 2018-07-23 16:58:50 +08:00
TestPlan.md Update TestPlan.md (#108) 2018-07-24 09:47:29 +08:00
Troubleshooting.md update Troubleshooting.md (#107) 2018-07-23 16:58:50 +08:00
package-lock.json use cmd /c to execute maven command in powershell (#112) 2018-07-26 09:53:04 +08:00
package.json add a config: prefer using mvnw or not (#105) 2018-07-23 12:19:41 +08:00
thirdpartynotice.txt add 3rd party notice (#3) 2018-01-16 10:39:36 +08:00
tsconfig.json Better maven archetype experience (#35) 2017-12-14 16:59:10 +08:00
tslint.json Guide users to setup correct mvn executable path (#66) 2018-07-04 10:42:50 +08:00

README.md

Maven for Java

Marketplace Version Installs Rating Build Status

Features

Maven extension for VS Code. It provides a project explorer and shorcuts 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, namely clean, validate, compile, test, package, verify, install, site, deploy.
  • Perserve command history to fast re-run.

Requirements

  • Java
  • Maven / Maven Wrapper

For troubleshooting, please refer to the page HERE.

Basic Usage

Maven Explorer

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

Screenshot

Re-Run Historical Commands

It perserves history of goals for each project, so you can fast re-run previous long commands, e.g. mvn <goals> -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

Archetype Related

Generate from Maven Archetype

The extension loads archetypes listed in local/remote catelog. 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

Update Maven Archetype Catalog

With following steps, you can update the local cache of Maven remote catelog. 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
        }
    ]
}
Special Handling for JAVA_HOME

If you have Red Hat's Java Language Support extension installed, then you can specify JAVA_HOME in settings for that extension:

{
    "java.home": "C:\\Program Files\\Java\\jdk-9.0.4"      // Red Hat Java Language Support Setting
}

This extension (Maven for Java) can reuse that setting if you desire:

{
    "maven.terminal.useJavaHome": true      // Use the Red Hat Java Language Support Setting for JAVA_HOME
}

With this support, you can specify JAVA_HOME in one place and you do not need to use the maven.terminal.customEnv setting unless you have other environment variables to set.

If you have JAVA_HOME configured through the maven.terminal.customEnv setting, and also specify to reuse the Red Hat setting, then the value from maven.terminal.customEnv will take precedence.

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

usage: mvn [options] [<goal(s)>] [<phase(s)>]

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 
}
Folder Exclusion for Searching POM Files

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

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

Data/Telemetry

VS Code collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more. If you dont wish to send usage data to Microsoft, you can set the telemetry.enableTelemetry setting to false. Learn more in our FAQ.

Contributing

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Release Notes

Refer to CHANGELOG