I have 2 profiles that may or may not be used together to run a group of tests. They each require different vmargs to run, but if they are used together it's ok to have them appended to each other.
What I'm looking for is a way to set argLine to be the concatenation of its current value plus what I set.
I was hoping it would as simple as
<argLine>${argLine} -DnewVMArg</argLine>
Is there something similar I can do to make this happen?
I made an attempt at fixing it which results in maven getting stuck in a recursive cycle. It's documented below.
My Most recent attempt was to define a property <my.argLines></my.argLines>
globally, and then to modify this within the profiles.
In each profile, in a properties block, I set overrode the property to:
<my.argLines>${my.argLines} -myUniqueToProfileArgs</my.argLines>
In each surefire configuration for the profiles, I set <argLines>
to be:
<argLines>${my.argLines}</argLines>
This logically fits for me, but the way it evalutes is apparently not going to mesh.
If you are dealing only with -D system properties, you could use <systemPropertyVariables> instead of <argLine> and then they will be combined naturally. One of the profiles could have:
and the second profile:
Also, it's worth mentioning that this approach allows you to override in child poms individual properties from parent poms.
Eclipse: Window -> Preferences -> TestNG -> Maven Uncheck the 'argLine'.
Define your default arguments
-DnewVMArg
insideargLine
like below:Define profiles arguments
Additional plugin configuration is not required
I have tested this configuration, my results below.
Default
Result
Goal with profile
Result
As you found out, a property cannot reference itself.
You need to define different properties for each profile and finally concatenate them in your surefire call:
Also note the not-empty default value. Maven has some surprising way of handling those. In order to be on the safe side, use harmless non-blank default values (see “Null” versus “empty” arguments in Maven)