有没有办法通过命令行将编译器参数传递给 Maven?我知道我可以在 compiler-plugin
中指定它,但我想运行 Xlint
同样来自命令行。所以我尝试了类似的东西
mvn clean install -DskipTests=true -DcompilerArgument=-Xlint:deprecation
但没有成功。
最佳答案
对于这个具体案例(弃用警告),实际上是一个property which can be used from the command line :
mvn clean install -Dmaven.compiler.showDeprecation=true
与 compilerArgument 解决方案相反,这在 maven 进程内部使用编译器时也有效,而不仅仅是在使用 fork=true 时。
一个类似有用的属性是 maven.compiler.showWarnings
。
关于java - 如何用Xlint编译Maven项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18653947/