You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "YongGoose (via GitHub)" <gi...@apache.org> on 2025/03/15 15:10:08 UTC
[PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
YongGoose opened a new pull request, #7223:
URL: https://github.com/apache/incubator-seata/pull/7223
**I haven't applied Spotless to the code yet.
I'll implement the Spotless configuration first and apply it afterward.**
### **🔹 Key Changes:**
- **Configured Spotless Maven Plugin** to automatically format Java files using **Palantir Java Format**.
- **JDK version-based profile activation:**
- JDK **8 to <11** → Uses `palantirJavaFormat.version = 1.1.0`
- JDK **11 to <21** → Uses `palantirJavaFormat.version = 2.28.0`
- JDK **21+** → Uses `palantirJavaFormat.version = 2.39.0`
- **Excluded specific directories/files** from formatting:
- `script/`, `generated/`, `antlr/mysql/parser/`, `antlr/mysql/antlr/`, etc.
- **Integrated with Maven’s `process-sources` phase**, ensuring formatting is applied during builds.
- **Enabled unused import removal, trailing whitespace trimming, and newline enforcement at EOF.**
### **🔹 How to Verify:**
1️⃣ Run **Maven build** to ensure Spotless is applied automatically:
```sh
mvn clean install
```
2️⃣ Manually apply formatting with:
```sh
mvn spotless:apply
```
3️⃣ Verify excluded directories remain unchanged.
### Screen shots


--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2727373271
@YongGoose Can Spotless only work on the change files instead of all files?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2020350043
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
@funky-eyes
After reviewing the suggested approach, I found that in Dubbo, the GitHub Actions workflow checks the code style and prompts the user to apply Spotless if any issues are detected.
```
run: |
echo "## :negative_squared_cross_mark: Formatting issues found!" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cat mvn.log | grep "ERROR" | sed 's/Check if code needs formatting Check if code aligns with code style [0-9A-Z:.-]\+//' | sed 's/\[ERROR] //' | head -n -11 >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "Please run \`mvn spotless:apply\` to fix the formatting issues." >> $GITHUB_STEP_SUMMARY
```
However, this approach would not work in our current implementation.
The reason is that for the workflow to run, the user must first commit and push their changes, triggering the workflow.
But in our case, Spotless is applied only to the changes from the `latest commit` (`HEAD`).
- https://javadoc.io/doc/org.eclipse.jgit/org.eclipse.jgit/5.6.1.202002131546-r/org/eclipse/jgit/lib/Repository.html#resolve-java.lang.String-
As a result, even if the workflow instructs the user to run Spotless, the problematic code has already been committed, meaning it falls outside Spotless's scope.
To resolve this issue, we either need to remove the scope limitation of Spotless or find an alternative approach.
https://github.com/diffplug/spotless/blob/main/plugin-maven/README.md#how-can-i-enforce-formatting-gradually-aka-ratchet
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2727374916
## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/7223?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 53.61%. Comparing base [(`e0dc0c3`)](https://app.codecov.io/gh/apache/incubator-seata/commit/e0dc0c379fab845d0685565ca543427f193578d0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`73b865c`)](https://app.codecov.io/gh/apache/incubator-seata/commit/73b865c6d48285197146c98ca375ffde05b13040?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/incubator-seata/pull/7223?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## 2.x #7223 +/- ##
============================================
- Coverage 53.62% 53.61% -0.01%
+ Complexity 7130 7129 -1
============================================
Files 1171 1171
Lines 41619 41619
Branches 4877 4877
============================================
- Hits 22319 22315 -4
- Misses 17191 17196 +5
+ Partials 2109 2108 -1
```
[see 5 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/7223/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary>🚀 New features to boost your workflow: </summary>
- ❄ [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- 📦 [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2020496217
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
In this commit https://github.com/apache/incubator-seata/pull/7223/commits/4f07580b4988f7012b7d4c455d3dfacc51dabfb1 i changed ratchet from to origin/2.x
Then below error occured.
```
Error: Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.44.3:apply (default) on project seata-parent: Execution default of goal com.diffplug.spotless:spotless-maven-plugin:2.44.3:apply failed: No such reference 'origin/2.x' -> [Help 1]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2036742095
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
+ <palantirJavaFormat>
+ <version>${palantirJavaFormat.version}</version>
+ </palantirJavaFormat>
+ <removeUnusedImports/>
+ <trimTrailingWhitespace/>
+ <endWithNewline/>
+ </java>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
Review Comment:
This doesn't work in GitHub Actions.
Automatically formatting and committing changes seems more suitable for a `git hook`, which would require users to modify their local `.git` folder.
For now, in this PR, I’ve applied `Spotless`.
I’m planning to explore additional improvements in a separate PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "xingfudeshi (via GitHub)" <gi...@apache.org>.
xingfudeshi commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2758923788
> > > It would be great if this can be achieved, but when I run the mvn spotless:apply command locally, how can I ensure that only the files I have modified are formatted?
>
> >
>
> > I believe it can be done by using the `git diff` feature with `pre-commit` hook. I haven’t actually implemented it yet, but it does seem feasible.
>
> >
>
> > * https://github.com/diffplug/spotless/tree/main/plugin-maven#how-do-i-preview-what-mvn-spotlessapply-will-do
>
>
>
> Ok, I hope this solution is feasible. If it's not, I don't mind modifying all the files; I don't think it will have too much of an impact.
I agree your point .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2015887179
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
Hi @YongGoose ,

I noticed that the constructor is formatted like this after formatting. I still prefer the format shown in the image below. Is there a way to adjust it?

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2020350043
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
@funky-eyes
After reviewing the suggested approach, I found that in Dubbo, the GitHub Actions workflow checks the code style and prompts the user to apply Spotless if any issues are detected.
```
run: |
echo "## :negative_squared_cross_mark: Formatting issues found!" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cat mvn.log | grep "ERROR" | sed 's/Check if code needs formatting Check if code aligns with code style [0-9A-Z:.-]\+//' | sed 's/\[ERROR] //' | head -n -11 >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "Please run \`mvn spotless:apply\` to fix the formatting issues." >> $GITHUB_STEP_SUMMARY
```
However, this approach would not work in our current implementation.
The reason is that for the workflow to run, the user must first commit and push their changes, triggering the workflow.
But in our case, Spotless is applied only to the changes from the `latest commit` (`HEAD`).
As a result, even if the workflow instructs the user to run Spotless, the problematic code has already been committed, meaning it falls outside Spotless's scope.
To resolve this issue, we either need to remove the scope limitation of Spotless or find an alternative approach.
https://github.com/diffplug/spotless/blob/main/plugin-maven/README.md#how-can-i-enforce-formatting-gradually-aka-ratchet
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2020469618
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
Still, I think setting it to `2.x` is a better approach than setting it to `HEAD`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2739357176
> It would be great if this can be achieved, but when I run the mvn spotless:apply command locally, how can I ensure that only the files I have modified are formatted?
I believe it can be done by using the git diff feature.
I haven’t actually implemented it yet, but it does seem feasible.
- https://github.com/diffplug/spotless/tree/main/plugin-maven#how-do-i-preview-what-mvn-spotlessapply-will-do
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2020508462
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
I noticed that after setting it to 2.x, the number of changed files is quite large, unless we are willing to accept changes to all files. Otherwise, I think we can initially set it to HEAD, merge this PR, and then create an issue to discuss the remaining problems.
@slievrly What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2015910143
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
It seems challenging to apply that format solely to the constructor.
However, I believe we can set up some configurations based on commas.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2040662225
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
+ <palantirJavaFormat>
+ <version>${palantirJavaFormat.version}</version>
+ </palantirJavaFormat>
+ <removeUnusedImports/>
+ <trimTrailingWhitespace/>
+ <endWithNewline/>
+ </java>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
Review Comment:
ok.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2727376563
> @YongGoose Can Spotless only work on the change files instead of all files?
According to the link below, it seems possible using a Git pre-commit hook or `ratchetFrom`.
- https://github.com/diffplug/spotless/issues/178
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2739438126
> > It would be great if this can be achieved, but when I run the mvn spotless:apply command locally, how can I ensure that only the files I have modified are formatted?
>
> I believe it can be done by using the `git diff` feature with `pre-commit` hook. I haven’t actually implemented it yet, but it does seem feasible.
>
> * https://github.com/diffplug/spotless/tree/main/plugin-maven#how-do-i-preview-what-mvn-spotlessapply-will-do
Ok, I hope this solution is feasible. If it's not, I don't mind modifying all the files; I don't think it will have too much of an impact.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2015925979
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
Sure, I don't think this issue is a big deal. I believe we can merge this PR first and then make additional adjustments later. Also, when the CI detects that the code style doesn't meet expectations, can it prompt the user to run mvn spotless:apply locally? I recall that in the Dubbo community's CI workflow, such a prompt is provided when code style checks fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2020463870
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
In other words, unless we format and commit all the code at once, we will not be able to prompt the user to run `mvn spotless:apply`. What if we change the `HEAD` to `2.x`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "xingfudeshi (via GitHub)" <gi...@apache.org>.
xingfudeshi commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2006873393
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
> @funky-eyes
>
> Currently, our baseline is set to `HEAD`, which means that only files changed since the last commit are considered. This creates a potential issue: if code with incorrect formatting gets committed, `checkstyle` will catch it, but `Spotless` won’t apply its fixes, and we lose the intended benefit.
>
> To address this, we tried switching the baseline from HEAD to `origin/2.x`. However, the branch wasn’t recognized. 🥹
>
> What do you think?
Hi, I pulled your code and followed the steps. Seems to work!
```
1. git checkout feature/apply-spotless
2. Change the value of ratchetFrom from HEAD to feature/apply-spotless
3. Add some spaces in the method of Java class, like this
```
<img width="660" alt="image" src="https://github.com/user-attachments/assets/bc195e49-b489-48b2-9e21-73f261486dd1" />
```
4. mvn spotless:check
5. Then I got the outputs like this
```
<img width="1206" alt="image" src="https://github.com/user-attachments/assets/ad93a013-878f-4455-939e-b83e8f494c6b" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2005217848
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
@slievrly @funky-eyes @xingfudeshi
I configured `<ratchetFrom>HEAD</ratchetFrom>` so that only the modified files are formatted by comparing them with the currently checked-out commit (HEAD).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2727377845
> Can Spotless only work on the change files instead of all files?
No, Spotless can be applied to all files as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2006632551
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
@funky-eyes
Currently, our baseline is set to `HEAD`, which means that only files changed since the last commit are considered. This creates a potential issue: if code with incorrect formatting gets committed, `checkstyle` will catch it, but `Spotless` won’t apply its fixes, and we lose the intended benefit.
To address this, we tried switching the baseline from HEAD to `origin/2.x`. However, the branch wasn’t recognized. 🥹
What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2011139740
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
> @funky-eyes
>
> Currently, our baseline is set to `HEAD`, which means that only files changed since the last commit are considered. This creates a potential issue: if code with incorrect formatting gets committed, `checkstyle` will catch it, but `Spotless` won’t apply its fixes, and we lose the intended benefit.
>
> To address this, we tried switching the baseline from HEAD to `origin/2.x`. However, the branch wasn’t recognized. 🥹
>
> What do you think?
I think it can be done this way
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2005568123
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
> @slievrly @funky-eyes @xingfudeshi
>
> I configured `<ratchetFrom>HEAD</ratchetFrom>` so that only the modified files are formatted by comparing them with the currently checked-out commit (HEAD).
Good job! I will pull this PR to my local machine for related testing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2020467469
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
> What if we change the `HEAD` to `2.x`?
I think this approach is a good one.
However, when I tried running it locally, the behavior was different from what I expected, so I'm reconsidering it.
To explain in more detail, switching to `origin/2.x` should apply changes only to the files that have been modified from `2.x`.
Even though there were no changes in my local branch, some recently committed files in `2.x` were also modified.

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] optimize: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly merged PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2735487104
> I think this approach is very effective. Although it involves modifying many files, I believe as long as the CI passes, there won't be any significant issues. Even though it may conflict with other PRs, I think this cost is worthwhile.
Thank you for your comment!
However, after discussing with @slievrly on the mailing lists, we decided to apply spotless only to the modified files, so it looks like we won’t be modifying many files!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2735472732
I think this approach is very effective. Although it involves modifying many files, I believe as long as the CI passes, there won't be any significant issues. Even though it may conflict with other PRs, I think this cost is worthwhile.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2739037142
> > I think this approach is very effective. Although it involves modifying many files, I believe as long as the CI passes, there won't be any significant issues. Even though it may conflict with other PRs, I think this cost is worthwhile.
>
> Thank you for your comment!
>
> However, after discussing with @slievrly on the mailing lists, we decided to apply spotless only to the modified files, so it looks like we won’t be modifying many files!
>
> > Although there is the drawback that spotless won’t be applied to unmodified files, after weighing the trade-offs with the git history, we determined that it’s better to only modify the changed files.
It would be great if this can be achieved, but when I run the mvn spotless:apply command locally, how can I ensure that only the files I have modified are formatted?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "slievrly (via GitHub)" <gi...@apache.org>.
slievrly commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2033579095
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
+ <palantirJavaFormat>
+ <version>${palantirJavaFormat.version}</version>
+ </palantirJavaFormat>
+ <removeUnusedImports/>
+ <trimTrailingWhitespace/>
+ <endWithNewline/>
+ </java>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
Review Comment:
How it works in github action workflow, I didn't see this profile id included in workflow.In addition to checking if the format is as expected, is it possible to automatically format changes in the workflow and commit them to PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on code in PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#discussion_r2015956233
##########
pom.xml:
##########
@@ -289,6 +289,78 @@
</plugins>
</build>
</profile>
+
+ <!-- profile: spotless -->
+ <profile>
+ <id>jdk9-jdk11-spotless</id>
+ <activation>
+ <jdk>[1.8, 11)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>1.1.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk11-jdk21-spotless</id>
+ <activation>
+ <jdk>[11, 21)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.28.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>jdk21-spotless</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <properties>
+ <palantirJavaFormat.version>2.39.0</palantirJavaFormat.version>
+ </properties>
+ </profile>
+ <profile>
+ <id>java11+</id>
+ <activation>
+ <jdk>[11,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless-maven-plugin.version}</version>
+ <configuration>
+ <java>
+ <excludes>
+ <exclude>**/script/**</exclude>
+ <exclude>**/generated/**</exclude>
+ <exclude>**/antlr/mysql/parser/*.*</exclude>
+ <exclude>**/antlr/mysql/antlr/*.*</exclude>
+ <exclude>**/antlr/mysql/stream/ANTLRNoCaseStringStream.java</exclude>
+ </excludes>
+ <ratchetFrom>HEAD</ratchetFrom>
Review Comment:
I’ll take a look at Dubbo’s code to get a better understanding. It seems feasible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2727054910
@funky-eyes @xingfudeshi
What do you think? 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: Apply Spotless with Palantir Java Format [incubator-seata]
Posted by "YongGoose (via GitHub)" <gi...@apache.org>.
YongGoose commented on PR #7223:
URL: https://github.com/apache/incubator-seata/pull/7223#issuecomment-2727381229
There are several things we need to discuss ❗️
1. Should we use both `Spotless` and `Checkstyle`, or just Spotless?
2. Files that should be excluded from `Spotless` (currently, the same exclusions as `Checkstyle` have been applied).
3. When should Spotless be automatically applied (in CI process)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org