How do you create persistant IntelliJ variables in run configurations in IntelliJ? - intellij-idea

I'm using IntelliJ 15.0.3.
Update: Have also tried updating to 2016.2.4, but the issue persists.
By creating variables under Settings -> Appearence and Behaviour -> Path Variables, these can be used in a run configuration with $VARIABLE_NAME$ to indicate for example what working directory or program arguments should be used by that run configuration. This is useful if for example the same directory is used in many parts of the run configuration but is changed from run to run.
However when using $VARIABLE_NAME$ in a run configuration it doesn't seem to be persistant. If I close my IntelliJ session the value of the variable will replace the variable reference. So for example if I have the variable:
FILENAME = somefile.csv
and in my run configuration I put "$FILENAME$" under program arguments, this will only be persistant for that session. When I close and reopen IntelliJ the program argument has been set to "somefile.csv" instead of retaining the reference "$FILENAME$".
How do I ensure that the variable reference is retained over several sessions?
Edit: Added screenshots showing before and after session reset.
Before a session reset I set my program arguments to reference my FILENAME variable. This also happens if I try to for example use the working directory field instead of the program arguments field.
After restarting IntelliJ the run configuration no longer references FILENAME.

I can't reproduce the issue in v2016.2.4 (i.e. I still get the replacement value after a restart). You may want to upgrade to v15.0.6 which is the latest v15.x available and see if that resolves the issue.
The values you set are simply stored in the file .IntelliJIdea\config\options\path.macros.xml (see Directories used by the IDE to store settings, caches, plugins and logs for info on where the configs directory is located.) So you can take a look at that file and see what's going on. Maybe try adding it outside IDEA (when IDEA is closed) and see if it holds (in the event a bug is causing the that file to not save properly after editing via the IDE.)

Related

Is there any other setting inside IntelliJ for Java VM system properties?

Because of constraints with our internal Maven repositories/proxies I need to use the following VM entry as a system property in order for my Cucumber/Selenium tests to work:
-Dwebdriver.chrome.driver=src/test/resources/drivers/windows/chromedriver.exe
However, the only place I could figure out where to place and have it picked up is in the Run Configurations, as follows:
However, due to the way I believe Cucumber/IntelliJ works, every time I debug a specific Cucumber test,
It always creates a brand new Run Configuration and I have to manually add this entry.
Is there another setting inside IntelliJ to set this property or a way for it to be part of the 'default' for when new configurations are automatically created?

Dynamic path creation

