ongdisheng commented on issue #578:
URL: https://github.com/apache/fesod/issues/578#issuecomment-3561936899

   > ## Proposal
   > Currently, we are using 
[palantir-java-format](https://github.com/palantir/palantir-java-format), but 
recently I have become a bit concerned. From the repository's situation, it 
seems that it is not being maintained very well. It is based on the excellent 
[google-java-format](https://github.com/google/google-java-format).
   > 
   > I have looked into the usage of spotless in some other ASF projects. I 
believe we can use `google-java-format` or `eclipse jdt` instead.
   > 
   > It seems that `google-java-format` is not very friendly towards lambda 
expressions, and `eclipse jdt` offers more flexible settings. I think using 
`eclipse jdt` is a suitable choice.
   > 
   > ## Reference
   > * [shardingsphere 
blog](https://shardingsphere.apache.org/blog/cn/material/spotless/)
   > * 
[shardingsphere](https://github.com/apache/shardingsphere/blob/master/src/resources/spotless/java.xml)
   > * 
[spotless_streampark_formatter.xml](https://github.com/apache/streampark/blob/dev/tools/checkstyle/spotless_streampark_formatter.xml)
   > * 
[eventmesh-spotless-formatter.xml](https://github.com/apache/eventmesh/blob/master/style/task/eventmesh-spotless-formatter.xml)
   > * 
[spotless_inlong_formatter.xml](https://github.com/apache/inlong/blob/master/codestyle/spotless_inlong_formatter.xml)
   
   Hi @Delei, I gave the Eclipse JDT formatter a try and got it working. Here's 
what I did: 
   
   1. Created `tools/spotless/fesod-formatter.xml`:
   ```xml
   <profiles version="13">
       <profile kind="CodeFormatterProfile" name="'Fesod Apache Current'" 
version="13">
           <setting id="org.eclipse.jdt.core.compiler.source" value="1.8" />
           <setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8" />
           <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120" />
           <setting id="org.eclipse.jdt.core.formatter.tabulation.size" 
value="4" />
           <setting 
id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1" />
           <setting 
id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration"
 value="106" />
           <!-- ... additional settings -->
       </profile>
   </profiles>
   ```
   
   2. Updated `pom.xml` by switching from Palantir to Eclipse JDT:
   ```xml
   <java>
       <eclipse>
           <file>tools/spotless/fesod-formatter.xml</file>
       </eclipse>
       <licenseHeader>
           <file>tools/spotless/license-header.txt</file>
           <delimiter>package |import |module </delimiter>
       </licenseHeader>
       <importOrder>
           <order>\#|</order>
       </importOrder>
       <removeUnusedImports/>
       <trimTrailingWhitespace/>
       <endWithNewline/>
   </java>
   ```
   
   The formatter is working where `spotless:check` manages to detect files that 
need reformatting. I'm more than happy to submit a PR for this if you'd like.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to