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-unsubscr...@seata.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to