๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋นˆ ๊ตฌ๋ฉ ์ฑ„์šฐ๊ธฐ

[SonarQube] Android Project์— SonarSanner ์‹คํ–‰ํ•˜๊ธฐ

SonarQube๋ฅผ ์„ค์น˜ํ–ˆ๊ณ , ์ด์ œ ์ •๋ง ์ •์ ๋ถ„์„์„ ์œ„ํ•ด ์ค€๋น„ํ•œ๋‹ค.

 

docs.sonarqube.org/latest/setup/get-started-2-minutes/

 

Try Out SonarQube | SonarQube Docs

From the zip file Download the SonarQube Community Edition zip file. As a non-root user, unzip it, let's say in C:\sonarqube or /opt/sonarqube. As a non-root user, start the SonarQube Server: # On Windows, execute: C:\sonarqube\bin\windows-x86-64\StartSona

docs.sonarqube.org

http://www.localhost:9000 ์œผ๋กœ ์ง„์ž…ํ•˜๊ณ  ๋กœ๊ทธ์ธ ํ›„์—

 

Create new Project ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์ƒˆ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ ๋‹ค.

 

 

ํ”„๋กœ์ ํŠธ key, ํ”„๋กœ์ ํŠธ์˜ display name์„ ์ง€์ •ํ•˜๊ณ  Set Up ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅธ๋‹ค.

 

token ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜๊ณ  Generate ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด

ํ† ํฐ์ด ์ƒ์„ฑ๋œ๋‹ค. Continue ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๊ณ 

 

Android ํ”„๋กœ์ ํŠธ์ด๊ธฐ ๋•Œ๋ฌธ์— Gradle build๋ฅผ ์„ ํƒํ•œ๋‹ค.

build.gradle ํŒŒ์ผ์— ๋„ฃ์„ ์ฝ”๋“œ์™€ command ๋ช…๋ น์–ด๋ฅผ ์•Œ๋ ค์ค€๋‹ค.

์œ„์˜ ์ฝ”๋“œ๋Š” Kotlin DSL ์ฝ”๋“œ์˜€๋‹ค. ๋‚ด๊ฐ€ ์ •์ ๋ถ„์„์„ ํ•˜๋ ค๊ณ  ํ•˜๋Š” ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ์“ธ ์ˆ˜ ์—†์–ด์„œ ํ—ค๋ฉ”๋‹ค๊ฐ€ ์š” ํŽ˜์ด์ง€์—์„œ ์ฐพ์•˜๋‹ค.

plugins.gradle.org/plugin/org.sonarqube

 

Gradle - Plugin: org.sonarqube

Version 3.1.1 (latest) Created 25 January 2021. Gradle plugin to help analyzing projects with SonarQube plugins { id "org.sonarqube" version "3.1.1" } buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "o

plugins.gradle.org

ใ…ฃ ํŽ˜์ด์ง€์˜ legacy plugin application ์ฝ”๋“œ๋ฅผ ํ™œ์šฉํ–ˆ๋‹ค.

 

ํ”„๋กœ์ ํŠธ์˜ build.gradle ํŒŒ์ผ์—์„œ ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ๋„ฃ์—ˆ๊ณ 

ํ”„๋กœ์ ํŠธ build.gradle ์ถ”๊ฐ€ ์ฝ”๋“œ

app์˜ build.gradle ํŒŒ์ผ์—์„œ ์ด ์ฝ”๋“œ๋ฅผ ์‚ฝ์ž…ํ–ˆ๋‹ค.

app build.gradle ์ถ”๊ฐ€ ์ฝ”๋“œ

 

๊ทธ๋ฆฌ๊ณ  ํ„ฐ๋ฏธ๋„์—์„œ cmd ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ–ˆ๋‹ค.

์†Œ๋‚˜ํ๋ธŒ ์Šค์บ๋„ˆ๋ฅผ ๋Œ๋ฆฝ์‹œ๋‹ค.

๋ช…๋ น์–ด : gradlew.bat sonarqube -Dsonar.projectKey={ํ”„๋กœ์ ํŠธํ‚ค} -Dsonar.host.url=http://localhost:9000 -Dsonar.login={ํ† ํฐ}

 

์‹คํ–‰ํ•ด์„œ ๋นŒ๋“œ ์„ฑ๊ณต์„ ํ™•์ธํ•˜๊ณ  

๋นŒ๋“œ ์„ฑ๊ณต

 

* ๋งค๋ฒˆ ์ €๋ ‡๊ฒŒ ๊ธธ๊ฒŒ ๋ช…๋ น์–ด๋ฅผ ์“ฐ๊ธฐ ์‹ซ์–ด์„œ ๋” ์ฐพ์•„๋ดค๋‹ค.

app์˜ build.gradle ํŒŒ์ผ์— ํ”„๋กœํผํ‹ฐ ๊ฐ’๋“ค์„ ์ง€์ •ํ•ด ๋„ฃ์–ด์คฌ๋‹ค.

host.url, login(ํ† ํฐ), projectKey ๊ฐ’ ์„ค์ •ํ•ด์ฃผ๊ธฐ

๊ทธ๋ฆฌ๊ณ  terminal์— ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ–ˆ๋‹ค.

๋ช…๋ น์–ด : gradlew.bat sonarqube

์ตœ์†Œํ•œ์˜ ๋ช…๋ น์–ด ์ž…๋ ฅ

๋นŒ๋“œ ์„ฑ๊ณต ํ™•์ธํ–ˆ๋‹ค.

๋นŒ๋“œ ์„ฑ๊ณต

 

๊ทธ๋ฆฌ๊ณ 

 

์„œ๋ฒ„๋ฅผ ํ™•์ธํ•˜๋‹ˆ๊นŒ ์ €๋ ‡๊ฒŒ ๋‚˜์™”๋‹ค. ํ”„๋กœ์ ํŠธ ๋ถ„์„์ด ์ œ๋Œ€๋กœ ์ด๋ค„์ง„ ๋“ฏ ํ•˜๋‹ค. 


๋ฒ„๊ทธ ๊ฐœ์ˆ˜๋กœ ํ˜„์‹ค ์ง์‹œ๐Ÿ˜‚