I'm confused about the correct way to set a property for some unit tests via the command line when using Maven. There are a number of questions (e.g. Specifying Maven memory parameter without setting MAVEN_OPTS environment variable, Is there a way to pass jvm args via command line to maven?, How to set JVM parameters for Junit Unit Tests?) that touch on this subject but none have the answer I'm looking for.
I want to set the property java.util.logging.config.class
to some value but I don't want to set the MAVEN_OPTS
environment variable.
I can configure the surefire plugin in my pom file with the property:
<argLine>-Djava.util.logging.config.class=someClass</argLine>
so that it is set every time the test phase is run.
However, if I remove the setting from the pom file and add the following to the command line:
mvn package -DargLine="java.util.logging.config.class=someClass"
then the following error in the test phase is reported and the build fails:
Error: Could not find or load main class java.util.logging.config.class=someClass
If I run the following from the command line:
mvn package -Djava.util.logging.config.class=someClass
then the following error is reported at the beginning of the build but the build and tests are successful:
Logging configuration class "someClass" failed java.lang.ClassNotFoundException: someClass
I don't really understand the behaviour. Can someone enlighten me?
java.util.logging.config.class
property to control the logging output from a 3rd party library that my application depends on. – Archangel