g2rain-common
Used in:
components
- OverviewOverview
- VersionsVersions
- DependentsDependents
- DependenciesDependencies
<dependency>
<groupId>com.g2rain</groupId>
<artifactId>g2rain-common</artifactId>
<version>1.0.8</version>
</dependency><?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.g2rain</groupId>
<artifactId>g2rain-common</artifactId>
<version>1.0.8</version>
<packaging>jar</packaging>
<name>G2rain Common</name>
<description>
G2Rain core library for daily development.
Provides common utility functions, constants, base data models, and unified exception handling.
Aims to improve development efficiency and maintain code consistency.
</description>
<!-- Project URL: Maven Central 要求必须配置 -->
<url>https://github.com/g2rain/g2rain-common</url>
<scm>
<url>https://github.com/g2rain/g2rain-common</url>
<connection>scm:git:https://github.com/g2rain/g2rain-common.git</connection>
<developerConnection>scm:git:ssh://git@github.com/g2rain/g2rain-common.git</developerConnection>
<tag>HEAD</tag>
</scm>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<organization>
<name>G2rain</name>
<url>http://www.g2rain.com/</url>
</organization>
<developers>
<developer>
<name>Jagger</name>
<email>g2rain_developer@163.com</email>
<organization>G2rain</organization>
<organizationUrl>http://www.g2rain.com/</organizationUrl>
</developer>
<developer>
<id>alpha</id>
<name>Alpha</name>
<organization>G2rain</organization>
<organizationUrl>http://www.g2rain.com/</organizationUrl>
</developer>
</developers>
<distributionManagement>
<!-- Snapshot 仓库配置 -->
<snapshotRepository>
<id>central-portal-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
</snapshotRepository>
<!-- Release 仓库由 central-publishing-maven-plugin 自动处理,无需配置 -->
</distributionManagement>
<properties>
<jackson.databind.version>3.1.1</jackson.databind.version>
<junit.jupiter.version>6.0.3</junit.jupiter.version>
<mockito.core.version>5.23.0</mockito.core.version>
<lombok.version>1.18.44</lombok.version>
<mapstruct.version>1.6.3</mapstruct.version>
<swagger.annotations.version>2.2.46</swagger.annotations.version>
<jetbrains.annotations.version>26.1.0</jetbrains.annotations.version>
<jakarta.validation.api.version>3.0.2</jakarta.validation.api.version>
<hibernate.validator.version>8.0.2.Final</hibernate.validator.version>
<expressly.version>5.0.0</expressly.version>
<maven.compiler.plugin.version>3.15.0</maven.compiler.plugin.version>
<maven.surefire.plugin.version>3.5.5</maven.surefire.plugin.version>
<maven.enforcer.plugin.version>3.6.2</maven.enforcer.plugin.version>
<maven.checkstyle.plugin.version>3.6.0</maven.checkstyle.plugin.version>
<maven.pmd.plugin.version>3.28.0</maven.pmd.plugin.version>
<spotbugs.maven.plugin.version>4.9.8.3</spotbugs.maven.plugin.version>
<jacoco.maven.plugin.version>0.8.14</jacoco.maven.plugin.version>
<maven.source.plugin.version>3.4.0</maven.source.plugin.version>
<maven.javadoc.plugin.version>3.12.0</maven.javadoc.plugin.version>
<flatten.maven.plugin.version>1.7.3</flatten.maven.plugin.version>
<maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
<central.publishing.maven.plugin.version>0.10.0</central.publishing.maven.plugin.version>
<maven.compiler.release>25</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 版本号可根据项目需求调整,建议使用 3.x 及以上稳定版 -->
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.databind.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations-jakarta</artifactId>
<version>${swagger.annotations.version}</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${jakarta.validation.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.expressly</groupId>
<artifactId>expressly</artifactId>
<version>${expressly.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>${jetbrains.annotations.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 编译插件,用于编译Java源代码 -->
<!-- 使用方式: mvn compiler:compile -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<!-- 指定目标Java版本(如25), 替代传统的<source>和<target>, 确保字节码与指定版本兼容 -->
<release>${maven.compiler.release}</release>
<!-- 指定编码格式 -->
<encoding>${project.build.sourceEncoding}</encoding>
<compilerArgs>
<!-- 启用方法参数元数据保留, 支持反射获取参数名(如WebFlux参数绑定) -->
<arg>-parameters</arg>
</compilerArgs>
<!-- 配置注解处理器依赖路径 -->
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<!-- 单元测试插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<argLine>
-XX:+EnableDynamicAgentLoading -Xshare:off
</argLine>
</configuration>
</plugin>
<!-- Maven强制执行插件,用于强制执行项目规则 -->
<!-- 使用方式: mvn enforcer:enforce -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.enforcer.plugin.version}</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<!-- 指定必须使用 JDK 25 -->
<requireJavaVersion>
<version>[25,)</version>
</requireJavaVersion>
<!-- 检查依赖冲突 -->
<requireUpperBoundDeps/>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Maven Checkstyle插件,用于检查代码风格 -->
<!-- 使用方式: mvn checkstyle:check -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<configuration>
<!-- 使用 Google 代码检查规范 -->
<configLocation>google_checks.xml</configLocation>
<!-- 在控制台输出结果 -->
<consoleOutput>true</consoleOutput>
<!-- 出现违反代码规范时构建失败 -->
<failsOnError>true</failsOnError>
</configuration>
</plugin>
<!-- Maven PMD插件,用于检测代码潜在问题 -->
<!-- 使用方式: mvn pmd:check -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven.pmd.plugin.version}</version>
<configuration>
<!-- 出现违反规则时构建失败 -->
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
<!-- SpotBugs Maven插件,用于静态代码分析,查找潜在bug -->
<!-- 使用方式: mvn spotbugs:check -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs.maven.plugin.version}</version>
<configuration>
<!-- 出现 bug 时构建失败 -->
<failOnError>true</failOnError>
</configuration>
</plugin>
<!-- JaCoCo Maven插件,用于代码覆盖率检查 -->
<!-- 使用方式:
1. mvn clean test (执行测试并生成覆盖率数据)
2. mvn jacoco:report (生成覆盖率报告) -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<!-- 准备 JaCoCo 运行时代理 -->
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<!-- 生成代码覆盖率报告 -->
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 源码包插件:生成sources jar,发布到maven仓库时方便用户查看源码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven.source.plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc插件:生成javadoc jar,方便文档查看 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.plugin.version}</version>
<configuration>
<release>${maven.compiler.release}</release>
<encoding>${project.build.sourceEncoding}</encoding>
<doclint>none</doclint>
<additionalOptions>
<additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 生成一个“扁平化”的 POM 文件 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten.maven.plugin.version}</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- 发布 profile:签名 + Sonatype staging -->
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<!-- GPG 签名插件:生成已签名的 jar / pom -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven.gpg.plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--batch</arg>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
<passphrase>${env.MAVEN_GPG_PASSPHRASE}</passphrase>
</configuration>
</execution>
</executions>
</plugin>
<!-- Central Publishing Maven Plugin:使用新的 Central Publisher Portal -->
<!-- 参考文档:https://central.sonatype.org/publish/publish-portal-maven/ -->
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${central.publishing.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<!-- 自动发布,无需手动干预(适合 CI 构建) -->
<autoPublish>true</autoPublish>
<!-- 等待直到发布完成 -->
<waitUntil>published</waitUntil>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>