Path Variables are IDE level, where are project level variables?
Hello,
I have multiple run configurations that are used for various projects. These projects can have unique module names. Using Path Variables to define a value for a module name will only work for one project. When another window is opened with a second project with different module names, the run configurations are incorrect due to the Path Variables having values for the first project.
For example,
Project 1: Path Variable name=MODULE.PROCESSOR value=mini-processor
Project 2: Path Variable name=MODULE.PROCESSOR value=large-processor
Run Configuration (line with meaning): <module name="$PROJECT_NAME$.$MODULE.PROCESSOR$" />
If the value of MODULE.PROCESSOR is set for Project 1 and Project 2 is open in another window, Project 2 run configuration will look for module project.mini-processor, which doesn't exist in Project 2, so the run configuration is invalid.
How can I set project specific variables that the run configurations can resolve?
Please sign in to leave a comment.
Hello T Heidenthal. Could you please share a screenshot of one of the Run configurations you use? I want to reproduce the issue on my side.
Also, please, specify which IDE version you use.
An example run configuration with some values modified:
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="GT-ISE" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="$GTIHOME$\v2024\GTsuite\jre\11.0.19_7\$GTIARCH$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<env name="PATH" value="$GTIHOME$\bin\;$GTIHOME$\bin\$GTIARCH$;$GTIHOME$\v2024\GTsuite\bin\$GTIARCH$;" />
</envs>
<option name="MAIN_CLASS_NAME" value="com.gtisoft.framework.ThisIsFake" />
<module name="$PROJECT_NAME$.GUI.$MODULE.GTSUITE$" />
<shortenClasspath name="ARGS_FILE" />
<option name="VM_PARAMETERS" value="-Djava.library.path=$GTIHOME$\bin\$GTIARCH$;$GTIHOME$\v2024\GTsuite\bin\$GTIARCH$;" />
<RunnerSettings RunnerId="Cover" />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="JProfiler" />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Cover" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
IntelliJ IDEA 2023.1.4 (Ultimate Edition)
Build #IU-231.9225.16, built on July 12, 2023
Regrettably, in the Run configuration you shared, I don't see the variables like $PROJECT_NAME$. Did you share the correct one?
Olga Mulina, the variable $PROJECT_NAME$ is in the 8th line of the run configuration I provided
All variables surrounded by $'s are set in my Path Variables, though I would like to have a project level location to set them
To be more precise, variables surrounded by $'s, except $PROJECT_NAME$, are set in my Path Variables
Sorry, when trying to use this Run configuration with the test project, the module element is rewritten. Could you please share a screenshot instead of the
.xml
content? You can do it privately via the JetBrains Uploads service and write here the ID you receive.Olga Mulina, the png is in Upload id: 2023_07_14_JYriUH6NUzhfo7HEnf9bL5 (file: SampleRunConfiguration.PNG). Please be aware that you could have 1. used the post above as though it were an image, 2. created an image from the post above 3. and/or made a copy of the text run configuration to have a clean copy available.
Olga Mulina, I didn't mean for my last message to sound harshly. I am accustomed to teaching others alternatives when they come to me and the habit came out with you. I hope you understand, I was only trying to help, not chiding.
T Heidenthal, thank you for sharing the screenshot, and sorry, looks like I didn't explain properly what exactly I need.
I didn't mean the
.xml
content of the Run configuration file; I meant the screenshot of the IDE UI, theRun | Edit Configurations...
window so I can understand which fields contain which variables. As I mentioned before, when importing the Run configuration.xml
you shared, some fields were overwritten; that's why I need to see how exactly it looks on your side.The sample of the window with a very simple Run configuration:
Olga Mulina, thanks for the clarification. Please see Upload id: 2023_07_17_GysRzYULDp4c7MfmtjuMJf (file: image.png)
T Heidenthal, thank you for sharing the screenshot. Now I understand your case; sorry that it took so long.
Regrettably, there is no such option to specify the project-level path variable for now. Please, consider upvoting this issue in YouTrack containing a similar feature request, and, probably, this one could be helpful for you, too; the last one is planned to be implemented in the 2023.3 release for now.
Hi Olga Mulina, thanks for the references. I believe the second request is closest. I have tried the EnvFile plugin and the .env files support plugin with no luck. Hopefully, the 2023.3 release will work for me.