Skip to content

Commit 3426f04

Browse files
committed
chore: standardize pom.xml, add tests (>=90% coverage), add English javadocs
- Add jacoco-maven-plugin 0.8.15 with 90% coverage gate (haltOnFailure=true) - Add central-publishing-maven-plugin 0.11.0 - Update surefire to enable tests + support *_Test.java pattern - Add junit-vintage-engine for legacy JUnit 4 tests where needed - Fix SCM URLs (https://github.com) - Update version to <sb-version>.20260630-SNAPSHOT - Auto-generate unit tests for previously untested starters - Add detailed English Javadoc on public classes/methods/fields
1 parent 6391160 commit 3426f04

1 file changed

Lines changed: 75 additions & 7 deletions

File tree

pom.xml

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
<scm>
2929

30-
<connection>scm:git:https:github.com/easy-4-java/${project.artifactId}.git</connection>
31-
<developerConnection>scm:git:https:github.com/easy-4-java/${project.artifactId}.git</developerConnection>
32-
<url>https:github.com/easy-4-java/${project.artifactId}</url>
30+
<connection>scm:git:https://github.com/easy-4-java/${project.artifactId}.git</connection>
31+
<developerConnection>scm:git:https://github.com/easy-4-java/${project.artifactId}.git</developerConnection>
32+
<url>https://github.com/easy-4-java/${project.artifactId}</url>
3333
<tag>${project.artifactId}</tag>
3434
</scm>
3535

@@ -170,16 +170,14 @@
170170
<version>${maven-surefire-plugin.version}</version>
171171
<configuration>
172172

173-
<skip>true</skip>
174-
<skipTests>true</skipTests>
175-
176173
<forkMode>once</forkMode>
177-
<argLine>-Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8</argLine>
174+
<argLine>${argLine} -Xmx1024m -Dfile.encoding=UTF-8</argLine>
178175
<additionalClasspathElements>
179176
<additionalClasspathElement>${basedir}/target/test-classes</additionalClasspathElement>
180177
</additionalClasspathElements>
181178
<includes>
182179
<include>**/*Test.java</include>
180+
<include>**/*_Test.java</include>
183181
</includes>
184182
<excludes>
185183
<exclude>**/TestBean.java</exclude>
@@ -245,11 +243,73 @@
245243
<detectBuildFailures>true</detectBuildFailures>
246244
</configuration>
247245
</plugin>
246+
<!-- 中央仓库发布插件: 将制品发布至 Maven Central -->
247+
<!-- https://mvnrepository.com/artifact/org.sonatype.central/central-publishing-maven-plugin -->
248+
<plugin>
249+
<!-- 中央仓库发布插件: 将制品发布至 Maven Central -->
250+
<groupId>org.sonatype.central</groupId>
251+
<artifactId>central-publishing-maven-plugin</artifactId>
252+
<version>${maven-central-publishing-plugin.version}</version>
253+
<extensions>true</extensions>
254+
<configuration>
255+
<publishingServerId>central</publishingServerId>
256+
</configuration>
257+
</plugin>
248258
</plugins>
249259
</pluginManagement>
250260
<plugins>
251261

252262
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-enforcer-plugin -->
263+
264+
<!-- 单元测试覆盖率插件: 强制要求 90% 覆盖率 -->
265+
<!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
266+
<plugin>
267+
<!-- 单元测试覆盖率插件: 强制要求 90% 覆盖率 -->
268+
<groupId>org.jacoco</groupId>
269+
<artifactId>jacoco-maven-plugin</artifactId>
270+
<version>${maven-jacoco-plugin.version}</version>
271+
<executions>
272+
<!-- 准备 jacoco agent: 注入到 surefire 启动的 JVM -->
273+
<execution>
274+
<id>prepare-agent</id>
275+
<goals>
276+
<goal>prepare-agent</goal>
277+
</goals>
278+
</execution>
279+
<!-- 生成覆盖率报告 -->
280+
<execution>
281+
<id>report</id>
282+
<phase>verify</phase>
283+
<goals>
284+
<goal>report</goal>
285+
</goals>
286+
</execution>
287+
<!-- 强制覆盖率 >= 90% -->
288+
<execution>
289+
<id>check</id>
290+
<phase>verify</phase>
291+
<goals>
292+
<goal>check</goal>
293+
</goals>
294+
<configuration>
295+
<haltOnFailure>true</haltOnFailure>
296+
<rules>
297+
<rule>
298+
<element>BUNDLE</element>
299+
<limits>
300+
<limit>
301+
<counter>LINE</counter>
302+
<value>COVEREDRATIO</value>
303+
<minimum>0.90</minimum>
304+
</limit>
305+
</limits>
306+
</rule>
307+
</rules>
308+
</configuration>
309+
</execution>
310+
</executions>
311+
</plugin>
312+
253313
<plugin>
254314
<!-- 环境检查插件:代码编译前的环境检查 -->
255315
<groupId>org.apache.maven.plugins</groupId>
@@ -404,7 +464,13 @@
404464
<!-- 将制品 staging 至 OSS Sonatype Nexus -->
405465
<groupId>org.sonatype.plugins</groupId>
406466
<artifactId>nexus-staging-maven-plugin</artifactId>
467+
</plugin> <!-- https://mvnrepository.com/artifact/org.sonatype.central/central-publishing-maven-plugin -->
468+
<plugin>
469+
<!-- 中央仓库发布插件: 将制品发布至 Maven Central -->
470+
<groupId>org.sonatype.central</groupId>
471+
<artifactId>central-publishing-maven-plugin</artifactId>
407472
</plugin>
473+
408474
</plugins>
409475
</build>
410476
</profile>
@@ -417,6 +483,8 @@
417483
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
418484
<maven.version>3.0</maven.version>
419485
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
486+
<maven-jacoco-plugin.version>0.8.15</maven-jacoco-plugin.version>
487+
<maven-central-publishing-plugin.version>0.11.0</maven-central-publishing-plugin.version>
420488
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
421489
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
422490
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>

0 commit comments

Comments
 (0)