[Geoserver-devel] Switching to Spotless for Java formatting, status and request for help

Hi all,
as discussed in the PSC meetings and follow up mails, I’ve been playing with
Spotless to replace the dying COVEO formatting plugin.

Here is a test PR:
https://github.com/geotools/geotools/pull/3761

Highlights:

  • Uses Spotless for Java formatting, and uses the latest google-java-format plugin compatible with Java 8 (with improved formatting for streams and annotations)
  • Uses up-to-date checking to avoid re-formatting files for nothing
  • The up-to-date file index is kept in a hidden file in each module, “.spotless-index”. On linux that’s invisible by default. The files are in gitignore so they won’t be committed.
    Using spotless, we’ll be eventually able to also format with other formatters in the future, like the Eclipse one for XML/HTML for example.

Can people on different platforms try that out and tell me how that works for them? Try running:

mvn spotless:apply -nsu -Dall

Expect a few messages from spotless on the first run, while it’s creating the index files, and then it should be real fast from the second run onwards.
Github actions won’t get a speedup unless we find a way to cache the index files… not sure that we want to do that honestly (might be
complicated to setup and maintain, on a per branch basis…)

Cheers
Andrea

On Sunday, 30 January 2022 5:02:31 AM AEDT Andrea Aime wrote:

mvn spotless:apply -nsu -Dall

I tried it on linux. This command works OK, unsurprisingly.

Looks like there were a couple of spots you missed in dealing with the old
coveo based formatter. See PR against your branch.

For novelty, I also tried it on a Windows 11 VM with netbeans. It was a bit
messy to do within the IDE, but I think it ran OK. It worked fine on the
command line (once I found maven).

Test configuration:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: c:\Program Files\NetBeans-12.6\netbeans\java\maven\bin\..
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Program Files\Eclipse
Adoptium\jdk-8.0.312.7-hotspot\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

openjdk version "1.8.0_312"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (Temurin)(build 25.312-b07, mixed mode)

mvn spotless:apply -nsu -Dall

I tried it on linux. This command works OK, unsurprisingly.

Looks like there were a couple of spots you missed in dealing with the old
coveo based formatter. See PR against your branch.

Thanks, issues noted, I’ll try to address them in the upcoming weekends.

For novelty, I also tried it on a Windows 11 VM with netbeans. It was a bit
messy to do within the IDE, but I think it ran OK. It worked fine on the
command line (once I found maven).

Great, thanks for testing!
Do we have anyone on OSX?

Cheers
Andrea

···

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 333 8128928

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Hi,

I tried it on Mac OSX. No issues and no code changes.

mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /usr/local/Cellar/maven/3.8.4/libexec
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre
Default locale: nb_NO, platform encoding: UTF-8
OS name: “mac os x”, version: “10.16”, arch: “x86_64”, family: “mac”

Best regards,

Roar Brænden

···

==
GeoServer Professional Services from the experts!
Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 333 8128928

https://www.geosolutionsgroup.com/
http://twitter.com/geosolutions_it

Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Thanks! (no code changes expected indeed, I did run a reformat before pushing the branch).

Cheers
Andrea

···

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 333 8128928

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail