Skip to content

Commit 49b2bd5

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 3b965f2 commit 49b2bd5

1 file changed

Lines changed: 81 additions & 8 deletions

File tree

‎pom.xml‎

Lines changed: 81 additions & 8 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

@@ -167,16 +167,13 @@
167167
<version>${maven-surefire-plugin.version}</version>
168168
<configuration>
169169

170-
<skip>true</skip>
171-
<skipTests>true</skipTests>
172-
173-
174-
<argLine>-Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8</argLine>
170+
<argLine>${argLine} -Xmx1024m -Dfile.encoding=UTF-8</argLine>
175171
<additionalClasspathElements>
176172
<additionalClasspathElement>${basedir}/target/test-classes</additionalClasspathElement>
177173
</additionalClasspathElements>
178174
<includes>
179175
<include>**/*Test.java</include>
176+
<include>**/*_Test.java</include>
180177
</includes>
181178
<excludes>
182179
<exclude>**/TestBean.java</exclude>
@@ -239,11 +236,73 @@
239236
<detectBuildFailures>true</detectBuildFailures>
240237
</configuration>
241238
</plugin>
239+
<!-- 中央仓库发布插件: 将制品发布至 Maven Central -->
240+
<!-- https://mvnrepository.com/artifact/org.sonatype.central/central-publishing-maven-plugin -->
241+
<plugin>
242+
<!-- 中央仓库发布插件: 将制品发布至 Maven Central -->
243+
<groupId>org.sonatype.central</groupId>
244+
<artifactId>central-publishing-maven-plugin</artifactId>
245+
<version>${maven-central-publishing-plugin.version}</version>
246+
<extensions>true</extensions>
247+
<configuration>
248+
<publishingServerId>central</publishingServerId>
249+
</configuration>
250+
</plugin>
242251
</plugins>
243252
</pluginManagement>
244253
<plugins>
245254

246255
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-enforcer-plugin -->
256+
257+
<!-- 单元测试覆盖率插件: 强制要求 90% 覆盖率 -->
258+
<!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
259+
<plugin>
260+
<!-- 单元测试覆盖率插件: 强制要求 90% 覆盖率 -->
261+
<groupId>org.jacoco</groupId>
262+
<artifactId>jacoco-maven-plugin</artifactId>
263+
<version>${maven-jacoco-plugin.version}</version>
264+
<executions>
265+
<!-- 准备 jacoco agent: 注入到 surefire 启动的 JVM -->
266+
<execution>
267+
<id>prepare-agent</id>
268+
<goals>
269+
<goal>prepare-agent</goal>
270+
</goals>
271+
</execution>
272+
<!-- 生成覆盖率报告 -->
273+
<execution>
274+
<id>report</id>
275+
<phase>verify</phase>
276+
<goals>
277+
<goal>report</goal>
278+
</goals>
279+
</execution>
280+
<!-- 强制覆盖率 >= 90% -->
281+
<execution>
282+
<id>check</id>
283+
<phase>verify</phase>
284+
<goals>
285+
<goal>check</goal>
286+
</goals>
287+
<configuration>
288+
<haltOnFailure>true</haltOnFailure>
289+
<rules>
290+
<rule>
291+
<element>BUNDLE</element>
292+
<limits>
293+
<limit>
294+
<counter>LINE</counter>
295+
<value>COVEREDRATIO</value>
296+
<minimum>0.90</minimum>
297+
</limit>
298+
</limits>
299+
</rule>
300+
</rules>
301+
</configuration>
302+
</execution>
303+
</executions>
304+
</plugin>
305+
247306
<plugin>
248307
<!-- 环境检查插件:代码编译前的环境检查 -->
249308
<groupId>org.apache.maven.plugins</groupId>
@@ -401,7 +460,13 @@
401460
<!-- 将制品 staging 至 OSS Sonatype Nexus -->
402461
<groupId>org.sonatype.plugins</groupId>
403462
<artifactId>nexus-staging-maven-plugin</artifactId>
463+
</plugin> <!-- https://mvnrepository.com/artifact/org.sonatype.central/central-publishing-maven-plugin -->
464+
<plugin>
465+
<!-- 中央仓库发布插件: 将制品发布至 Maven Central -->
466+
<groupId>org.sonatype.central</groupId>
467+
<artifactId>central-publishing-maven-plugin</artifactId>
404468
</plugin>
469+
405470
</plugins>
406471
</build>
407472
</profile>
@@ -428,6 +493,8 @@
428493
<maven-help-plugin.version>3.5.0</maven-help-plugin.version>
429494
<maven-install-plugin.version>3.1.3</maven-install-plugin.version>
430495
<maven-invoker-plugin.version>3.8.0</maven-invoker-plugin.version>
496+
<maven-jacoco-plugin.version>0.8.15</maven-jacoco-plugin.version>
497+
<maven-central-publishing-plugin.version>0.11.0</maven-central-publishing-plugin.version>
431498
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
432499
<maven-javadoc-plugin.version>3.8.0</maven-javadoc-plugin.version>
433500
<maven-nexus-staging-plugin.version>1.7.0</maven-nexus-staging-plugin.version>
@@ -490,6 +557,12 @@
490557
<artifactId>spring-boot-starter-test</artifactId>
491558
<scope>test</scope>
492559
</dependency>
560+
<!-- JUnit Vintage Engine: enables running legacy JUnit 4 tests -->
561+
<dependency>
562+
<groupId>org.junit.vintage</groupId>
563+
<artifactId>junit-vintage-engine</artifactId>
564+
<scope>test</scope>
565+
</dependency>
493566

494567
<!-- For Spring Boot Configuration Processor -->
495568
<dependency>

0 commit comments

Comments
 (0)