Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does intellij support variables in launch configurations?

In eclipse I can include things like the following in the vm args or program args in a launch configuration:

-Dsome.system.property=${string.prompt:explanation:default} 

When you run this, you get a string prompt in a little pop up showing the explanation text and ready with the default, and it allows you to inject properties easily and per run of the application.

I use it a lot for things like specifying whether I want a dev or test instance of the application. You can also do ${env_var:ENVIRONMENT_VARIABLE_NAME} to pick up machine specific config, useful for sharing these launch configs between developers.

Is this, or anything similar, supported in IntelliJ Idea? Are there plugins that provide this functionality?

like image 578
Joe Kearney Avatar asked Oct 06 '11 14:10

Joe Kearney


People also ask

How do I set variables in IntelliJ?

Add environment variablesFrom the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog, select a configuration you want to add the environment variables to.

What are configurations in IntelliJ?

Run/debug configurations IntelliJ IDEA uses run/debug configurations to run, debug, and test your code. Each configuration is a named set of startup properties that define what to execute and what parameters and environment should be used.

How do I use environment variables in IntelliJ?

Click edit configurations on the dropdown box for your runtime configurations. Select the runtime you want to add environment variables to. Click environment variables folder icon to pull up the environment variables screen. From here you can add as many environment variables as you want.


2 Answers

There is no direct equivalent in IntelliJ. To make it easier to share configurations or other project settings between multiple developers, you can use path variables (Settings | Path Variables, see the Help for more information). To customize the options before launching the run configuration, enable the "Before launch | Show Settings" option in the run configuration settings.

like image 175
yole Avatar answered Oct 06 '22 04:10

yole


In the 2016 version of IntelliJ at least, you can access environment variables using the brace-enclosed environment variable syntax:

${HOME}/path/to/file 

is expanded properly, but the alternative syntax

$HOME/path/to/file 

does not work.

Version Info:

IntelliJ IDEA 2016.2.2 Build #IC-162.1628.40, built on August 16, 2016 JRE: 1.8.0_76-release-b216 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o 
like image 37
Joel Cornett Avatar answered Oct 06 '22 04:10

Joel Cornett