Gradle Study (-sonar) runner

Source: Internet
Author: User
Preface


The last article to learn sonar, this article to explain sonar runner. The difference is that sonar runner upload the analyzed data to the database, while sonar uses 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


The sonar runner version used by Gradle is 2.3, which supports version 3.0 and higher for sonar. But if you have to support 3.0 (or do not have such a thing happen, brave embrace new things bad), it needs to configure themselves.


2.plugin logo


Apply plugin: ' Sonar-runner '


3. How to implement


Gradle Sonarrunner

configuration of 4.Sonar runner


Similar to the sonar configuration items, but the configuration is not the same, where the configuration is in the form of Key/value, and in the sonar is a special attribute name assigned to the way.


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

5. Version Configuration


In the 1th section of the Sonar runner the default version is 2.3, of course you can modify, through the following statement to modify.


Sonarrunner {
	toolversion = ' 2.3 '//Default
}

6. Multi-Project Construction


Here also and sonar similar, I directly paste configuration, no longer elaborated.


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

Set character encoding to UTF-8 for each item

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


Set the language for Project1 to groovy


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


Skip Quality Management for Project2 settings.


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


7. Custom Sourcesets


Sonar also has these configurations, so a stroke. (Why is it 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, you can analyze other languages. I've already talked about how to set up the language.


9. Control the execution of sonar runner process


Sonar runner, like the test process, is a separate process. You can set the memory of the process as well as 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.