SBT: Enable/Disable fatal warnings only for certain command alias? - scala

Absolute sbt newbie here, so I might be missing something basic:
I want to have a particular command alias like build-special which runs the regular build command, but with the "-Xfatal-warnings" fatal warning flag enabled (or disabled, depending on what we make the default.)
How would this be done?

Related

Change the sbt log level on only my machine in perpetuity?

Every time I use sbt the first thing I do is set the log level to Error:
$ sbt
// ... sbt loads
[my_project] $ error
[my_project] $
Several places on SO and elsewhere recommend adding this to either your build.sbt or your sbt.boot.properties:
set logLevel in run := Level.Error
But I'm working in a shared project with many developers and I don't want to change the log level for everyone, just me! I do currently use SBT_OPTS to tailor sbt's memory usage on my machine, and this may potentially be an option but I can't find any guidance on what format to pass options via SBT_OPTS except for Java things like pass -Dkey=val directly to the java runtime and memory parameters like -Xmx8G.
sbt --help indicates that .sbtopts may also be a potential option:
.sbtopts if this file exists in the current directory, its contents
are prepended to the runner args
But as far as I can tell there are no method to specify command-line "runner args" that set the log level to Error, only for setting the log level to debug via --debug.
I'm a little stumped, I've identified at least two potential avenues (SBT_OPTS and .sbtopts) for passing machine-specific customization to sbt, but do either of these support setting the log level to Error? Or is there a third avenue I'm missing, maybe some elusive ~/.sbt, that I could use to set my machine's sbt log level to Error?
Put the following in $HOME/.sbt/1.0/global.sbt
logLevel := Level.Error
All available log level options are:
Error
Warn
Info
Debug
Thanks #maxkar for leading me to this solution

Arguments to PyUnit not parsed correctly

When we try to run a PyUnit test in Eclipse as a Python unit-test, it fails. This is because the arguments sent to PyUnit come in the following order: file-to-test --port portno. We have discovered that there is an environment variable called POSIXLY_CORRECT that, if set, makes PyUnit expect the arguments to come in a certain order, options first.
We have looked everywhere in Eclipse to try and find where these arguments are set, but are unable to find them. So as a workaround we change the run configuration to use an environment without the POSIXLY_CORRECT set. But this is very awkward.
Does anyone know how to solve this so that we do not need to modify the run configurations to be able to run our tests?

Build a VS2003 project from the command line without outputting warnings

Anyone know if it's possible to build a VS2003 project from the command line without showing any warnings? We've got a heap of VS2003 projects that get built by TSFBuild as part of our platform build and the warnings are just noise in the build log file.
I have looked at the parameters by running devenv.com /help and nothing there seems relevant. VS2010 has a build output verbosity setting but I couldn't find one for VS2003. I am also looking to see if it can be configured through the project file.
Seems like you're building your projects using MSBuild. If so, you can try suppress the warnings by setting the WarningLevel property as suggested here. Or you can choose the console logger to not show the warning and error summary, then output them to seperate files as provided here:
/consoleloggerparameters:parameters
NoSummary: Hides the error and warning summary displayed at the end
of a build.
/fileloggerparameters:
You can use up to ten file loggers by
following the parameter with a digit
identifying the logger. For example,
to generate separate log files for
warnings and errors, use -
/flp1:logfile=errors.txt;errorsonly
/flp2:logfile=warnings.txt;warningsonly

How can colored terminal output be disabled for sbt/play?

I would like to disable the color escape codes logged from sbt/play. Is this possible? And if it is, is there a way to do it without making changes to the config - i.e. via a command line switch or system property.
Since version 0.13.8 (and possibly earlier) you can now simply use the -no-colors option to sbt. e.g.
sbt -no-colors test
You can simply set the system property sbt.log.noformat to true. If you want to e.g. use SBT inside Vim you can create a script like this:
#!/bin/bash
java -Dsbt.log.noformat=true $JAVA_OPTS -jar "${HOME}/bin/sbt-launch.jar" "$#"
This sounds like your platform does not match the actual jline.terminal property. I am just guessing here but when I pass the parameter as Daniel suggested on a Windows command line I see the color escape codes as well.
Therefore, you have to make sure the property matches your platform, i.e. WindowsTerminal on Windows and UnixTerminal on Unix.
If this does not help, then you might be on an unsupported platform in which case the website suggests to use:
-Djline.terminal=jline.UnsupportedTerminal
Well, you can get colors on Windows by installing Cygwin and passing this parameter:
-Djline.terminal=jline.UnixTerminal
So I'd look up jline parameters to see what disables color coding.
I was able to get colored output from SBT in Cygwin by adding:
-Djline.terminal=jline.UnixTerminal
Additionally I figured out that I also needed to add the following line to Cygwin.bat:
set CYGWIN=tty ntsec
After that is added SBT gives very nice colored output. Additionally I would recommend looking into Console2 as it can hook through Cygwin, but provides a much better interface in my opinion:
http://sourceforge.net/projects/console/

How to suppress all warnings using MSBuild

How would I suppress all warnings (or at least as many as possible since those prefixed with MSB cannot be suppressed How to suppress specific MSBuild warning)?
msbuild /clp:ErrorsOnly
/consoleloggerparameters:
Parameters to console logger. (Short form: /clp)
The available parameters are:
PerformanceSummary--Show time spent in tasks, targets
and projects.
Summary--Show error and warning summary at the end.
NoSummary--Don't show error and warning summary at the
end.
**ErrorsOnly--Show only errors.**
WarningsOnly--Show only warnings.
NoItemAndPropertyList--Don't show list of items and
properties at the start of each project build.
ShowCommandLine--Show TaskCommandLineEvent messages
ShowTimestamp--Display the Timestamp as a prefix to any
message.
ShowEventId--Show eventId for started events, finished
events, and messages
ForceNoAlign--Does not align the text to the size of
the console buffer
DisableMPLogging-- Disable the multiprocessor
logging style of output when running in
non-multiprocessor mode.
EnableMPLogging--Enable the multiprocessor logging
style even when running in non-multiprocessor
mode. This logging style is on by default.
Verbosity--overrides the /verbosity setting for this
logger.
The best way is to fix the issues that are causing the warnings.
If you must ignore the warnings (e.g. you have inherited a project with so many that you can't see the wood for the trees), you could try changing the WarningLevel property, http://msdn.microsoft.com/en-us/library/13b90fz7.aspx
If you would like to suppress MSB3270 only then you can set in project file just
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
None
</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
In Jenkins
Happened upon this Googling "how to suppress MSBuild warnings in Jenkins"
So much noise like the following in our console output, couldn't find the meat
Missing XML comment for publicly visible type or member
Inherited Jenkins on a Windows server
Manage Jenkins > Global Tool Configuration > MSBuild
Add /clp:ErrorsOnly to the Default parameters