sim*_*905 17 java compiler-construction lint build maven
我在尝试:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Werror</compilerArgument>
<fork>true</fork>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但没有快乐.现在有什么想法可以在这篇博客文章中提出的这些错误中世纪 ?
glt*_*lts 25
使用Maven 3.3和Java 8进行2015年更新.
这是一个最小的编译器配置,它可以启用所有警告,并在发生警告时使构建失败.
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
注意事项:
<showWarnings>true</showWarnings>是必须的.由于未知原因,Maven默认使用-nowarn标志主动抑制警告,因此将忽略-Xlint和-Werror标志.showDeprecation不需要启用,因为-Xlint:all已经发出弃用警告.fork,即使文档另有说明,也不需要启用.maven-compiler-plugin3.6.0中的新功能:failOnWarning标志。这对我有用:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgument>-Xlint:-processing</compilerArgument>
<failOnWarning>true</failOnWarning>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
请注意,我必须排除processing皮棉,否则自动事项的注释会因隐含的“找不到符号”错误而破坏构建。
编辑:这个答案已经过时,但我无法删除它,因为它是当时接受的答案。
这是 Maven 的一个错误,请参阅: https: //issues.apache.org/jira/browse/MCOMPILER-120它已在 Maven-compiler-plugin 2.4 中修复,但我不认为它已经发布。不幸的是,标签也不起作用。
| 归档时间: |
|
| 查看次数: |
10366 次 |
| 最近记录: |