由于公司的墙太高了,我炸不开,无法畅快的用gradle,所以我还是乖乖的用sonar-runner来生成代码质量的数据吧。
在csdn上找的资源!
解压缩后,文件目录结构
然后配置环境变量,在cmd下输入sonar-runner,出现如下信息说明配置正确
C:\Users\hui.qian>sonar-runner -h D:\sonar\sonar-runner-2.4 INFO: INFO: usage: sonar-runner [options] INFO: INFO: Options: INFO: -D,--define <arg> Define property INFO: -e,--errors Produce execution error messages INFO: -h,--help Display help information INFO: -v,--version Display version information INFO: -X,--debug Produce execution debug output
在sonar-runner目录下找到conf/sonar-runner.properties文件。打开mysql的配置
#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:9002 #----- 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=sonar sonar.jdbc.password=sonar #----- Default source code encoding sonar.sourceEncoding=UTF-8 #----- Security (when 'sonar.forceAuthentication' is set to 'true') sonar.login=admin sonar.password=admin
ok,上面关于sonar-runner全部配置完成
点击StartSonar.bat启动sonar服务器:
我选择我自己正在做的一个项目,然后在该项目根目录下添加一个sonar配置文件sonar-project.properties。配置文件中信息如下:
sonar-project.properties
sonar.projectKey=as sonar.projectName=as sonar.projectVersion=1.0 sonar.sources=src binaries=bin
Caused by: java.lang.IllegalStateException: The svn blame command [svn blame --x ml --non-interactive -x -w src/com/sprd/scenario/test/ASDeviceManagerTest.java] failed: svn: warning: W155010: The node 'D:\as\src\com\sprd\scenario\test\ASDevi ceManagerTest.java' was not found. svn: E200009: Could not perform blame on all targets because some targets don't exist
这个时候我们访问http://localhost:9002/就可以看见该项目的代码质量