Debug long compile times in Scala and SBT

后端 未结 1 620
星月不相逢
星月不相逢 2021-02-02 00:00

In my Scala/SBT project, I have one file that takes up to 5(!) minutes to compile. All the other ones can compile in a few seconds. This makes development pretty painful.

相关标签:
1条回答
  • 2021-02-02 00:42

    You can try the following Scala compiler options:

    • -Ystatistics Print compiler statistics

    Find a phase that takes the most time. Then, try those:

    • -Xprint:<phase> Print out program after or "all"
    • -Yshow-trees Show detailed trees when used in connection with -print:phase
    • -Ydebug Output debugging messages
    • -Ypmat-debug Trace all pattern matcher activity.

    To enable these settings directly from the sbt console, you can use set scalacOptions in ThisBuild += "-Ystatistics", or for more than one, set scalacOptions in ThisBuild ++= Seq("-Yshow-trees", "-Ydebug)

    0 讨论(0)
提交回复
热议问题