Search code examples
eclipselauncher

Set Environment Variable At Eclipse workspace level for all launchers?


Can I set a workspace wide setting to add an environment variable to all future launchers created in the workspace?

Use Case

  • Our unit tests require an environment variable to guide the test to certain resources.
  • the variable varies with each version of our product

Options - modify each junit launcher with the environment variable - create start up script that sets variable and launches eclipse - set globally

Ideally, I'd like to provide a way for users to set it once per workspace.

Does eclipse have a place to set an environment variable for all launchers?

Thanks

Peter


Solution

  • Only option which I can think of is similar to yours where you can create multiple shell scripts(linux) or batch files(windows) and set it up there. for ex -

    I am giving examples for windows environment and same can be done for Linux as well -

    for windows-

    eclipse.exe -DvariableName1=value1 -DvariableName2=value2
    

    As you want to pass different variables to different workspaces, you can also pass location of your workspace as part of arguments.

    eclipse.exe -data <your_workspace_location> -DvariableName1=value1 -DvariableName2=value2
    

    You can create multiple shortcuts of eclipse.exe in windows and place them on Desktop (for quick access) if needed. Each shortcut may point to a similar variant of above command with different workspace and different variables.

    Hope this helps. Happy coding :)