While developing transformations on local I set my transformation path to the target folders that are presented in Local PC and Once testing is completed on local I am moving our transformation to server repository to schedule it from server environments but every time I require to change the path set to the server folders. I believe it can be done by creating dynamic path or creating any variable but I am unable to resolve it. Is this option available in Pentaho? if Yes, Can you please help me for setting the dynamic path?
In This answer there is a link to a described solution, and in the answer i have a sample KTR that should help.
You can also use the pentaho properties file in different environments, meaning, you can utilize the same variable in both environments, say ${path}, but in each environment this has a different value.
kettle.properties can be found in your user folder .. C:\Users\YourUser.kettle
The standard way to handle environments in Kettleis with variables.
In the home directory there is a (hidden) folder named .kettle which contains every thing that should be local : your preferences, your shared connections, your cache, and, most of all, THE kettle.property file.
You can define variables in it, like a ${myPath}. To do this, use the menu Edit/Edit the Kettle.properties and add a variable named myPath and give it for value your prefered path, with an optional description.
Then, when you see a blue diamond with a $ on the right of a field in a step window (which means almost any field you'll need), you can press Crtl+Enter in the field and choose any variable defined in your kettle.properties. Alternatively, you may type or copy/paste ${your-variable-name} in the field.
Then, when launching spoon, it will not use the hard-coded path, but the content of the variable in the kettle.properties.
And nothing prevent you from having a different kettle.properties on your dev PC and on the prod server.
While we are there, three usefull tricks.
There is a predefined ${Internal.Job.Filename.Directory} variable contaning the path of the current transformation which by used for relative path. For example, ${Internal.Job.Filename.Directory}/../myDir/myFile.ext.
If you right-click anywhere on the screen, and go to the Properties/Parameters, you may also define your variable here.
You may also redefine these variables in the Run Option window that anoys you each time you rune a transformation (yes, there was a reason).
Finally, you can send these variables from job to jobs and transfos.

Update changes from Developement instance to Production instance in Odoo

I have 2 instances of Odoo v9 running in the same server (Ubuntu 14.04). I want to make changes (install modules, change source code or anything) in the developement instance and after confirming they are OK, move the changes to the Production Instance. Is there anyway of doing that without repeating the whole process of development?
Thank you.
As I can understand you do not want to stop the production instance.
If they are only XML files you might be able to get away by only updating the module from the frontend (Apps-> Your Module -> Update. Although if you have modified the __openerp__.py file inside your module you have to enter the debug mode and click Update Apps List first of all.
For changes in files that are inside the static folder of your module, you do not need to stop the server. Although, your users must click ctr + shift + R in order to flush their caches and bring to their browsers the new content.
For Python source code I am afraid that you have to stop both instances of the server so that the code can be correctly recompiled.
(See note 1 on this)
In the end you should stop and update everything because unexpected things might pop up at random times due to resources not been properly updated.
Note 1: The Python documentation about the compilation of Python modules above others mentions:
As an important speed-up of the start-up time for short programs that
use a lot of standard modules, if a file called spam.pyc exists in the
directory where spam.py is found, this is assumed to contain an
already-“byte-compiled” version of the module spam. The modification
time of the version of spam.py used to create spam.pyc is recorded in
spam.pyc, and the .pyc file is ignored if these don’t match.
So theoretically if you modify fileA.py in a module and a new fileA.pyc is generated the server will be able to interpret and use it. In any case I had an issue with two instances running where the py file was creating the field and the XML file was using it and the server reported that a filed had not been created for the XML view, that means that the server did pick up and parse the XML file but did not recompile the py.

Intellij 11.1.5 - Project specific path variable

I am using the Intellij 11.1.5. We are a large team, and have a pretty complex project setup. so we've made a template and when someone needs a new project set up, we just clone it and she is pretty much ready to go. One other thing i would like to automate is the creation of run configurations. One such configuration starts a custom bat file that requires a parameter representing a path that is user specific. I wanted to know if can store that value as a path variable specific to each project. Maybe somewhere in the .idea folder in my project. I know that Intellij stores it in its .IntelliJIdea11\config\options\path.macros.xml file, but is there a way to tweak that?
Any other idea that would allow me to locally store a parameter passed to the run config script would be usefull.
Thanks
I'm afraid you can't do it in IDEA, but you can use some environment variable directly in the .bat file instead of using the parameter (or rewrite the batch script to detect this value automatically, if possible). Instruct your users to define this environment variable.
IDEA Path variables are global and cannot be made project specific.

Property replacement in IntelliJ IML file

I recently migrated to IntelliJ 10. My .IML file has several properties such as $MODULE_DIR$ which set up the build environment. These are designed to be checked in so each user can configure his/her own local settings.
But everytime I checkin, IDEA replaces these some of these properties with the actual environment value, for example replacing every occurrence $MODULE_DIR$ in the iml file with my configured value "C:/Modules". This does not seem to happen for other properties, nor for other developers on the team using the same project. Am I missing some setting??
tia.
You should probably read about Path Variables in the Idea help.
I know that $MODULE_DIR$, $PROJECT_DIR$, ard $APPLICATION_HOME_DIR$ are used by Idea to determine where to find Module/Project/Idea stuff (jars etc). So I would guess not using these exact variable names will solve your problem.