¹Ù·½Îĵµ http://docs.sonarqube.org/display/SONAR/Analyzing+with+Maven ˵µ÷ÓÃÉùÄɵÄÕýÈ··½·¨ÊÇ:
mvn clean install -DskipTests=truemvn ÉùÄÉ:ÉùÄÉ
µ«Ã»ÓÐ˵Ã÷ÔÒò.ÉùÄÉÈçºÎ¹¤×÷?ËüÐèÒª±àÒëÀàÂð?ÄÇôΪʲô²»Ö±½Ómvn clean compile
ÄØ?»¹ÊÇÐèÒªÒ»¸öjarÎļþ?ÄÇôΪʲô²»Ö±½Ómvn clean package
ÄØ?ÉùÄɲå¼þµ½µ×ÊÇ×öʲôµÄ?
À´×ÔSonarSource ÍŶӳÉÔ±µÄ½âÊÍ::p><¿éÒýÓÃ>
ÔÚ¶àÄ£¿é¹¹½¨ÖУ¬¾ÛºÏÆ÷²å¼þÎÞ·¨½âÎöÀ´×ÔÄ¿±êÎļþ¼ÐµÄÒÀÀµÏî.ËùÒÔÄãÓÐÁ½¸öÑ¡Ôñ:
mvn clean install
&&mvn sonar:sonar
×÷ΪÁ½¸ö¶ÀÁ¢µÄ½ø³Ìmvn clean package sonar:sonar
×÷Ϊµ¥¸ö·´Ó¦Æ÷ÎÒÒ²ºÜ¾ªÑÈ£¬ËùÒÔÎÒ·¢ÁËÒ»¸ö tweet ²¢ÊÕµ½ÁËÒÔÏ À´×Ô Maven ¹Ù·½Õ˺ŵĻشð:
<¿éÒýÓÃ>Èç¹û²å¼þµÄÉè¼ÆÄ¿µÄ²»ÊÇʹÓà target/classes Îļþ¼Ð×÷ΪÌæ´ú£¬ÄÇôÊǵģ¬ÄúÐèÒª°²×°²ÅÄÜÔÚÔËÐÐʱ»ñÈ¡ jar *ÔÚ²»Í¬µÄ»á»° *ÖÐ.Èç¹ûËûÃÇÇ¿ÆÈÄúʹÓà install ûÓÐ foo ÔÒò£¬ÇëÏò²å¼þ×÷ÕßͶËß [ed - @connolly_s]
official documentation http://docs.sonarqube.org/display/SONAR/Analyzing+with+Maven says that the proper way of invoking sonar is:
mvn clean install -DskipTests=true
mvn sonar:sonar
but doesn't say why. how does sonar work? does it need compiled classes? so why not just mvn clean compile
? or does it need a jar file? so why not just mvn clean package
? what exactly does sonar plugin?
Explanation from a SonarSource team member:
In a multi-module build an aggregator plugin can't resolve dependencies from target folder. So you have two options:
mvn clean install
&&mvn sonar:sonar
as two separate processesmvn clean package sonar:sonar
as a single reactor
I was surprised too, so I made a tweet an received the following answer from the official Maven account:
If the plugin is not designed to use the target/classes folder as a substitute, then yes you would need to have installed to get the jar when running *in a different session*. Complain to the plugin author if they force you to use install without foo reason [ed - @connolly_s]
Õâƪ¹ØÓÚΪʲô sonar:sonar ֮ǰÐèÒª mvn install ?µÄÎÄÕ¾ͽéÉܵ½ÕâÁË£¬Ï£ÍûÎÒÃÇÍƼöµÄ´ð°¸¶Ô´ó¼ÒÓÐËù°ïÖú£¬Ò²Ï£Íû´ó¼Ò¶à¶àÖ§³Ö¸ú°æÍø£¡