-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert scalafmt integration to use a compile-only sourceset #1283
Convert scalafmt integration to use a compile-only sourceset #1283
Conversation
mdedetrich
commented
Aug 22, 2022
•
edited
Loading
edited
- Convert scalafmt integration to use a compile-only sourceset (Use custom source sets and compile-only dependencies instead of reflection #524)
- Just like other PRs that convert from reflection to using a compile-only source set, this PR also removes code related to old versions of Scalafmt. This is also necessary due to the fact that scalafmt's API is completely different from major versions so spotless wouldn't even work with scalafmt versions older than 3.
- Possible solution to Force scalaVersion when using scala scalafmt extension #1273 (still need to test)
fcb77ca
to
848061e
Compare
testlib/src/test/java/com/diffplug/spotless/scala/ScalaFmtStepTest.java
Outdated
Show resolved
Hide resolved
public String apply(String input) throws Exception { | ||
ScalafmtConfig config; | ||
if (configSignature.files().isEmpty()) { | ||
// Note that reflection is used here only because Scalafmt has a method called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way around this may be that instead of defining ScalafmtFormatterFunc
as a Java source file, instead we can define it as a Scala source file (which with a basic class Java has no issues calling). Not sure if this is possible or even desirable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be okay putting Scala into our codebase if it was really useful for some task, but this is small enough that I'd prefer the reflection. Note the little refactor I did in a75877c.
ea185c5
to
d0e5667
Compare
d0e5667
to
966f33d
Compare
966f33d
to
781eb68
Compare
lib/src/scalafmt/java/com/diffplug/spotless/glue/scalafmt/ScalafmtFormatterFunc.java
Show resolved
Hide resolved
lib/src/main/java/com/diffplug/spotless/scala/ScalaFmtStep.java
Outdated
Show resolved
Hide resolved
NBD, but please push new commits instead of force-pushing. Easier to review only what has changed that way :) |
Also thanks for this very good PR, it will definitely get merged :D |
So I just added a commit which implements the |
plugin-gradle/src/main/java/com/diffplug/gradle/spotless/ScalaExtension.java
Show resolved
Hide resolved
CI is passing now, forgot about the newly formatted files and accidentally deleted a line which I didn't realize. |
Just pushed some commits regarding updates/changes in the documentation. |
…lved in serialization/equality, so good to eagerly initialize in the constructor.
Perfect, happy with the commit message so feel free to merge and thanks for being responsive on the PR! |
Published in |