Gradle Study (-sonar) runner

Source: Internet
Author: User
Preface


The previous article learned sonar, this article to explain sonar runner. The difference is that sonar runner is uploading the analyzed data to the database, and sonar is using various methods to organize the data in the database into different forms for the user. So sonar relies on sonar runner, and no data can be displayed.


Knowledge points


1.sonar version and compatibility


Gradle The version of Sonar runner that is used by default is 2.3, and this version supports Sonar version 3.0 and higher. But if you have to support the 3.0 before (or do not have this happen, brave to embrace the new things bad), it needs to be configured.


2.plugin Identification


Apply plugin: ' Sonar-runner '


3. How to perform


Gradle Sonarrunner

configuration of the 4.Sonar runner


Similar to Sonar's configuration, the configuration is not the same, the configuration is in the form of Key/value, and in Sonar is a special property name assignment method.


<pre name= "code" class= "java" >sonarrunner {
	sonarproperties {property
		"Sonar.host.url", "/HTTP// Localhost:9002/"Property
		" Sonar.jdbc.url "," Jdbc:mysql://localhost:3306/sonar "
		Sonar.jdbc.driverClassName "," Com.mysql.jdbc.Driver "Property
		" Sonar.jdbc.username "and" sonar "property
		" Sonar.jdbc.password "," Sonar "
	}
}

5. Version Configuration


In the 1th section, the Sonar runner default version is 2.3, and of course you can modify it by using the following statement.


Sonarrunner {
	toolversion = ' 2.3 '//Default
}

6. Multi-Project Construction


Here is similar to Sonar, I will directly post configuration, no longer elaborated.


There are both global and private 2 configurations, you can configure common properties for each subproject, or you can separate them to configure special properties for each subproject.

Set the character encoding for each item to UTF-8

subprojects {
Sonarrunner {
sonarproperties {property
"sonar.sourceencoding", "UTF-8"    
}
}
}


Set the language for Project1 to groovy


Project (":p Roject1") {
	Sonarrunner {
		sonarproperties {property
			"Sonar.language", "Grvy"
		}
	}
}


Set skip quality management for Project2.


Project (":p Roject2") {
	Sonarrunner {
		Skipproject = True
	}
}


7. Custom Sourcesets


Sonar also has these configurations, so a pen has been brought over. (Why are they all configured?)


Sonarrunner {
	sonarproperties {
		properties["sonar.sources"] + = SourceSets.custom.allSource.srcDirs
		properties["sonar.tests"] + = SourceSets.integTest.allSource.srcDirs
	}
}

8. More than just Java


Same as Sonar is the ability to analyze other languages. I've already talked about how to set up a language.


9. Controlling the execution of the sonar runner process


Sonar runner, like the test process, is a separate process. You can set the memory of the process and the system properties. To see what properties you can set, you can view the Javaforkoptions class in the API.


Sonarrunner {
	forkoptions {
		maxheapsize = ' 512m '
	}
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.