eclipse intellij 是否支持启动配置中的变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7675705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:06:47  来源:igfitidea点击:

does intellij support variables in launch configurations?

javaeclipseconfigurationintellij-ideaenvironment-variables

提问by Joe Kearney

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

在 Eclipse 中,我可以在启动配置中的 vm args 或 program args 中包含以下内容:

-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.

我经常使用它来指定我想要应用程序的开发实例还是测试实例。您还${env_var:ENVIRONMENT_VARIABLE_NAME}可以选择特定于机器的配置,这对于在开发人员之间共享这些启动配置很有用。

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

IntelliJ Idea 是否支持此功能或任何类似功能?是否有提供此功能的插件?

采纳答案by yole

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.

IntelliJ 中没有直接的等价物。为了更轻松地在多个开发人员之间共享配置或其他项目设置,您可以使用路径变量(设置 | 路径变量,请参阅帮助以获取更多信息)。要在启动运行配置之前自定义选项,请启用运行配置设置中的“启动前 | 显示设置”选项。

回答by Joel Cornett

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

至少在 IntelliJ 2016 版本中,您可以使用大括号括起来的环境变量语法访问环境变量:

${HOME}/path/to/file

is expanded properly, but the alternative syntax

被正确扩展,但替代语法

$HOME/path/to/file

does notwork.

没有工作。

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

回答by Leon

Just did this for a machine specific variable in IntelliJ 11.0.2. Set up a path variable i.e. MY_VARIABLE. Use in your run config as you would in eclipse : ${MY_VARIABLE}

只是为 IntelliJ 11.0.2 中的机器特定变量执行此操作。设置一个路径变量,即 MY_VARIABLE。像在 eclipse 中一样在运行配置中使用:${MY_VARIABLE}

回答by fxp

Maybe thisis what you want. it's work on mine project.

也许就是你想要的。这是我的项目的工作。

e.g.

例如

launchctl setenv ANDROID_HOME= /usr/myuser/android_sdk/
and restart intellij

回答by leedm777

I've never seen anything like that in all my years using IntelliJ IDEA.

在我使用 IntelliJ IDEA 的这些年里,我从未见过这样的事情。

You can open a feature request in their issue tracker, and maybe they'll implement it in a future release.

您可以在他们的问题跟踪器中打开一个功能请求,也许他们会在未来的版本中实现它。