So, I am having a project which I am required to update an environmental variable of the testing execution due to external reasons. In parallel, I am executing the tests in different ways (unittesting, performance, specific module...), so that I need to change the environmental variables of all these configurations everytime I am externally requesting, creating some administrative work.
Is there any way to set up a common environmental variable for different test configurations?
Looking to eclipse documentation I do not see any way to perform it, so I am really looking for a hack (maybe modifying configuration file programmatically)
You can define your own Variables in Preferences > Run/Debug > String substitution. Then you can use those variables in "Environment" settings of your Run/Debug configuration.
Related
I am configuring an SPI provider (specifically, for the x509cert-lookup SPI) in Keycloak, deployed on bare metal. The provider config documentation tells me to use the build command for selecting the provider and the start command to pass options to that provider.
However, from the docs about general configuration I conclude that all options can also be passed in a keycloak.conf file, and the build step is merely an optimization.
If I do not care much about optimizing startup time: Can the build step be eliminated altogether, putting all options into the config file for simplicity? Or is there anything so special about the providers that they must be set in the build step?
(Background: I am running a non-containerized bare metal setup where Keycloak is managed by systemd, and we've had situations where provider configuration was somehow lost between restarts.)
You're right when you mention that the extra build step prior to the start command is purely optimization.In fact, when you call start, it performs a build!
When running inside a containerized environment, the optimization step is a nice feature. Here's the configs that can be set in the extra build step (if desired)
https://www.keycloak.org/server/all-config?f=build
If it's not the case, like you, and you run on bare metal, then the additional build doesn't provide you much.
Here's the most useful link to get you started:
https://www.keycloak.org/server/configuration
Beware that there is an order of precedence when setting the config such as:
command-line parameters
environment variables
user-created .conf file
keycloak.conf file located in the conf directory.
command-line parameters take precedence over environment (and so on).
Hope this helps!
Using PyDev with Eclipse Juno, I need to set some environment variables to debug every single of the many scripts in my project. I have found how to set them for a given script but it would be totally impractical to do it for all of them. The only solution I have found consists in adding those variable to the Python interpreter configuration in the Preferences. But then it will be used by all projects, which I don't want.
I thought of creating a script setting those environment variables and then launching Python, and then add it as a new Python interpreter but PyDev does not accept two interpreters with the same actual exe (I guess it checks sys.executable).
The recommended approach is really setting it at the Python interpreter level.
You can use virtualenv ( http://pypi.python.org/pypi/virtualenv ) to create a copy of your interpreter in a different path.
Just to elaborate that #FabioZadrozny's answer meets the need of the OP...
In case it hasn't occurred to you, do this:
From the menu "Window->Preference"
Navigate to "PyDev->Interpreters->Python Interpreter"
Create a new interpreter instance with "New..." button
Name it something like "python-MyProj", but use the same executable you are already using
Now in the "Environment" tab for that interpreter, set up the needed environment variable
Now, see the PyDev project to use THAT interpreter:
Right-click the project to get "Properties..."
Navigate to "PyDev-Interpreter/Grammar"
Select the newly created interpreter instance by name
Now run any python file within the project, and it should "see" the configured environment variable.
By this mechanism, you do have a "project specific setting"... which, again, for the reasons #FabioZadrozny pointed out, need to be set at the interpreter level.
I installed Eclipse Juno recently and after it I installed the p4Eclipse 4.2 plugin from this repository:
http://www.perforce.com/downloads/http/p4-eclipse/install/4.2
Then I tried to create a new perforce connection.I entered the name of server and username and password. But I got an error message when clicking on next:
com.perforce.p4java.exception.ConfigException: java.io.FileNotFoundException: \p4tickets.txt (Access is denied)
Reading the P4Eclipse help I understood that because I didn't define the user environment variable P4TICKETS the P4Eclipse tried to define it by itself. On the help has mentioned that if the value is not explicitly is set it will be defined for windows as %USERPROFILE%\p4tickets.txt
and for all other platforms as
$HOME/.p4tickets
It seems that P4Eclipse has configured for other platforms and therefore it tried to find the file somewhere which it was not allowed. When I defined the User Environment variable P4TICKETS with the value %USERPROFILE%\p4tickets.txt it worked. The problem is that we have many clients and I don't want to define an environment variable for all of them. So I wonder if there is a set to configure P4Eclipse for Windows platform or define the P4TICKETS within eclipse and not with an environment variable!
Yes, I think you can go to the advanced configuration for the plugin and set P4TICKETS. In the release notes they describe this method for setting P4HOST:
470897 (Bug #042451)
Support for P4HOST variable. To set P4HOST variable,
either set the environment variable P4HOST (For example,
export P4HOST=123.456.789.0) or in the the preference page,
Preference>Team>Perforce>Advanced, set P4HOST properties,
(For example, name: P4HOST value: 123.456.789.0). Then
restart Eclipse to make it affect.
I'm not 100% sure that will work but you can give it a try.
Setting up environment variables for hundreds of tests get old very quick. Is there a way to declare an environmental variable globally in Eclipse?
Can this be done in Eclipse? Can this be done outside of Eclipse?
It seems that the only way to do it is to enable "Run all tests in the selected project .." and set Environment variables once there.
If you want to run a single test, and that test requires an environment variable set, it looks like you need to set that environment variable as part of that tests's settings.
In windows use the "start" command to spawn eclipse from command line with defined variables (linux has similar functionality)
Make file starteclipse.cmd
================================
SET VAR1=SOMEVALUE
SET VAR2=SOMEVALUE
start d:\eclipse\eclipse.exe
================================
From command line go to the dir with starteclipse.cmd file and run it.
This will spawn eclipse with proper environment settings.
I also find it frustrating having to set env vars one by one.
If you own the code and have a chance to change it, you'd be better off using a System property instead, which can be passed as VMArgs -Dprop=val.
You can set VM args in a global level - Preferences | Java | Installed JREs, and Plugin Development | Target platform.
Even if you can't change the code, most well civilised java libs support properties as well if not more than env vars- so it's worth double checking.
(of course it's not an option for external processes).
I am trying to create an eclipse runtime tool to diff 2 files. For my specific instance the files have the same name but are comparing versions.
I created a runtime external tool configuration using p4merge using these arguments:
gen\${string_prompt:File Name} gen2\${string_prompt:File Name}
What I really want is 1 dialog box where I can use the variable 2ce.
Anyone know if this is possible directly in eclipse other than writing a batch or shell script?
In the "External Tools Configurations" window, on the "Environment" tab, create a new environment variable. Set it's name to tmp_StrInput or something similar and it's value to "${string_prompt:Hint:DefaultText}".
Then, in your arguments (or anywhere else) on the "Main" tab, use ${env_var:tmp_StrInput} every time you want to insert the result from the string_prompt dialog.
The prompt appears and sets the environmental variable before the tool is run, the only negative side-effect is that you have created an extra environment variable. It does seem a bit like a work around but it works well!