Java based parking spot management application
- Visit the official SonarQube website: https://www.sonarqube.org/downloads/.
- Scroll down to the Community Edition (free) section and click on the Download button.
- The download should start automatically. You will get a
.zipfile for the SonarQube server.
- Once the download is complete, extract the
.zipfile to a directory of your choice.
For example:- On Windows:
C:\SonarQube - On Linux/macOS:
/opt/sonarqube
- On Windows:
** NOTE: Java Version: SonarQube requires Java 11 or higher. Set the JAVA_HOME environment variable to point to your JDK.**
- Open a terminal (or Command Prompt) and navigate to the
bindirectory inside your SonarQube installation directory.- On Windows: Navigate to
C:\SonarQube\bin\windows-x86-64. - On Linux/macOS: Navigate to
/opt/sonarqube/bin/linux-x86-64.
- On Windows: Navigate to
- Start the SonarQube server:
- On Windows: Run
StartSonar.bat. - On Linux/macOS: Run
./sonar.sh start.
- On Windows: Run
- Wait for the server to start. You should see log messages indicating that SonarQube is running.
- Open a web browser and navigate to http://localhost:9000.
- Log in using the default credentials:
- Username:
admin - Password:
admin
- Username:
- Update the default password if prompted.
- Open IntelliJ IDEA.
- Go to File > Settings (or Preferences on macOS).
- In the left-hand panel, select Plugins.
- Search for SonarQube in the search bar and press Enter.
- Find the SonarQube plugin in the search results and click Install.
- Restart IntelliJ IDEA after installation.
- Log in to the SonarQube Server:
- Open your browser and go to http://localhost:9000.
- Log in using your credentials. Default credentials are:
- Username:
admin - Password:
admin(if changed, use your updated password).
- Username:
- Go to the Projects Section:
- From the SonarQube Dashboard, click on the Projects tab in the top menu bar.
- Click the Create Project button (located at the top-right corner of the page).
- Select the Manual Setup Option:
- Choose Manually to create a project manually.
- Enter Project Details:
- Provide the following information:
- Project Name: Enter a descriptive name for your project (e.g., "My Java Project").
- Project Key: Enter a unique identifier for your project (e.g.,
my_java_project).
- Click the Set Up button.
- Provide the following information:
- Choose Analysis Method:
- When prompted, select Locally.
- Generate Authentication Token:
- Enter a name for the token (e.g., "MyProjectToken") and click Generate Token.
- Copy the generated token immediately.
- Click Continue.
- Select Build Tool and Generate Command:
- Select your preferred build tool (e.g., Maven, Gradle). Choose Maven for this setup.
- SonarQube will display a command template. For Maven, it will look like this:
mvn sonar:sonar \ -Dsonar.projectKey=my_java_project \ -Dsonar.host.url=http://localhost:9000 \ -Dsonar.login=<your_generated_token>
- Replace
<your_generated_token>with the token generated earlier.
- Run the Command:
- Open a terminal (or Command Prompt) and navigate to the root directory of your project.
- Paste and execute the generated command.
- If the build is successful, the project will appear on the SonarQube dashboard.
- Open IntelliJ IDEA and navigate to your project.
- Go to File > Settings (or Preferences on macOS).
- In the left-hand menu, select Tools > SonarQube.
- Click the + icon to add a new SonarQube server.
- Fill in the following details:
- Name: Enter a name for the server configuration (e.g., "My SonarQube Server").
- Server URL: Enter the URL of your SonarQube server (e.g.,
http://localhost:9000). - Authentication Token: Paste the token generated in Step 6.
- Click Test Connection to verify the setup.
- Click OK to save.
- Open your browser and navigate to http://localhost:9000.
- Go to your project in the dashboard to view the analysis results, including issues, code smells, and quality gates.
By following these steps, you will successfully integrate SonarQube with IntelliJ IDEA and analyze your project for code quality.