Step 1. Download sonarqube click here and choose the latest version of sonarqube(7.1)
Step 2. Extract it.
Step 3.Check maven is configured in your Machine or not.
Open cmd and type mvn -version. It will display the maven version.
Open cmd and type mvn -version. It will display the maven version.
Step 4. Go to the directory where Maven is installed.
e.g C:\Tools\apache-maven-3(in my case)
4.1 Go inside the conf folder and edit setting.xml file with below.
Inside <pluginGroups> add highlighted line.
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
4.2 Under profiles tag add below lines.
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://localhost:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
Step 5. Go to the location where SonarQube is extracted.
..\sonarqube-7.1\bin\windows-x86-64 and click on batch file(StartSonar.bat).
Once sonarqube is up, type http://localhost:9000 in the browser.
Step 6. login with default credential
username : admin
password : admin.
username : admin
password : admin.
Step 7. Click on Quality Profiles
7.1 Select Java Profile from the drop-down box.
7.2 Click on the Restore button which is on the right and gives the path of the custom sonarqube.xml. To download Click here.
7.3. Rename it. For this click on setting icon.
7.4 Set as default for this configuration. For this click on setting icon.
Step 8. Go to this location ..\Development\Jordans\My-Formations\my-formation-rest> .
8.1 Type cmd in the address bar. It will open the cmd.
8.2 Type mvn sonar: sonar.
For SonarLint.
1. Go to the marketplace in sts/eclipse ide and type sonarlint and install the plugin.
2. Go to window>showviews>others>sonarlint>sonarqube server>
configure the server with below details.
a) http://localhost:9000
b) username + password admin/admin
Finally Right click on any project build path> configuration build path >sonlarlint> update project binding> type my-formation-rest(under SonarQube Project).
SonarQube and SonarLint are configured.
Now Right-click on any project/file sonarlint> analyze it will run sonarlint and highlighted where your code violated the sonar rules.
Happy Coding.