-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scaffold): support sonar integration
- Loading branch information
Showing
7 changed files
with
238 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
generators/app/templates/1.docs/guides/dependencies/jacoco.tmpl.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Jacoco | ||
|
||
Jacoco可以为你统计代码覆盖率,默认作用在maven生命周期的`verify`阶段。 | ||
|
||
## 如何使用 | ||
|
||
执行maven的`verify`生命周期 | ||
|
||
```shell | ||
$ mvn clean verify | ||
``` | ||
|
||
如果你使用IDE,也可以直接在IDE上执行`root -> Lifecycle -> verify`。 | ||
|
||
然后可查看生成的测试报告 | ||
|
||
```shell | ||
$ open cov-report/target/jacoco-ut/index.html | ||
``` | ||
|
||
## 配置Jacoco | ||
|
||
可以通过 `pom.xml` 的 `cov` profile对jacoco进行详细的配置,详细请参考[官方文档](https://www.jacoco.org/jacoco/trunk/doc/maven.html)。 | ||
|
||
### 常用配置 | ||
|
||
- `configuration -> rules -> rule -> limits -> limit` | ||
- COVEREDRATIO: 最低覆盖率百分比限制 | ||
- MISSEDCOUNT: 最低无测试的类数量限制 | ||
- `configuration -> excludes -> exclude`: 需要排除统计的类 | ||
|
||
## 其它 | ||
|
||
### 关于cov-report模块 | ||
|
||
`cov-report`是为了聚合多模块工程环境下的多份报告而存在的模块,如果工程中添加了新的模块,需要在cov-report模块的pom.xml中加入相关的依赖,否则新模块的报告无法被聚合显示。 | ||
|
26 changes: 26 additions & 0 deletions
26
generators/app/templates/1.docs/guides/dependencies/sonar.tmpl.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Sonar | ||
|
||
> Sonar属于外部服务,在接入之前请先准备好可用的基础设施 | ||
## 如何接入 | ||
|
||
通过 `pom.xml` 的 `sonar` profile 配置 `sonar.host.url` 为你的sonar服务地址 | ||
|
||
```xml | ||
<profile> | ||
<id>sonar</id> | ||
<properties> | ||
<sonar.host.url>http://{sonar-url}</sonar.host.url> | ||
</properties> | ||
</profile> | ||
``` | ||
|
||
然后执行 | ||
|
||
```shell | ||
$ mvn clean verify sonar:sonar | ||
``` | ||
|
||
如果你使用IDE,也可以直接在IDE先执行 `root -> Lifecycle -> verify`,再执行 `root -> Plugins -> sonar -> sonar:sonar`。 | ||
|
||
等待任务完成后,即可在sonar ui界面查看到你的代码分析结果。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>${groupId}</groupId> | ||
<artifactId>${artifactId}</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>cov-report</artifactId> | ||
|
||
<description>this module is only for coverage report aggregation.</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${groupId}</groupId> | ||
<artifactId>${artifactId}-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>${groupId}</groupId> | ||
<artifactId>${artifactId}-provider</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>cov</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>report-aggregate</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>report-aggregate</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters