{"id":67,"date":"2011-06-12T00:04:06","date_gmt":"2011-06-12T00:04:06","guid":{"rendered":"http:\/\/choudhury.com\/blog\/?p=67"},"modified":"2013-09-03T23:31:24","modified_gmt":"2013-09-03T23:31:24","slug":"using-sonar-in-your-java-maven-project","status":"publish","type":"post","link":"https:\/\/choudhury.com\/blog\/2011\/06\/12\/using-sonar-in-your-java-maven-project\/","title":{"rendered":"Using sonar in your Java Maven project"},"content":{"rendered":"<p>In my <a href=\"blog\/?p=51\">previous post<\/a>, I went through how to get sonar up and running, now this guide is a quick how to running sonar for your java maven project.<\/p>\n<p>So here is simple maven project <a href='https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/DistanceConverter.zip'>DistanceConverter<\/a> (hardly anything in this project, but enough to run sonar). If you look at the pom.xml file for this project, you will a sonar profile and some properties required for the sonar plugin. To run the sonar code metrics, you need to run<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">mvn clean install -Psonar sonar:sonar<\/div><\/div>\n<p><a href=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/sonar_command_line.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/sonar_command_line.jpg\" alt=\"\" title=\"sonar_command_line\" width=\"669\" height=\"119\" class=\"alignnone size-full wp-image-69\" srcset=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/sonar_command_line.jpg 669w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/sonar_command_line-300x53.jpg 300w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\" \/><\/a><\/p>\n<p>The &#8220;-Psonar&#8221; activates the sonar profile and &#8220;sonar:sonar&#8221; executes the sonar goal in the sonar plugin. If your running this for the first time, expect a long wait as quite a few dependencies may need to be downloaded.<\/p>\n<p>If all goes well, if you go back to the sonar webpage, you will see it&#8217;s been updated. You&#8217;ll see various metrics e.g. code coverage, the violations reported by checkstyle, pmd and findbugs.<\/p>\n<p><a href=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar.jpg\" alt=\"\" title=\"distance-converter_sonar\" width=\"927\" height=\"442\" class=\"alignnone size-full wp-image-70\" srcset=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar.jpg 927w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar-300x143.jpg 300w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar_home.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar_home.jpg\" alt=\"\" title=\"distance-converter_sonar_home\" width=\"1366\" height=\"728\" class=\"alignnone size-full wp-image-71\" srcset=\"https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar_home.jpg 1366w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar_home-300x159.jpg 300w, https:\/\/choudhury.com\/blog\/wp-content\/uploads\/2011\/06\/distance-converter_sonar_home-1024x545.jpg 1024w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post, I went through how to get sonar up and running, now this guide is a quick how to running sonar for your java maven project. So here is simple maven project DistanceConverter (hardly anything in this project, but enough to run sonar). If you look at the pom.xml file for this &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/choudhury.com\/blog\/2011\/06\/12\/using-sonar-in-your-java-maven-project\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using sonar in your Java Maven project&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6,3],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-code-quality","category-java"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":11,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":576,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/posts\/67\/revisions\/576"}],"wp:attachment":[{"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/choudhury.com\/blog\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}