一、sonarQube搭建见sonarLint与IntelliJ IDEA 集成
sonarqube 需要在更新中心下载Andriod
二、sonar-runer配置
2.1下载sonar-runner-dist-2.4.zip,解压
2.2进入conf->sonar-runner.properties
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
sonar.host.url=http://localhost:9000
#----- PostgreSQL
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#----- MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
#----- Oracle
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
#----- Microsoft SQLServer
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
#----- Global database settings
sonar.jdbc.username=root
sonar.jdbc.password=****
#----- Default source code encoding
#sonar.sourceEncoding=UTF-8
#----- Security (when 'sonar.forceAuthentication' is set to 'true')
sonar.login=admin
sonar.password=admin
2.3 添加环境变量
添加变量 添加到path2.4 验证
进入dos命令行,执行sonar-runner -v
三、执行测试
3.1 项目配置
sonar-runner.properties
# Required metadata
sonar.projectKey=vga
sonar.projectName=vga
sonar.projectVersion=1.0
# Paths to source directories.
# Paths are relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Do not put the "sonar-project.properties" file in the same directory with the source code.
# (i.e. never set the "sonar.sources" property to ".")
sonar.sources=src
# The value of the property must be the key of the language.
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.profile=Android Lint
3.2 执行代码扫描
进入配置文件目录,打开dos命令行,执行 sonar-runner -X或者sonar-runner -e
等等出现 execution success
四、查看结果
打开 http://localhost:9000
Home quality code扫一扫,关注TestDev
网友评论