Setting properties through the Maven command line

I am confused about the correct way to set the property for some unit tests through the command line when using Maven. There are a number of issues (for example, Task memory parameter Maven without installing variable MAVEN_OPTS environment , is there a way to transfer jvm args from the command line in the maven? , How to set the JVM parameters for test Junit Unit? ), Which relate to this topic, but no one has the answer I'm looking for.

I want to set a property java.util.logging.config.classfor some value, but I do not want to set an environment variable MAVEN_OPTS.

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 installed every time the test phase is performed.

However, if I remove the parameter 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 is reported during the testing phase and the assembly fails:

Error: could not find or load the 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 at the beginning of the assembly the following error is reported, but the assembly and tests are successful:

Failed to create logging configuration class "someClass" java.lang.ClassNotFoundException: someClass

I do not really understand the behavior. Can someone enlighten me?

+4
source share
2 answers

Yes you must have

mvn package -DargLine="-Djava.util.logging.config.class=someClass"

-D argLine.

. argLine maven-surefire-plugin argLine. , -DargLine. -Djava.util.logging.config.class=someClass. , , POM

<argLine>-Djava.util.logging.config.class=someClass</argLine>

,

mvn package -Djava.util.logging.config.class=someClass

argLine. .

+7

, , , src/test/resources/myTestConfig.xml. Test-ng. , / , ().

Maven - Maven, Java . , . , "-----------" Gradle .

0

Source: https://habr.com/ru/post/1623720/


All Articles