Display warnings in sbt continuous compilation mode - scala

I am running "activator ~run" on my scala project to have it update immediately after I make a change to the code.
This works nicely, but I dont see any warnings any more on subsequent compiles. The only thing I see is "[success] Compiled in xs".
Now i do see the warnings immediately after running "activator ~run" for the first time. I do not see it after I make code changes and save them.
How can I get sbt to display the warnings on each refresh, so that I can work on them?
I'm using sbt 013.5, scala 2.11.2, activator 1.2.7

Related

Preserve results of sbt incremental compilation when moving project directory

Consider the scenario: I have a simple scala project managed by sbt, in a directory called foo.
cd foo
sbt compile
It now takes a few seconds and the project compiles correctly.
Now, thanks to sbt incremental compilation, if I run
sbt compile
it terminates the compile task in close to 0 seconds, since the source code hasn't changed.
But if I rename the foo directory into bar
cd ..
mv foo bar
and try to compile it again
cd bar
sbt compile
now the compile task takes again few seconds, hence not using the results from the previous compilation.
Is there a way to preserve the incremental compilation results of a project even when its absolute path on disk has changed?
You can also try to use Hoarder Plugin: https://github.com/romanowski/hoarder.
Ping me on Hoarder's gitter in case of any questions/problems.
As it turns out, there's some work in progress to make incremental compilation results cacheable. Here's the relevant PR: https://github.com/sbt/zinc/pull/216.
Also, there's an issue (being discussed at the time of this writing) about making zinc's analysis completely machine independent. See https://github.com/sbt/zinc/issues/218.

ScalaTest2 cannot run unit-tests when dynamic.classpath is enabled in IntelliJ[12/13]

We've ran into a strange problem after upgrading our suite of unit-tests to ScalaTest2.0 (with Scala 2.10)
Now running all our unit-tests is very unreliable: sometimes the process hangs, sometimes we get false failures, and the reporting within IntelliJ is messed up (individual tests are not reported under the proper class name, etc.)
After some investigation, we nailed it down to the IntelliJ property dynamic.classpath. When set to false, the problem disappears and our unit-tests run fine, when set to true (even in a different project) the problem starts to appear.
The problem is that we need dynamic.classpath set to true, else IntelliJ is complaining that the command line is too long, with the following message:
Error running Unit Tests
Command line is too long. In order to reduce its length classpath file can be used.
Would you like to enable classpath file mode for all run configurations of your project?
see problem here: IDEA 10.5 Command line is too long
and What does the dynamic.classpath flag do? (IntelliJ project settings)
Any help appreciated (or maybe a workaround to the "command line too long" without using dynamic classpath?)
IntelliJ v13.0.2 (also happened with 12)
scala plugin v0.30.387
scala v2.10.0
scalatest v2.10-2.0

how to compile single file in sbt

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

How to compile tests with SBT without running them

Is there a way to build tests with SBT without running them?
My own use case is to run static analysis on the test code by using a scalac plugin. Another possible use case is to run some or all of the test code using a separate runner than the one built into SBT.
Ideally there would be a solution to this problem that applies to any SBT project. For example, Maven has a test-compile command that can be used just to compile the tests without running them. It would be great if SBT had the same thing.
Less ideal, but still very helpful, would be solutions that involve modifying the project's build files.
Just use the Test / compile command.
Test/compile works for compiling your unit tests.
To compile integration tests you can use IntegrationTest/compile.
Another hint to continuously compile on every file change: ~Test/compile
We have a build.sbt file that is used for multiple projects. Doing sbt test:compile compiled the tests for every single project and took over 30 minutes.
I found out I can compile only the tests for a specific project named xyz by doing:
sbt xyz/test:compile
Using sbt version 1.5.0 and higher test:compile returns deprecation warning.
Use Test / compile.
(docs)

How do I run a maven/eclipse/GWT/playN app in production mode?

There seems to be an issue if you want to launch a playN/GWT/maven app from eclipse in production mode using the following procedure:
Right click on playn-showcase-html and select Goolge-GWT Compile
Compiling module playn.showcase.Showcase
Resolving com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator
Found type 'com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator'
Found type 'javax.validation.constraints.DecimalMax'
[WARN] Detected warnings related to 'javax.validation.Constraint'. Is validation-<version>.jar on the classpath?
Specify -logLevel DEBUG to see all errors.
[WARN] Ignoring unresolvable annotation type javax.validation.Constraint
Compiling 1 permutation
Compiling permutation 0...
Compile of permutations succeeded
Linking into /Users/bryan/dev/playn-samples/showcase/html/target/playn-showcase-html-1.0-SNAPSHOT/showcase
Link succeeded
Compilation succeeded -- 19.459s
Anyone know what these warnings are about?
Right click on playn-showcase-html and select Run As web application
Go to URL http://127.0.0.1:8888/Showcase.html in your browser and you'll get an error that says GWT module 'showcase' may need to be (re)compiled.
The only way around this appears to be if you swap steps 1 & 2, but that just seems backwards. I think the problem is that the when you run the web app from eclipse that the gwt maven plugin is compiling/deploying the artifacts again which step on your previous GWT compile step.
Anyways, this isn't a huge deal since you can reverse the order of steps to get it to work, but I was just curious if anyone has found a solution to this.
I suggest that you try to compile/run it with maven directly, not through Eclipse, first go to the root directory of your game and do the following:
mvn clean package
that should compile your game without problems, and then
mvn test -Ptest-html
and that should run your game in http://localhost:8080/
Hope this helps, and I strongly suggest that use maven directly whenever you can, because Eclipse has a lot of incompatibility problems with some things.