SonarQubeを利用してみよう-設置編-
Sonar Qube Installzation.
こんにちはー
Androidで ソースのクォリティーを上げるために使ったりする sonar qubeのインストール方法を紹介しようと思います。
http://www.sonarqube.org/ ホームページはこちらです。
1. brew install sonar
`brew install sonar` sonarをインストールします
2.sonar.propertiesの設定を変更
ここのバージョンはinstallされたやつで変えてください。
~ ᐅ vim /usr/local/Cellar/sonar/5.x.x/libexec/conf/sonar.properties
ファイルの中に 変更する部分は
dbのuseridとpassword、後使うDBの部分ですが、今回はMysqlで利用してみようと思います。
11 #
12 # IMPORTANT: the embedded H2 database is used by default. It is recommended for tests but not for
13 # production use. Supported databases are MySQL, Oracle, PostgreSQL and Microsoft SQLServer.
14
15 # User credentials.
16 # Permissions to create tables, indices and triggers must be granted to JDBC user.
17 # The schema must be created first.
18 sonar.jdbc.username=sonar
19 sonar.jdbc.password=sonar
20
.....
29
30 #----- MySQL 5.x
31 # Only InnoDB storage engine is supported (not myISAM).
32 # Only the bundled driver is supported.
33 sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfig s=maxPerformance
こんな感じで # を消して comment outされているやつを回るようにしてあげればいいのです。
3. mysql install
- mysqlを installします。
$brew install mysql
$mysql.server start
こうすることで使用できると思います。
4. mysqlを使う
$ mysql -uroot
mysql)CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
IDENTIFIED BY 'PASSWORD'ですが、コピペーしやすいように sonarにします。
passwordと usernameを sonarにする感じで実装します
5. sonar restart
$ sonar restart
#Starting SonarQube...
#Started SonarQube.
これでできる! sonar qubeの default urlは
http://localhost:9000/ なので接続してみましょう
あら....
何かの問題があるっぽいですね
6. sudo sonar restart
確認を一通りやってみて問題がない感じだと思って 権限かなと思い、sudoをつけてみましたー
٩( ᐛ )و
これで接続できる!
今日は ここまでやって次、ツールの使い方とアンドロイドのsampleアプリからgradleで伝送する感じでやってみるつもりです。
では、またの時に!