IntelliJ IDEA 2024.1 Help

Run/Debug Configuration: Maven

You can run Maven goals using run configuration. The default options listed in such configuration are enough to run your task. If you want, you can also create an advanced configuration using additional options or adding more goals and arguments.

Create a run/debug Maven configuration

  1. From the main menu, select Add Configuration. Alternatively, right-click any task in the Maven tool window and select Modify Run Configuration.

    Maven run configuration
  2. Specify a name of your configuration in the Name field to quickly identify it when editing or running the configuration, for example, from the Run popup Alt+Shift+F10 or the Maven tool window.

  3. Specify where you want your configuration to run on. The default Local Machine option will run your configuration locally on your computer.

    You can change the location of your run execution. For example, use SSH or Docker to run your target.

    You can also run your target on WSL. If you need to configure a new target or change the existing configuration, click Manage targets and in the Run Targets dialog, add your changes. For more information, refer to Run targets.

  4. If you need, specify Store as project file that saves the file with the run configuration settings, so you can share it with other team members. The default location is .idea/runConfigurations. However, if you do not want to share the .idea directory, you can save the configuration to any other directory within the project.

    To change the location, select this option and click the Manage File Location icon and in the dialog that opens, add the new location.

  5. Specify which Maven version should be used to execute the run configuration.

    Use this list to select a bundled Maven version that is available (for Maven2, version 2.2.1 and for Maven3, version 3.1), the result of resolved system variables such as MAVEN_HOME or MAVEN2_HOME, or the Maven wrapper. You can also specify your own Maven version that is installed on your machine. You can click the Browse button  and select the necessary directory in the dialog that opens.

  6. You must specify a valid cycle phase or a goal in the Run field to have an executable run configuration. Alternatively, if you are creating a run configuration from the Maven tool window, the goal you have selected will be displayed in this field. However, you can specify additional external goals and arguments for your run configuration. Use spaces to separate one goal from another. If you want to see the available list of Maven goals and arguments, click the Insert Tasks and Arguments icon in the field.

  7. Specify the location of your Maven project.

    You can either enter it manually or click the Browse button and point to the desired location in the dialog that opens. However, if you are creating a run configuration from the Maven tool window, IntelliJ IDEA will display the name of your project automatically.

    If you need, you can specify a path to the build script file instead of the project path. This might be helpful if you have a custom build script to which you want to refer.

  8. Specify profiles if you have them declared in your project. For more information about Maven profiles, see Maven profiles.

  9. If you need, specify the environment variables that you want to use in you project.

  10. The following default options are enabled, but you can click Modify options to add new options or remove some of the default ones in Add Run Options:

    • Open run/debug tool window when started - automatically opens the Run/Debug tool window when the configuration is executed and several debugger options

    • Maven Options - lists the default Maven options inherited from the Maven settings. If you want to change them, unselect the Inherit from settings option or click Modify to add new Maven options.

    • Java Options - lists the default Java options inherited from the Maven settings. If you want to change them, unselect the Inherit from settings option or click Modify to add new Maven options.

Modify run options

Click Modify options to add more run options or remove some of the default ones described above.

Item

Description

Allow multiple instances

Select this option to allow running multiple instances of this run configuration in parallel. By default, it is disabled, and when you start this configuration while another instance is still running, IntelliJ IDEA suggests stopping the running instance and starting another one. This is helpful when a run configuration consumes a lot of resources and there is no good reason to run multiple instances.

Item

Description

VM options

Specify the options to be passed to the Java virtual machine when launching the application, for example, -mx, -verbose, and so on.

When specifying JVM options, follow these rules:

  • Use spaces to separate individual options.

  • If the value of an option includes spaces, enclose either the value or the actual spaces with double quotes.

  • If an option includes double quotes as part of the value, escape the double quotes using backslashes.

  • You can pass environment variable values to custom Java properties.

-Xmx1024m -Dspaces="some arg" -Dmy.prop=\"quoted_value\" -Dfoo=${MY_ENV_VAR}

Use code completion in this field: start typing the name of a flag, and the IDE suggests a list of available command line options. This works for -XX: and -X options and some standard options that are not configured by IntelliJ IDEA automatically, like -ea, but not for -cp or –release.

The -classpath option specified in this field overrides the classpath of the module.

JRE

Specify a version of Java to use in your run configuration.

Item

Description

Profiles

Specify the profiles to be used separated with space.

User settings

Specify the file that contains user-specific configuration for Maven in the text field. If you need to specify another file, check the Override option, click the ellipsis button and select the desired file in the Select Maven Settings File dialog.

Local repository

By default, the field shows the path to the local directory under the user home that stores the downloads and contains the temporary build artifacts that you have not yet released. If you need to specify another directory, check the Override option, click the ellipsis button and select the desired path in the Select Maven Local Repository dialog.

Thread Count

Use this field to set the -T option for parallel builds. This option is available for Maven 3 and later versions.

For more information, refer to parallel builds in Maven 3 feature.

Skip Tests

If this option is checked, the tests will be skipped when running or debugging the Maven project.

Use plugin registry

Check this option to enable referring to the Maven Plugin Registry.

This option corresponds to the --no-plugin-registry command-line option.

Print exception stacktraces

If this option is checked, exception stack traces are generated.

This option corresponds to the --errors command-line option.

Always update snapshots

Select this checkbox to always update snapshot dependencies.

Resolve Workspace artifacts

We recommend that you use this checkbox if you have dependent modules in your project.

By default, this checkbox is not selected. In this case, classes of dependent modules are searched in .jar files in a Maven local repository. If you select this checkbox, the classes of the dependent modules will be searched in the module compilation output. In this case, each time you make changes to the dependent module, you don't need to deploy them into a local repository.

Executed goals recursively

If this option is cleared, the build does not recur into the nested projects.

Clearing this option equals to --non-recursive command-line option.

Work offline

f this option is checked, Maven works in the offline mode and uses only those resources that are available locally.

This option corresponds to the --offline command-line option.

Checksum policy

Select the desired level of checksum matching while downloading artifacts. You can opt to fail downloading when checksums do not match --strict-checksums, or issue a warning --lax-checksums.

Output level

Select the desired level of the output log, which allows plugins to create messages at levels of debug, info, warn, and error, or disable output log.

Multiproject build fail policy

Specify how to treat a failure in a multiproject build. You can choose to:

  • Fail the build at the very first failure, which corresponds to the command line option --fail-fast.

  • Fail the build at the end, which corresponds to the command line option --fail-at-end.

  • Ignore failures, which corresponds to the command line option --fail-never.

You can select which log files that are generated while running or debugging should be displayed in the console, that is, on the dedicated tabs of the Run or Debug tool window. You can also select an option that saves the console output to a file or show the console output when a message is printed to stdout or stderr.

You can select additional options to add before the run configuration is executed. For example, you can add a Maven goal or an argument that you want to execute before you run your configuration.

Click Add before launch task and in the list that opens, select Run Maven Goal, and in the dialog that opens configure your task.

Last modified: 28 June 2024