11

This seems like a simple thing, but I can't find an answer in the existing questions:

How do you add a global argument to all your present and existing run or debug configurations? In my case, I need a VM argument, but I see that this could be useful for runline arguments as well.

Basically, every time I create a unit test I need to create a configuration (or run, which creates one), and then manually edit each one with the same VM argument. This seems silly for such a good tool.

orbfish
  • 7,381
  • 14
  • 58
  • 75

2 Answers2

11

This is not true. You can add the VM arguments to the JRE definition. This is exactly what it is for. I use it myself so that assertions are enabled and heap is 1024mb on every run, even future ones.

alice
  • 111
  • 1
  • 2
  • If it's only for the assertions, there is a checkbox in Preference -> JUnit -> [x] Add '-ea' to VM arguments when creating a new JUnit Launch Configuration. – leo Jan 26 '12 at 20:30
6

Ouch: 7-years bug, asking for running configuration template, precisely for that kind or reason.

This thread proposes an interesting workaround, based on duplicating a fake configuration based on string substitution:

  1. You can define variables in Window->Preferences->Run/Debug->String Substitution. For example you can define a projectName_log4j variable with the correct -Dlog4j.configuration=... value.
    In a run configuration you can use ${projectName_log4j} and you don't have to remember the real value.
  2. You can define a project-specific "empty" run configuration.
    Set the project and the arguments fields in this configuration but not the main class. If you have to create a new run configuration for this project select this one and use 'Duplicate' from its popup-menu to copy this configuration.
    You have to simply set the main class and the program arguments.

Also you can combine both solutions: use a variable and define an "empty" run configuration which use this variable. The great advantage in this case is when you begin to use a different log4j config file you have to change only the variable declaration.

Not ideal, but it may alleviate your process.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hrm both solutions are harder than what I do now! I love the end of the bug description where they say it's just too hard to add basic functionality. – orbfish Jun 29 '10 at 22:05
  • It's not a good answer for me, but wins by virtue of being the only one ;) – orbfish Jul 14 '10 at 19:30