Is it possible to set environmental variables in a build profile as opposed to setting them in the command line?
For instance, I want to enable the debugger when I’m using my test environment (-Denv=test).
I want maven to do this:
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
This way, I can quickly attach a debugger without having to type the same repeated line over and over.
I don’t believe the helps me in this case:
<plugin>
...
<!-- Automatically enable the debugger when running Jetty -->
<argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n</argLine>
</configuration>
...
</plugin>
Walter
In recent versions of Maven you can activate the debugger by running mvnDebug rather than mvn, the mvnDebug bat/sh file sets MVN__DEBUG_OPTS and passes them to the java.exe. The values passed are:
If that isn’t sufficient, this may work (note I’ve not yet tested this, I’ll update once I have). Maven reads properties prefixed with “env.” from the environment, you may be able to set environment variables by prefixing with the same. i.e.:
Update: The surefire plugin allows you to specify system properties to be used during test execution. The configuration is as follows:
If none of those work for you, it is possible to write a small plugin configured in your profile that binds to the initialize phase and sets your variables. The plugin would have configuration like this:
during execution the plugin would set each passed property using System.setProperty(). If the first two aren’t suitable or don’t work this should address your issue.