I have a Scala sbt project where I'm using the sbt-tpolecat plugin:
// scalac options for the enlightened @see https://github.com/typelevel/sbt-tpolecat
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.2")
When I compile against my project using
sbt clean compile
I get this wierd warning showing up as error:
[info] compiling 41 Scala sources and 2 Java sources to /Users/user/Projects/Private/scala-projects/open-electrons/cpo-platform/ocpp-gateway-server/target/scala-2.13/classes ...
[error] bad option: '-no-link-warnings'
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 2 s, completed Dec 23, 2024, 11:37:46 AM
How can I supress this error using the sbt-tpolecat plugin? Is there any other better way to do this?
EDIT: I tried to supress this by adding this to my build.sbt:
Compile / doc / scalacOptions += "-no-link-warnings"
But this has no effect and the build continues to fail.
Your attempted solution adds -no-link-warnings
as an options when invoking the compiler.
I'm also not sure whether you are touching the right scope, since the error in the original descriptions says this happens when you run Compile / compileIncremental
(and to the best of my understanding, sbt clean compile
doesn't automatically invoke the compilation under the doc scope -- unless you set it up yourself to do so).
What you might want to try is:
Compile / doc / scalacOptions -= "-no-link-warnings"
If you have multiple options you want to disable explicitly you can do it like so:
Compile / doc / scalacOptions --= Seq("-no-link-warnings")
The ticket linked in a comment has a different approach, which I'll leave here for reference (but since the approach above works, I would probably favor that, as it's probably a bit easier to read and understand).
Compile / doc / scalacOptions ~= (_.filterNot(
Set(
"-no-link-warnings",
)
))
One final warning that unfortunately setting and unsetting options this way is susceptible to the order in which these are evaluated. I believe this should not be a problem for you, as IIUC the plugin should be applied before any of your settings take effect, but I wanted to leave this here in case you are actually applying the settings by hand.
As a final note, you might want to consider the idea of setting the options for the compiler yourself. It's a few extra lines, but it's all entirely under your control and probably easier for you to debug should any issue arise (this is the original inspiration for the plugin you are using, I've seen that set of options copied and pasted in multiple Scala projects over the years).