feat: 添加 Maven 发布插件配置并更新版本

添加flatten-maven-plugin用于生成完整的POM文件以支持OSS发布,
并移除重复的开发者信息配置,
添加GPG签名和Central发布插件配置到release profile中,
同时更新父POM和子模块版本从SNAPSHOT到RC4。
This commit is contained in:
2026-05-28 23:23:58 +08:00
parent ba9ccebb56
commit d73b8f445d
3 changed files with 69 additions and 68 deletions

2
.gitignore vendored
View File

@@ -4,6 +4,8 @@ target/
!**/src/main/**/target/
!**/src/test/**/target/
.flattened-pom.xml
### STS ###
.apt_generated
.classpath

View File

@@ -8,7 +8,8 @@
<parent>
<groupId>xyz.zhouxy.plusone</groupId>
<artifactId>plusone-validator-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0-RC1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>plusone-validator</artifactId>
@@ -18,27 +19,6 @@
Plusone Validator 是一个校验库,使用 lambda 表达式(包括方法引用)和流式 API 构建校验规则,对对象进行校验。
</description>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Zhou Xingyi (周兴毅)</name>
<url>https://gitea.zhouxy.xyz/plusone</url>
</developer>
</developers>
<scm>
<connection>scm:git:https://gitea.zhouxy.xyz/plusone/plusone-validator.git</connection>
<developerConnection>scm:git:ssh://gitea.zhouxy.xyz/plusone/plusone-validator.git</developerConnection>
<url>https://gitea.zhouxy.xyz/plusone/plusone-validator</url>
</scm>
<dependencies>
<dependency>
<groupId>xyz.zhouxy.plusone</groupId>

103
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>xyz.zhouxy.plusone</groupId>
<artifactId>plusone-validator-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0-RC4</version>
<name>plusone-validator-parent</name>
<url>https://gitea.zhouxy.xyz/plusone/plusone-validator</url>
@@ -47,7 +47,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<plusone-commons.version>1.1.0-SNAPSHOT</plusone-commons.version>
<plusone-commons.version>1.1.0-RC2</plusone-commons.version>
</properties>
<dependencyManagement>
@@ -68,49 +68,68 @@
</dependencyManagement>
<build>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<pluginManagement>
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<!-- Flatten 插件:生成包含继承信息的完整 POM 用于发布 -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<!-- 核心配置oss 模式专为 Sonatype/Maven Central 设计 -->
<!-- 它会保留 url, licenses, developers, scm, properties 等必要元素 -->
<flattenMode>oss</flattenMode>
</configuration>
<executions>
<!-- 在 process-resources 阶段生成展平的 POM -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- 在 clean 阶段删除展平的 POM -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>