Skip to content
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

[SPARK-29293][BUILD] Move scalafmt to Scala 2.12 profile; bump to 0.12 #26655

Closed
wants to merge 3 commits into from

Conversation

srowen
Copy link
Member

@srowen srowen commented Nov 25, 2019

What changes were proposed in this pull request?

Move scalafmt to Scala 2.12 profile; bump to 0.12.

Why are the changes needed?

To facilitate a future Scala 2.13 build.

Does this PR introduce any user-facing change?

None.

How was this patch tested?

This isn't covered by tests, it's a convenience for contributors.

@srowen srowen self-assigned this Nov 25, 2019
@SparkQA
Copy link

SparkQA commented Nov 25, 2019

Test build #114363 has finished for PR 26655 at commit 05265bc.

  • This patch fails build dependency tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member Author

srowen commented Nov 25, 2019

The plugin changes the parameters used to skip formatting, so it failed because it tried to run scalafmt. That is easy enough to fix, both in fixing the parameter and also moving to pluginManagement; it shouldn't actually be used by default by the build.

But, this highlights another problem: scalafmt / plugin doesn't seem to work on the complex Spark code at this point: https://scalameta.org/scalafmt/docs/known-issues.html#deeply-nested-code . It will fail if you run it with the script.

So I'm also wondering whether we just yank this.

pom.xml Outdated
@@ -166,7 +166,6 @@
<commons.collections.version>3.2.2</commons.collections.version>
<scala.version>2.12.10</scala.version>
<scala.binary.version>2.12</scala.binary.version>
<scalafmt.parameters>--diff --test</scalafmt.parameters>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the problem. parameters is no longer available in the plugin. Without it, I think it formats all files and fails. I don't see a way to have the plugin not do this, hm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that sounds like a serious regression of scalafmt.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the plugin more than scalafmt. We could pursue a workaround, but maybe not worth it; I'm not sure how much this is used.

Really, the current state of this PR isn't great, as it no longer does anything useful. I'll need to either delete it or revert and move it behind a Scala 2.12 profile. Any opinion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the plugin more than scalafmt. We could pursue a workaround, but maybe not worth it; I'm not sure how much this is used.

Really, the current state of this PR isn't great, as it no longer does anything useful. I'll need to either delete it or revert and move it behind a Scala 2.12 profile. Any opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of trying to keep this functionality, since "nit: 4 spaces" is not a welcoming first experience for new contributors.

It looks like the plugin stopped using the cli interface to scalafmt, which is why parameters aren't accepted anymore. I've opened SimonJPegg/mvn_scalafmt#48 to see if the plugin author has any suggestions.

@srowen
Copy link
Member Author

srowen commented Nov 25, 2019

Another option is to leave this available only for the 2.12 build and revert this change, but I'm wondering if it's worth keeping anyway. Do devs use it?

@SparkQA
Copy link

SparkQA commented Nov 25, 2019

Test build #114366 has finished for PR 26655 at commit f13f51e.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

pom.xml Outdated
@@ -166,7 +166,6 @@
<commons.collections.version>3.2.2</commons.collections.version>
<scala.version>2.12.10</scala.version>
<scala.binary.version>2.12</scala.binary.version>
<scalafmt.parameters>--diff --test</scalafmt.parameters>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of trying to keep this functionality, since "nit: 4 spaces" is not a welcoming first experience for new contributors.

It looks like the plugin stopped using the cli interface to scalafmt, which is why parameters aren't accepted anymore. I've opened SimonJPegg/mvn_scalafmt#48 to see if the plugin author has any suggestions.

dev/scalafmt Outdated
params="${@:---diff}"

./build/mvn mvn-scalafmt_2.12:format -Dscalafmt.skip=false -Dscalafmt.parameters="$params"
./build/mvn mvn-scalafmt_2.12:format -Dscalafmt.skip=false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we figure out what's up with parameters, this would need to be either scalafmt_2.12 or scalafmt_2.13 accordingly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, right, noticed that one too. I will instead change this to put the older version of the plugin under the scala-2.12 profile, to get it out of the way of the 2.13 build, for now. If the plugin further updates, we can use this approach here.

@srowen
Copy link
Member Author

srowen commented Nov 25, 2019

I updated to just:

  • Move scalafmt under the 2.12 profile
  • Move it to pluginManagement for good measure (still works)
  • Add the extra skip configs that version 1.x wants, before I forget
  • Manually tested that it does reformat, and only files in the current changelist

@SparkQA
Copy link

SparkQA commented Nov 25, 2019

Test build #114422 has finished for PR 26655 at commit 9142562.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member

Retest this please

pom.xml Show resolved Hide resolved
@SparkQA
Copy link

SparkQA commented Nov 26, 2019

Test build #114456 has finished for PR 26655 at commit 9142562.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen srowen changed the title [SPARK-29293][BUILD] Update scalafmt plugin to 1.0.2 for compatibility with Scala 2.13 [SPARK-29293][BUILD] Move scalafmt to Scala 2.12 profile; bump to 0.12 Nov 26, 2019
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Merged to master.
Thank you, @srowen and @koeninger .
I also checked this is still active with Scala-2.12 also 0.12 becomes more verbose.

[INFO] Using config at path: dev/.scalafmt.conf
[INFO] Options: --diff
[ERROR] Could not locate Scala source at /Users/dongjoon/PRS/PR-26655/external/kafka-0-10-assembly/src/main/scala
[ERROR] Could not locate Scala source at /Users/dongjoon/PRS/PR-26655/external/kafka-0-10-assembly/src/test/scala
[ERROR] No source files found, skipping formatting!

@srowen srowen deleted the SPARK-29293 branch December 6, 2019 19:06
attilapiros pushed a commit to attilapiros/spark that referenced this pull request Dec 6, 2019
### What changes were proposed in this pull request?

Move scalafmt to Scala 2.12 profile; bump to 0.12.

### Why are the changes needed?

To facilitate a future Scala 2.13 build.

### Does this PR introduce any user-facing change?

None.

### How was this patch tested?

This isn't covered by tests, it's a convenience for contributors.

Closes apache#26655 from srowen/SPARK-29293.

Authored-by: Sean Owen <sean.owen@databricks.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants