将声纳配置属性外部化到用户主目录中的gradle.properties文件

use*_*842 4 gradle sonarqube

我想将声纳配置属性从build.gradle文件外部化到gradle.properties文件.

例如,应用插件:'sonar-runner'

sonarRunner

sonarProperties

                property "sonar.java.coveragePlugin", "jacoco" 
                property "sonar.host.url", "http://10.42.58.229:9000/"
                property "sonar.jdbc.url", "jdbc:mysql://10.42.58.229:3306/sonar"
                property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
Run Code Online (Sandbox Code Playgroud)

我想从gradle.properties文件中传递属性值,该文件存在于用户主目录中.

Jul*_*eam 7

这是可能的,但诀窍是你必须使用系统属性(使用systemProp前缀):

systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.jdbc.url=jdbc:postgresql://localhost/sonar
systemProp.sonar.jdbc.username=sonar
systemProp.sonar.jdbc.password=sonar
systemProp.sonar.login=admin
systemProp.sonar.password=admin
Run Code Online (Sandbox Code Playgroud)

请参阅:https: //docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle#AnalyzingwithSonarQubeScannerforGradle-Globalconfigurationsettings

这应该适用于旧的'sonar-runner'插件,但可以尝试新的'org.sonarqube'插件:https://plugins.gradle.org/plugin/org.sonarqube