com-lihaoyi / mill

Mill is a fast JVM build tool that supports Java and Scala. 2-4x faster than Gradle and 5-10x faster than Maven for common workflows, Mill aims to make your project’s build process performant, maintainable, and flexible
https://mill-build.org/
MIT License
2.17k stars 343 forks source link

Support Palantir-Java-Format for Java (500USD Bounty) #3448

Closed lihaoyi closed 1 month ago

lihaoyi commented 2 months ago

From the maintainer Li Haoyi: I'm putting a 500USD bounty on this issue, payable by bank transfer on a merged PR implementing this.


Palantir-Java-Format is a common Java autoformatter, and we should support it as a contrib/ module to better support Java projects. We should support all common configuration options to allow usage on JavaModules and ScalaModules (which can contain Java sources). It should broadly work the same way ScalaFmt works for Scala (https://mill-build.org/mill/0.11.12/Scala_Module_Config.html#_reformatting_your_code) This needs to come with a reasonable set of unit tests, docs, and at least one example test that can be included in the documentation.

May be able to adapt something from https://github.com/sbt/sbt-java-formatter

lefou commented 2 months ago

I'd prefer palantir, either directly or via spotless, which could provide a lot of other formatters too.

lihaoyi commented 2 months ago

Sure! Maybe it should be via spotless then?

lihaoyi commented 2 months ago

Let's go with palantir-java-format for now. At a glance Spotless seems a lot more heavyweight, and maybe can come in a follow up, but palantir-java-format should suit the immediate need of "we need a java formatter" and hopefully be easier to implement

lefou commented 2 months ago

I experiemented with it in the past but got some class access issues due to not using the module classloader. So, if you're a Scala dev not so deep into Java, expect some difficulties.

lihaoyi commented 2 months ago

yeah I assume there'll be stumbling blocks but I assume they'll be work-around-able. If it can work in eclipse/intellij/gradle/spotless it should be doable inside Mill; worst come to worst we can run it in a separate subprocess. But that's for whoever picks up the bounty to figure out!