I'm looking for an unobtrusive way to make mvn aware of additional flags I'd like to pass to the scalac compiler via the command-line or environment variables only.
I'm currently using the scala-maven-plugin with a command such as:
mvn --show-version --batch-mode --errors compile
In this case I want mvn to treat the compile stage as if it had been passed flags such as:
scalac -encoding utf8 -deprecation -unchecked -Xlint:_ -Werror -Wdead-code -Wunused:_
I do not want to touch the project's pom.xml. The reason for that in this case is that this is a step in an upstream CI/CD templates repository, so I don't have permission to mess with the Maven configuration of the downstream projects.
It does not appear that this is what MAVEN_OPTS is made for, so I'm wondering if there is some alternative to talk to scalac.
Using
scala:compilewith-DaddScalacArgsallows you to pass additional flags toscalac:Example:
Documentation:
Note that the available options to
scalachave changed with Scala versions.You can use:
mvn scala:helpscalac -Xscalac -Xlint:helpTo see the underlying version and the available
-Xoptions.