Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Differences between Maven parameters (maven.test.skip and maven.test.skip.exec)

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Part 1: the reason is the difference in our parameters:

Case 1: mvn clean install-Dmaven.test.skip=true

In this case, the test class file is not compiled or executed

Situation 2:mvn clean install-Dmaven.test.skip.exec=true

In this case, the test class file is compiled into a bytecode file, but the bytecode file is not executed

Since no one has written unit tests before, there is no problem. Now there are unit tests coming in, so here comes the problem.

-demarcation line-

In the first case (that is, in the case of an error), we maven3 (based on JDK 1.6) don't compile these, so run all the way to build successful, no problem.

And then. Execute sonar, because our Jenkins version is very low, can only accept sonar2.0, and sonar2.0 (based on JDK 1.5) in the execution of the life cycle of maven-compiler-plugin:2.3.2:testCompile, he found that he did not compile those classes, so he used jdk 1.5 to compile test classes, and our source code is 1.6 source code, he does not have the ability to compile these, so the compilation failed.

In the second case, we maven3 (based on JDK 1.6) compiled these classes, so we generated bytecode version 1.6 in the target directory, but did not run them. Everything went well, and then when it came to sonar, compiler-plugin:2.3.2:testCompile was also called (the key came), and he compared the timestamps and found that he already had the latest bytecode (just maven3 compiled with JDK 1.6), so he skipped the testCompile phase, so no problem.

Part 2: solution

One way is to change the parameter to Dmaven.test.skip.exec, but this is not the best way

The best way to do this is to set the source version and target version of sonar to 1.6instead of the default 1.5,

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report