{"id":9911,"date":"2015-10-08T11:26:00","date_gmt":"2015-10-08T11:26:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2015\/10\/08\/the-maven-build-task-now-simplifies-sonarqube-analysis\/"},"modified":"2022-08-02T01:16:28","modified_gmt":"2022-08-02T09:16:28","slug":"the-maven-build-task-now-simplifies-sonarqube-analysis","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/the-maven-build-task-now-simplifies-sonarqube-analysis\/","title":{"rendered":"The Maven build task now simplifies SonarQube analysis"},"content":{"rendered":"<p>Last month we released the MSBuild tasks for SonarQube analysis, which make it easy to analyze a .NET project. Today we are pleased to announce an updated <strong>Maven<\/strong> task that makes it easy for Java developers using Maven to trigger a SonarQube analysis in Visual Studio Online (VSO), and &#8211; when Update 1 is available soon &#8211; in Team Foundation Server (TFS) 2015.<\/p>\n<p>See also these related posts: <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/08\/24\/build-tasks-for-sonarqube-analysis.aspx\">Build Tasks for SonarQube Analysis<\/a>, <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/09\/29\/quickstart-analyzing-net-projects-with-sonarqube-msbuild-or-visual-studio-online-and-third-party-analyzers-stylecop-resharper.aspx\">Quickstart: Analyzing .NET projects with SonarQube, MSBuild or Visual Studio Online, and third-party analyzers (StyleCop, ReSharper)<\/a><\/p>\n<h3>Using the Maven task with SonarQube<\/h3>\n<p>The following screenshot shows a new build definition I created, to which I added a Maven task. You can see the new section named <strong>SonarQube Analysis<\/strong> in the parameters for this task.<\/p>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" title=\"clip_image001\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/10\/2335.clip_image001_thumb_724E9F6D.png\" alt=\"clip_image001\" width=\"703\" height=\"570\" border=\"0\" \/><\/p>\n<p>If I set the checkbox, the page updates to request a Service Endpoint, which specifies the URL of the SonarQube server and the credentials required to send analysis data to it.<\/p>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" title=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/10\/2465.clip_image002_thumb_042DC3EC.png\" alt=\"clip_image002\" width=\"704\" height=\"513\" border=\"0\" \/><\/p>\n<p>For information about creating a Service Endpoint for SonarQube, see <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/08\/24\/build-tasks-for-sonarqube-analysis.aspx\">this post<\/a>.<\/p>\n<p>If you use a version of SonarQube server earlier than 5.2, you must also enter the database connection string and the credentials for the database. If you are using SonarQube 5.2 or above, this isn\u2019t required.<\/p>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" title=\"clip_image003\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/10\/8780.clip_image003_thumb_688BC8A6.png\" alt=\"clip_image003\" width=\"610\" height=\"218\" border=\"0\" \/><\/p>\n<h3>Customizing the Maven build<\/h3>\n<p>When you configure an MSBuild SonarQube analysis task, you must provide the project name, the project key, and the version. You might be wondering why I don\u2019t provide these details for a Maven task. The reason is that they are automatically added to the default Maven <strong>POM<\/strong> file for the task. You can see in the following screenshot that this file is specified when you add a Maven task to a build definition.<\/p>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" title=\"clip_image004\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/10\/1307.clip_image004_thumb_734BB0AC.png\" alt=\"clip_image004\" width=\"681\" height=\"260\" border=\"0\" \/><\/p>\n<p>You can customize some features of the analysis by editing the <strong>POM **file passed to the task, or by passing parameters for the **Options<\/strong> setting. For example, you can pass values for the SQ-related options such as authentication. For more details, see <a href=\"http:\/\/docs.sonarqube.org\/display\/SONAR\/Analyzing+with+Maven#AnalyzingwithMaven-ConfiguringtheSonarQubeAnalysis\">Configuring the SonarQube Analysis<\/a> on the SonarQube website.<\/p>\n<p>Note that, if any of the Maven goals specified for the task should fail (for example, test failures), the SonarQube analysis will continue. This is different from the default behavior with MSBuild, where each step is decomposed.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this post, you\u2019ve seen how you can easily trigger a SonarQube analysis from the <strong>Maven<\/strong> task in Visual Studio Online and Team Foundation Server 2015 (from Update 1). You just need to define your SonarQube Service Endpoint once, and then reuse it for as many builds as you wish.<\/p>\n<p>We look forward to hearing from you, especially if you work with Java. Would you find value in having the same feature for <strong>Graddle<\/strong> or <strong>Ant<\/strong> tasks? Please send us your feedback by asking a question on <a href=\"http:\/\/stackoverflow.com\/questions\/tagged\/sonarqube\">StackOverflow<\/a>, or directly by reporting any bugs you find on the <a href=\"https:\/\/groups.google.com\/forum\/#!forum\/sonarqube\">SonarQube Google Group<\/a>. You can also submit suggestions (for example, for new features), on <a href=\"http:\/\/visualstudio.uservoice.com\/\">User Voice<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last month we released the MSBuild tasks for SonarQube analysis, which make it easy to analyze a .NET project. Today we are pleased to announce an updated Maven task that makes it easy for Java developers using Maven to trigger a SonarQube analysis in Visual Studio Online (VSO), and &#8211; when Update 1 is available [&hellip;]<\/p>\n","protected":false},"author":112,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[253,229,1,249],"tags":[],"class_list":["post-9911","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-devops-server","category-community","category-devops","category-open-source"],"acf":[],"blog_post_summary":"<p>Last month we released the MSBuild tasks for SonarQube analysis, which make it easy to analyze a .NET project. Today we are pleased to announce an updated Maven task that makes it easy for Java developers using Maven to trigger a SonarQube analysis in Visual Studio Online (VSO), and &#8211; when Update 1 is available [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/9911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/112"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=9911"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/9911\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=9911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=9911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=9911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}