We have one Scala3 project where we use macros. We use Visual Studio Code with Metals plugin.
sbt clean compile
tooks more then 20 minutes. Is there any way to profile Scala3
compiler to figure out where that time goes?
You can set the compilerflag "-Vprofile" in your build.sbt.
scalacOptions += "-Vprofile"
It will output the complexity of your files. At least, it will give you a hint, where a lot of compile time will be spend.
Maybe this will be interesting for you as well:
Scala Sbt - Measure task time for subprojects
Related
I want to test a project against latest Dotty 0.28 nightly builds, while it requires many dependencies that have last been published for Dotty 0.27.0-RC1. Without going into the question of binary compatibility, is there—for testing purposes, to see if a fix in Dotty applies to the project that previously crashed dotc—a way to specify in build.sbt diverging scala versions for the compiler that's used (I want 0.28.0-...-NIGHTLY) and the dependencies looked up (I want 0.27.0-RC1)?
I do not wish to edit all of libraryDependencies to change % "foo" for % "foo_0.27.0-RC1", but want a global way to enable this behaviour.
I'd like to check the code of my whole project with wartremover and sbt.
I've added addSbtPlugin("org.brianmckenna" % "sbt-wartremover" % "0.13" to plugins.sbt, but don't know what to do next.
I don't get any output from wartremover with sbt run and sbt compile.
Like said in the documentation, you will need to configure the linter:
wartremoverErrors ++= Warts.unsafe
With sbt >= 0.13.5 and the auto plugin feature, that's all. I get compilation errors with the examples as soon as I add the line above.
I've been avoiding using SBT since the support in intellij for maven has always been far superior, plus I don't see much advantage in SBT; but I figure why fight the masses.
So one of my open source projects I've converted over to SBT. Now when I run tests (approx 1000 test cases), I get OOMs. Ok so I've tried
fork in Test := true
javaOptions in Test ++= Seq("-Xmx2048m", "-XX:MaxPermSize=512m")
Ok so my OOMs go away but now I get
sbt.ForkMain$Run$RunAborted: java.net.SocketException: Broken pipe
at sbt.ForkMain$Run.write(ForkMain.java:114)
at sbt.ForkMain$Run$1.info(ForkMain.java:132)
Seems to be in different places each time.
These tests all pass if I'm building via maven (scala test maven plugin).
Help me Obi-wan or SBT lovers.
Edit: Adding env details
sbt 0.12.4
java 7.25
scala 2.10.2
I'm doing some refactoring that made compiler temporally give errors in several files. I'd like to work with them one by one (starting with common dependencies) and need some tool to check if modification is correct.
sbt compile is inconvenient because it gives too many errors and spends much time for compiling things that have no good.
I'm searching for a way to compile single file with sbt or a method for extracting sbt side libraries definition to pass them to a normal scalac compiler
There was a similar topic: How to compile just some files with sbt? that turned out to be source code error discussion rather that sbt functionality disclosure.
You could add the following line to build.sbt:
sources in Compile <<= (sources in Compile).map(_ filter(_.name == "Particular.scala"))
Then fix Particular.scala, then edit build.sbt and put the name of the next source file. If you keep the sbt console open, reload will re-read the .sbt file after you modify it.
I just wanted to mention here that I came across sbt-compile-quick-plugin (https://github.com/etsy/sbt-compile-quick-plugin). It does what it says on the tin, just add addSbtPlugin("com.etsy" % "sbt-compile-quick-plugin" % "1.3.0") to your project/plugins.sbt, then you can just start up sbt and run compileQuick /path/to/your/file
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.
I'm sure that I'm abusing some Scala constructs, but I have no idea how to go about debugging it. How does one debug long compile times in Scala?
I'm using Scala 2.9.2 and SBT 0.11.2
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")