完整 MAC上Android在SonraQube上配置、應用

 MAC上Android在SonraQube上配置、應用

 1、安裝相應工具

  • sonarqube安裝包
  •  jdk11 (最新版的sonarqube需要jdk11)
  • SonarQube Scanner (brew install sonar-scanner)

 

安裝完 使用 sonar-scanner -v測試下

INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/4.0.0.1744/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 4.0.0.1744
INFO: Java 11.0.3 Oracle Corporation (64-bit)
INFO: Mac OS X 10.14.5 x86_64
  •  mysql 非必需品

安裝完所需的一切之後可以開始實踐了


 2.啓動sonarqube

 

 1.到對應路徑啓動

用命令行cd到當前目錄下


 

sh sonar.sh start

出現下面這行字

Starting SonarQube...
Started SonarQube.

2.打開瀏覽器做相對應初始化的配置

在瀏覽器輸入 `http://localhost:9000` 本地端口
出現現在下面圖片

(第一次進入右邊是沒有已分析項目)

登陸默認賬號密碼 admin
在配置當中安裝相應的插件,這邊可以下載中文版
 

查看項目,第一次進去是沒有項目的
 

 3.配置相對應的Android項目

在Android的根目錄新增文件

配置文件如下

# must be unique in a given SonarQube instance
sonar.projectKey=com.hugh.basis
# this is the name displayed in the SonarQube UI
sonar.projectName=AndroidBasis
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=/Users/macbook/AndroidStudioProjects/AndroidBasis/app/src
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
#path to your project build output path
sonar.java.binaries=app/build/intermediates/classes/ 
sonar.java.source=1.8
sonar.sourceEncoding=UTF-8
sonar.host.url=http://localhost:9000
sonar.language=java


在當前根目錄下執行

 sonar-scanner

出現以下信息

INFO: Analysis total time: 18.872 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 20.633s
INFO: Final Memory: 16M/57M
INFO: -------------------------------------

再回到剛剛的頁面

以上就是完整的Android在mac下配置sonarqube的完整流程

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章