0

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.

4

1 回答 1

0

使用scala:compilewith-DaddScalacArgs允许您将其他标志传递给scalac

例子:

mvn \
  --show-version \
  --batch-mode \
  --errors \
  scala:compile \
  -DaddScalacArgs='-unchecked|-deprecation|-explaintypes|-Xfatal-warnings|-Xlint:_'

文档:

请注意,可用选项scalac已随 Scala 版本而更改。

您可以使用:

  • mvn scala:help
  • scalac -X
  • scalac -Xlint:help

查看底层版本和可用-X选项。

于 2020-04-22T15:14:08.963 回答