I'm using the sbt-idea plugin and in my metaproject and main project, I have a setting for logLevel := Level.Warn. This is effective at silencing all sub-warning messages from most of my build, but sbt-idea keeps printing out info messages.
I'm guessing that perhaps the plugin gets loaded before logLevel is applied, and it somehow gets a reference to a logger with a different level? The plugin in particular doesn't seem to be doing anything particularly funky about logging, except that it does seem to ask the state for its logger at initialization. It might end up being a different logger object from the one after my settings get applied?
I can't figure out what part of sbt actually consumes the logLevel setting key to see whether it creates a new logger or mutates the existing one.
Use --warn or --error before gen-idea.
$ sbt --warn gen-idea
or
$ sbt --error gen-idea
See Change the logging level globally for more up-to-date info (pun intended).
Be careful, though, as you may really miss infos after you silence the gen-idea command as it may take a while to complete and nothing gets printed out in the meantime.
It may hence be more useful to use another trick and execute warn or error commands before gen-idea.
$ sbt warn gen-idea
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to aaa (in build file:/Users/jacek/sandbox/stackoverflow/16256180/)
With this, you'll see something printed out on the console that may or may not be of some help.
Related
I use lombok extensively at backend, it's really nice and I hope to integrate it into GWT, so I can take advantage of the magic.
I managed to let gwt-maven-plugin recognize lombok by using the -javaagent:lombok.jar=ECJ vm args to be able to compile successfully, however, I'm not sure how to make it work with GWT super dev mode, as it continues complaining "missing getter method" in my IDE(Intellij IDEA).
Also tried the delombok goal of lombok-maven-plugin but without luck.
Any ideas?
Make sure to delete your workDir before starting gwt:run-codeserver. This directory might contain files from previous (lombok-unaware) compilation attempts.
[INFO] --- gwt-maven-plugin:2.8.0-beta1:run-codeserver (default-cli) # Web ---
[INFO] Turning off precompile in incremental mode.
[INFO] Super Dev Mode starting up
[INFO] workDir: C:\Users\jzaruba\AppData\Local\Temp\gwt-codeserver-1653004051676437159.tmp
This is what my mvn-gwt-codeserver.bat looks like:
call mvn clean dependency:properties gwt:run-codeserver %*
(I added dependency:properties because my gwt-maven-plugin configuration refers to Lombok via project dependency: ${org.projectlombok:lombok:jar}, i.e. no static path.)
And if you don't like launching the codeserver from command line, this is how "VM arguments" in my "GWT Codeserver" launch configuration look like:
-javaagent:path/to/lombok.jar=ECJ
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
I generate code with the scalaxb-sbt plugin that, when compiled, generates a good number of warning messages. Is there any way to hide compilation warnings for generated code or by package?
The silencer compiler plugin allows to suppress compiler warnings. It supports filtering out files by path. This will filter out all generated files from warnings:
scalacOptions += "-P:silencer:pathFilters=src_managed"
For Scala 2.12.13+ or 2.13.2+
Recent versions of the Scala compiler integrate the silencer plugin, see configurable warnings.
So now you don't need any plugin, just add the following line to build.sbt:
ThisBuild / scalacOptions += "-Wconf:src=src_managed/.*:silent"
Using this option will suppress warnings for generated code that lives under a directory called src_managed anywhere in your source tree.
This solved my problem with code generated by zio-grpc, where the compiler emitted warnings like parameter value evidence$3 in method live is never used (adding this info only for better searchability).
In your sbt console you could try the following:
set logLevel in compile := Level.Error or eventually set logLevel in sourceGenerators := Level.Error
and experiment with different settings. Once you are happy you could apply this setting in your build.sbt.
More detailed information can be found in the sbt documentation: http://www.scala-sbt.org/release/docs/Howto/logging.html
I found that I needed to do set logLevel in Compile := Level.Error in my sbt console session in order for this to work. This is with a capital C in Compile. This is with sbt version 0.13.11. This is also to turn all warnings off, though.
Put the code in a subproject, and set scalacOptions differently in that project? Whether this will work depends on whether the support even exists in scalac for suppressing the particular kind of warning you are getting. See for example https://issues.scala-lang.org/browse/SI-1781 . What kind of warnings are you needing to suppress exactly? Certain warnings like unchecked warnings can be suppressed with e.g. #unchecked without having to do the subproject thing.
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
default SBT log level is info (see http://code.google.com/p/simple-build-tool/wiki/RunningSbt).
How do I set it to warn as the default?
#Christian: Thanks! Did you get that to work? I modified the sbt.boot.properties accordingly and passed it via:
(1) -Dsbt.boot.properties=mysbt.boot.properties
(2) -jar /usr/local/Cellar/sbt/0.7.7/libexec/sbt-launch-0.7.7.jar "#/usr/local/Cellar/sbt/0.7.7/libexec/mysbt.boot.properties"
Both ways process my sbt.boot.properties but I still see [info] log messages. Overriding project settings does not work either.
I wonder if this works at all. I even found a bug.
Thanks,
Lars
You can set it temporarily by prefixing your action with warn, eg
~> sbt warn compile
or from the sbt console:
~> sbt
[info] Building project test 1.0 against Scala 2.8.1
[info] using TestProject with sbt 0.7.7 and Scala 2.7.7
> warn
Set log level to warn
> compile
>
In XSBT this seems to be the way to do it from the console
set logLevel in run := Level.Debug
https://github.com/harrah/xsbt/wiki/Quick-Configuration-Examples
Note that these are SBT levels, so for example they don't work directly with Play 2.0!
You could define it in sbt.boot.properties as explained here: sbt wiki