This is a multi-module Spring Boot project with SonarCloud and JaCoCo integration for code quality analysis and code coverage reporting.
The project consists of two modules:
application: The main Spring Boot applicationlibrary: A library module with utility functions
This project is integrated with SonarCloud for continuous code quality analysis. SonarCloud analyzes the code for bugs, vulnerabilities, code smells, and test coverage.
- Create a SonarCloud account at https://sonarcloud.io/
- Create a new project in SonarCloud
- Update the following properties in the parent
pom.xmlfile:<sonar.projectKey>your-project-key</sonar.projectKey> <sonar.organization>your-organization</sonar.organization>
- Add a
SONAR_TOKENsecret to your GitHub repository:- Go to your GitHub repository
- Go to Settings > Secrets and variables > Actions
- Create a new repository secret named
SONAR_TOKENwith the value of your SonarCloud token
The SonarCloud analysis is automatically triggered by the GitHub Actions workflow on every push to the main branch and on pull requests.
You can also run the analysis locally with:
mvn clean verify sonar:sonarThis project uses JaCoCo for code coverage analysis. JaCoCo generates code coverage reports that are used by SonarCloud to display code coverage metrics.
JaCoCo is automatically run as part of the Maven build process. To generate code coverage reports, run:
mvn clean verifyThe JaCoCo reports will be generated in the target/site/jacoco directory of each module and an aggregated report will be generated in the target/site/jacoco-aggregate directory of the parent project.
The project includes a GitHub Actions workflow that builds the project, runs tests, generates code coverage reports, and runs SonarCloud analysis on every push to the main branch and on pull requests.
The workflow is defined in the .github/workflows/sonarcloud.yml file.
To run the application, use:
mvn spring-boot:run -pl applicationTo run the tests, use:
mvn testTo build the project, use:
mvn clean install
```# multi-module