Skip to content

Commit

Permalink
Merge pull request #2639 from antarus/feature/add-sonar-doc
Browse files Browse the repository at this point in the history
Add sonar documentation
  • Loading branch information
pascalgrimaud authored Jul 17, 2022
2 parents b8fc25f + 9883e9e commit b291c4a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ private JHipsterModuleBuilder commonModuleFiles(JHipsterModuleProperties propert
return moduleBuilder(properties)
.context()
.put("sonarqubeDockerImage", dockerImages.get("sonarqube").fullName())
.put("srcMainDocker", "src/main/docker")
.and()
.documentation(documentationTitle("sonar"), SOURCE.template("sonar.md"))
.javaBuildPlugins()
.plugin(propertiesPlugin())
.pluginManagement(sonarPlugin())
Expand Down
22 changes: 22 additions & 0 deletions src/main/resources/generator/server/sonar/sonar.md.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Usage

Before you can analyse your project, you must launch sonar with the following command

**with docker-compose**
```bash
docker-compose -f {{srcMainDocker}}/sonar.yml up -d
```

**with docker compose plugin**
```bash
docker compose -f {{srcMainDocker}}/sonar.yml up -d
```

After that you can launch the analysis of your project with
```bash
./mvnw clean verify sonar:sonar
```

You can see the result at [http://localhost:9001/](http://localhost:9001/)

[official documentation](https://www.sonarqube.org/)
4 changes: 4 additions & 0 deletions src/test/features/sonar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ Feature: Sonar modules
| baseName | jhipster |
Then I should have files in "."
| sonar-project.properties |
Then I should have files in "documentation"
| sonar.md |

Scenario: Should apply frontend and backend sonar module
When I apply "sonar-java-backend-and-frontend" module to default project with maven file
| packageName | tech.jhipster.chips |
| baseName | jhipster |
Then I should have files in "."
| sonar-project.properties |
Then I should have files in "documentation"
| sonar.md |
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ void shouldBuildBackendModule() {
.containing(
"sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, src/main/webapp/i18n/*.js, target/classes/static/**/*.*, src/main/webapp/app/index.tsx"
)
.notContaining("sonar.testExecutionReportPaths=target/test-results/jest/TESTS-results-sonar.xml");
.notContaining("sonar.testExecutionReportPaths=target/test-results/jest/TESTS-results-sonar.xml")
.and()
.createFile("documentation/sonar.md")
.containing("docker compose -f src/main/docker/sonar.yml up -d");
}

@Test
Expand All @@ -51,7 +54,10 @@ void shouldBuildBackendFrontendModule() {
.containing(
"sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, src/main/webapp/i18n/*.js, target/classes/static/**/*.*, src/main/webapp/app/index.tsx, src/main/webapp/routes/index.svelte"
)
.containing("sonar.testExecutionReportPaths=target/test-results/jest/TESTS-results-sonar.xml");
.containing("sonar.testExecutionReportPaths=target/test-results/jest/TESTS-results-sonar.xml")
.and()
.createFile("documentation/sonar.md")
.containing("docker-compose -f src/main/docker/sonar.yml up -d");
}

private void mockSonarqubeImage() {
Expand Down

0 comments on commit b291c4a

Please sign in to comment.