This is an automated email from the ASF dual-hosted git repository.
funky-eyes pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push:
new b1922a6126 optimize: remove p3c, use maven-checkstyle-plugin, only
check PR changes. (#8057)
b1922a6126 is described below
commit b1922a61264f7ab300fcf3b83e5f084f49f126b8
Author: 徐晓伟 <[email protected]>
AuthorDate: Tue Apr 28 14:30:14 2026 +0800
optimize: remove p3c, use maven-checkstyle-plugin, only check PR changes.
(#8057)
---
.github/workflows/build.yml | 39 ++++++----
Makefile | 68 ++++++++++++++++++
build/pom.xml | 5 +-
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
.../main/resources/error/ErrorCode_en.properties | 2 +-
.../test/resources/error/ErrorCode_en.properties | 2 +-
.../src/test/resources/mock-application.properties | 2 +-
.../org/apache/seata/mcp/core/utils/UrlUtils.java | 4 +-
core/src/main/log4j.properties | 24 +++----
pom.xml | 42 +++--------
server/src/test/resources/application.properties | 2 +-
style/checkstyle.xml | 82 ++++++++++++++++++++++
13 files changed, 204 insertions(+), 70 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index db4180865e..4383df4e2e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -52,6 +52,8 @@ jobs:
# step 1
- name: "Checkout"
uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
# step 2
- name: "Use Python 3.x"
uses: actions/setup-python@v2
@@ -76,24 +78,31 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-maven-
- # step 6.1
- - name: "Test, Check PMD, Check license with Maven and Java8"
+ # step 6.1:Support GitHub Actions, local shell
+ - name: Checkstyle
+ run: |
+ GITHUB_BASE_REF=${GITHUB_BASE_REF:-2.x}
+ echo "GITHUB_BASE_REF: $GITHUB_BASE_REF"
+ if [ "$GITHUB_ACTIONS" = "true" ]; then
+ PR_HEAD_SHA="${{ github.event.pull_request.head.sha }}"
+ else
+ PR_HEAD_SHA=""
+ fi
+ HEAD_SHA=${PR_HEAD_SHA:-HEAD}
+ echo "Pull Request Head SHA: $HEAD_SHA"
+ export CHANGED_FILES=$(git diff --name-only --diff-filter=AM
origin/$GITHUB_BASE_REF...$HEAD_SHA)
+ echo "CHANGED_FILES: $CHANGED_FILES"
+ export CHECKSTYLE_INCLUDES=$(echo "$CHANGED_FILES" | grep '\.java$'
| sed -e 's#.*src/main/java/##g' -e 's#.*src/test/java/##g' | tr '\n' ',')
+ echo "CHECKSTYLE_INCLUDES: $CHECKSTYLE_INCLUDES"
+ mvn -T 4C -e -B clean checkstyle:check -Dcheckstyle.skip=false
-Dcheckstyle.includes=$CHECKSTYLE_INCLUDES
+ # step 6.2
+ - name: "Test, Check license with Maven and Java8"
if: matrix.java == '8'
run: |
./mvnw -T 4C clean test \
- -Dpmd.skip=false -Dlicense.skip=false -DredisCaseEnabled=true
-DnacosCaseEnabled=true \
- -e -B \
-
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
\
- -Dorg.slf4j.simpleLogger.log.net.sourceforge.pmd=info \
- 2>&1 | tee build.log | while read line; do
- echo "$line"
- if [[ "$line" == *"PMD Failure"* ]]; then
- echo "::error::PMD Violations Detected! Check Details
Above!"
- fi
- done
- exit_code=${PIPESTATUS[0]}
- exit $exit_code
- # step 6.2
+ -Dlicense.skip=false -DredisCaseEnabled=true
-DnacosCaseEnabled=true \
+ -e -B
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
+ # step 6.3
- name: "Test with Maven and Java${{ matrix.java }}"
if: matrix.java != '8'
run: |
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..02ea02f699
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,68 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SHELL := /usr/bin/env bash
+
+.PHONY: help
+.DEFAULT_GOAL := help
+
+help: ## Show help information
+ @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf
"\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
+
+# Prefer using mvn, fall back to ./mvnw if mvn does not exist
+MVN ?= $(shell command -v mvn >/dev/null 2>&1 && echo "mvn" || echo "./mvnw")
+MAVEN_ARGS ?= -T 4C -e -B -V
+
+.PHONY: clean checkstyle checkstyle-diff license test package-only package
+
+clean: ## Clean the project
+ $(MVN) $(MAVEN_ARGS) clean
+
+checkstyle: ## Run global Checkstyle code check
+ $(MVN) $(MAVEN_ARGS) clean checkstyle:check -Dcheckstyle.skip=false
+
+checkstyle-diff: ## Run Checkstyle code check only on changed .java files
+ BASE_REF="$${GITHUB_BASE_REF:-2.x}"; \
+ echo "BASE_REF: $${BASE_REF}"; \
+ HEAD_SHA="$${PR_HEAD_SHA:-HEAD}"; \
+ echo "HEAD_SHA: $${HEAD_SHA}"; \
+ if git show-ref --quiet "refs/remotes/origin/$${BASE_REF}"; then \
+ DIFF_RANGE="origin/$${BASE_REF}...$${HEAD_SHA}"; \
+ else \
+ DIFF_RANGE="$${BASE_REF}...$${HEAD_SHA}"; \
+ fi; \
+ echo "DIFF_RANGE: $${DIFF_RANGE}"; \
+ CHANGED_FILES="$$(git diff --name-only --diff-filter=AM
"$${DIFF_RANGE}" || true)"; \
+ echo "CHANGED_FILES: $${CHANGED_FILES}"; \
+ CHECKSTYLE_INCLUDES="$$(echo "$${CHANGED_FILES}" | grep -E '\.java$$'
|| true)"; \
+ CHECKSTYLE_INCLUDES="$$(echo "$${CHECKSTYLE_INCLUDES}" | sed -e
's#.*src/main/java/##g' -e 's#.*src/test/java/##g' | tr '\n' ',' )"; \
+ echo "CHECKSTYLE_INCLUDES: $${CHECKSTYLE_INCLUDES}"; \
+ if [ -z "$${CHECKSTYLE_INCLUDES//,/}" ]; then \
+ echo "No changed .java files detected, skip checkstyle."; \
+ exit 0; \
+ fi; \
+ $(MVN) $(MAVEN_ARGS) clean checkstyle:check -Dcheckstyle.skip=false
-Dcheckstyle.includes="$${CHECKSTYLE_INCLUDES}"
+
+license: ## Run license check
+ $(MVN) $(MAVEN_ARGS) clean -Dlicense.skip=false
+
+test: ## Run unit tests
+ $(MVN) $(MAVEN_ARGS) clean test
+
+package-only: ## Package the project without running tests
+ $(MVN) $(MAVEN_ARGS) clean package -DskipTests
+
+package: ## Package the project
+ $(MVN) $(MAVEN_ARGS) clean package
diff --git a/build/pom.xml b/build/pom.xml
index 1a58afd729..4f9af62139 100644
--- a/build/pom.xml
+++ b/build/pom.xml
@@ -103,12 +103,10 @@
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
<kotlin-maven-plugin.version>2.2.20</kotlin-maven-plugin.version>
<!-- Check -->
- <maven-pmd-plugin.version>3.8</maven-pmd-plugin.version>
- <p3c-pmd.version>1.3.6</p3c-pmd.version>
<maven-javadoc-plugin.version>3.0.0</maven-javadoc-plugin.version>
<license-maven-plugin.version>4.0</license-maven-plugin.version>
<mojo-license-maven-plugin.version>1.20</mojo-license-maven-plugin.version>
-
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
+
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
<spotless-maven-plugin.version>2.44.3</spotless-maven-plugin.version>
<palantirJavaFormat.version>2.38.0</palantirJavaFormat.version>
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
@@ -137,7 +135,6 @@
<!-- Default values of the Maven plugins -->
<checkstyle.skip>true</checkstyle.skip>
<license.skip>true</license.skip>
- <pmd.skip>true</pmd.skip>
<maven.test.skip>false</maven.test.skip>
<maven.git-commit-id.skip>true</maven.git-commit-id.skip>
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 5340332485..50415b22f4 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -59,6 +59,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#8031](https://github.com/apache/incubator-seata/pull/8031)] upgrade some
dependencies versions
- [[#8030](https://github.com/apache/incubator-seata/pull/8030)] add the
dependency jackson-datatype-jsr310
- [[#8043](https://github.com/apache/incubator-seata/pull/8043)] simplify
jackson related dependencies
+- [[#8057](https://github.com/apache/incubator-seata/pull/8057)] remove p3c,
use maven-checkstyle-plugin, only check PR changes
- [[#8063](https://github.com/apache/incubator-seata/pull/8063)] bump
commons-io:commons-io from 2.8.0 to 2.21.0
- [[#8064](https://github.com/apache/incubator-seata/pull/8064)] bump
org.apache.kafka:kafka-clients from 3.6.1 to 3.9.2
- [[#8069](https://github.com/apache/incubator-seata/pull/8069)] bump
org.assertj:assertj-core from 3.12.2 to 3.27.7
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 95f1bc729a..1f0eff234e 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -60,6 +60,7 @@
- [[#8031](https://github.com/apache/incubator-seata/pull/8031)] 升级一些依赖版本
- [[#8030](https://github.com/apache/incubator-seata/pull/8030)] 添加依赖
jackson-datatype-jsr310
- [[#8043](https://github.com/apache/incubator-seata/pull/8043)] 简化 jackson
相关依赖
+- [[#8057](https://github.com/apache/incubator-seata/pull/8057)] 删除 p3c, 使用
maven-checkstyle-plugin, 仅检查 PR 变更
- [[#8063](https://github.com/apache/incubator-seata/pull/8063)] 将
commons-io:commons-io 从 2.8.0 版本升级到 2.21.0 版本
- [[#8064](https://github.com/apache/incubator-seata/pull/8064)] 将
org.apache.kafka:kafka-clients 从 3.6.1 版本升级到 3.9.2 版本
- [[#8069](https://github.com/apache/incubator-seata/pull/8069)] 将
org.assertj:assertj-core 从 3.12.2 版本升级到 3.27.7
diff --git a/common/src/main/resources/error/ErrorCode_en.properties
b/common/src/main/resources/error/ErrorCode_en.properties
index 9019ccd185..13ec748d84 100644
--- a/common/src/main/resources/error/ErrorCode_en.properties
+++ b/common/src/main/resources/error/ErrorCode_en.properties
@@ -18,4 +18,4 @@
ERR_PREFIX=ERR-CODE: [Seata-{code}][{key}]
ERR_POSTFIX=More: [https://seata.apache.org/docs/next/overview/faq#{code}]
ERR_CONFIG=config error, {0}
-ERR_DESERIALIZATION_SECURITY=deserialization security error, {0}
\ No newline at end of file
+ERR_DESERIALIZATION_SECURITY=deserialization security error, {0}
diff --git a/common/src/test/resources/error/ErrorCode_en.properties
b/common/src/test/resources/error/ErrorCode_en.properties
index 24a44239e4..e448dc5935 100644
--- a/common/src/test/resources/error/ErrorCode_en.properties
+++ b/common/src/test/resources/error/ErrorCode_en.properties
@@ -21,4 +21,4 @@ ERR_CONFIG=config error, {0}
ERR_NOT_EXIST=
ERROR_LOOP=ERROR_LOOP
ERR_NEST1=ERR NEST TEST
-ERR_NEST2=ERR_NEST1
\ No newline at end of file
+ERR_NEST2=ERR_NEST1
diff --git
a/config/seata-config-apollo/src/test/resources/mock-application.properties
b/config/seata-config-apollo/src/test/resources/mock-application.properties
index 9beea77cc5..12044a1359 100644
--- a/config/seata-config-apollo/src/test/resources/mock-application.properties
+++ b/config/seata-config-apollo/src/test/resources/mock-application.properties
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-seata.test=mockdata
\ No newline at end of file
+seata.test=mockdata
diff --git
a/console/src/main/java/org/apache/seata/mcp/core/utils/UrlUtils.java
b/console/src/main/java/org/apache/seata/mcp/core/utils/UrlUtils.java
index 44345f9387..6820c8f906 100644
--- a/console/src/main/java/org/apache/seata/mcp/core/utils/UrlUtils.java
+++ b/console/src/main/java/org/apache/seata/mcp/core/utils/UrlUtils.java
@@ -28,7 +28,7 @@ import java.util.Map;
public class UrlUtils {
- private static final Logger logger =
LoggerFactory.getLogger(UrlUtils.class);
+ private static final Logger LOGGER =
LoggerFactory.getLogger(UrlUtils.class);
public static String buildUrl(
String baseUrl, String path, Map<String, String>
queryStringParams, Map<String, Object> queryObjectParams) {
@@ -81,7 +81,7 @@ public class UrlUtils {
try {
return objectMapper.convertValue(obj, new
TypeReference<Map<String, Object>>() {});
} catch (IllegalArgumentException e) {
- logger.warn("Failed to convert object to map: {}", e.getMessage());
+ LOGGER.warn("Failed to convert object to map: {}", e.getMessage());
return Collections.emptyMap();
}
}
diff --git a/core/src/main/log4j.properties b/core/src/main/log4j.properties
index 3d4ab4dba7..72a42ddaf2 100644
--- a/core/src/main/log4j.properties
+++ b/core/src/main/log4j.properties
@@ -17,16 +17,16 @@
log4j.rootCategory=info,R
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.Threshold=info
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=- %m%n
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.Threshold=info
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=- %m%n
-log4j.appender.R=org.apache.log4j.RollingFileAppender
-log4j.appender.R.Append=true
-log4j.appender.R.Threshold=info
-log4j.appender.R.MaxFileSize=102400KB
-log4j.appender.R.MaxBackupIndex=10
-log4j.appender.R.File=${WORKDIR}/logs/biz.log
-log4j.appender.R.layout=org.apache.log4j.PatternLayout
-log4j.appender.R.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p]
%m%n
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.Append=true
+log4j.appender.R.Threshold=info
+log4j.appender.R.MaxFileSize=102400KB
+log4j.appender.R.MaxBackupIndex=10
+log4j.appender.R.File=${WORKDIR}/logs/biz.log
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%c]-[%p]
%m%n
diff --git a/pom.xml b/pom.xml
index e9d1a1cd10..2e8307d52e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -399,51 +399,27 @@
</execution>
</executions>
</plugin>
- <!-- PMD-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <version>${maven-pmd-plugin.version}</version>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${maven-checkstyle-plugin.version}</version>
<configuration>
-
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
- <minimumPriority>2</minimumPriority>
- <printFailingErrors>true</printFailingErrors>
- <rulesets>
- <ruleset>rulesets/java/ali-comment.xml</ruleset>
- <ruleset>rulesets/java/ali-concurrent.xml</ruleset>
- <ruleset>rulesets/java/ali-constant.xml</ruleset>
- <ruleset>rulesets/java/ali-exception.xml</ruleset>
- <ruleset>rulesets/java/ali-flowcontrol.xml</ruleset>
- <ruleset>rulesets/java/ali-naming.xml</ruleset>
- <ruleset>rulesets/java/ali-oop.xml</ruleset>
- <ruleset>rulesets/java/ali-orm.xml</ruleset>
- <ruleset>rulesets/java/ali-other.xml</ruleset>
- <ruleset>rulesets/java/ali-set.xml</ruleset>
- </rulesets>
- <excludes>
- <exclude>**/generated/*.java</exclude>
- <exclude>**/antlr/mysql/parser/*.*</exclude>
- <exclude>**/antlr/mysql/antlr/*.*</exclude>
-
<exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
- </excludes>
+ <configLocation>style/checkstyle.xml</configLocation>
+ <consoleOutput>true</consoleOutput>
+ <detail>true</detail>
+ <skip>${checkstyle.skip}</skip>
</configuration>
<executions>
<execution>
- <id>pmd-check</id>
- <phase>validate</phase>
+ <id>verify-style</id>
+ <phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
- <dependencies>
- <dependency>
- <groupId>com.alibaba.p3c</groupId>
- <artifactId>p3c-pmd</artifactId>
- <version>${p3c-pmd.version}</version>
- </dependency>
- </dependencies>
</plugin>
+
<!-- JaCoCo -->
<plugin>
<groupId>org.jacoco</groupId>
diff --git a/server/src/test/resources/application.properties
b/server/src/test/resources/application.properties
index b7fec4d62d..21abc297a6 100644
--- a/server/src/test/resources/application.properties
+++ b/server/src/test/resources/application.properties
@@ -23,4 +23,4 @@ seata.metrics.registry-type=compact
seata.registry.namingserver.server-addr=127.0.0.1:8081
seata.registry.namingserver.namespace=public
seata.registry.namingserver.heartbeat-period=5000
-seata.server.http.filter.xss.keywords=["custom1", "custom2"]
\ No newline at end of file
+seata.server.http.filter.xss.keywords=["custom1", "custom2"]
diff --git a/style/checkstyle.xml b/style/checkstyle.xml
new file mode 100644
index 0000000000..cb1c311031
--- /dev/null
+++ b/style/checkstyle.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+ "https://checkstyle.org/dtds/configuration_1_3.dtd">
+<module name="Checker">
+ <module name="SuppressionSingleFilter">
+ <property name="checks" value="ConstantName"/>
+ <property name="files" value="MySqlParser\.java$"/>
+ </module>
+ <module name="SuppressionSingleFilter">
+ <property name="checks" value="MissingSwitchDefault"/>
+ <property name="files" value="MySqlParser\.java$"/>
+ </module>
+ <module name="SuppressionSingleFilter">
+ <property name="checks" value="MethodName"/>
+ <property name="files" value="MySqlParser\.java$"/>
+ </module>
+ <module name="SuppressionSingleFilter">
+ <property name="checks" value="ParameterName"/>
+ <property name="files" value="MySqlParser\.java$"/>
+ </module>
+ <module name="SuppressionSingleFilter">
+ <property name="checks" value="NeedBraces"/>
+ <property name="files" value="MySqlParser\.java$"/>
+ </module>
+ <module name="SuppressionSingleFilter">
+ <property name="checks" value="LocalVariableName"/>
+ <property name="files" value="MySqlParser\.java$"/>
+ </module>
+ <module name="SuppressionSingleFilter">
+ <property name="checks" value="ConstantName"/>
+ <property name="files" value="MySqlLexer\.java$"/>
+ </module>
+
+ <!-- Allow using @SuppressWarnings("checkstyle:...") in code -->
+ <module name="SuppressWarningsFilter"/>
+
+ <module name="TreeWalker">
+ <module name="SuppressWarningsHolder"/>
+
+ <!-- Naming -->
+ <module name="TypeName"/>
+ <module name="AbstractClassName">
+ <property name="format"
+
value="^(Abstract(?!LockStoreSql$|IdentifyResponseCodecV2$|Store$|NettyRemotingInstrumentation$).+|Base(?!Param$|DistributedLockSqlServer$|DistributedLockSql$).+)$"/>
+ </module>
+ <module name="ConstantName"/>
+ <module name="MemberName"/>
+ <module name="LocalVariableName"/>
+ <module name="ParameterName"/>
+ <module name="MethodName"/>
+ <module name="PackageName"/>
+ <module name="ArrayTypeStyle"/>
+
+ <!-- OOP -->
+ <module name="EqualsAvoidNull"/>
+
+ <!-- Flow Control -->
+ <module name="FallThrough"/>
+ <module name="MissingSwitchDefault"/>
+ <module name="NeedBraces"/>
+ <module name="EmptyBlock"/>
+
+ <!-- Constant -->
+ <module name="UpperEll"/>
+ </module>
+</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]