[英]How to make maven fail on raw types?
I want to make maven compile fail if somewhere in the code, raw types (missing generics) are used. 我想在代码中的某处使用maven编译失败,使用原始类型(缺少泛型)。 I tried the following: 我尝试了以下方法:
-Xlint:rawtypes
parameter to javac
can be used to issue warnings if raw types are used. 从版本7开始,如果使用原始类型,则可以使用-Xlint:rawtypes
参数到javac
发出警告。 Unfortunately, I have to use java 6 which does not support this flag. 不幸的是,我必须使用不支持此标志的java 6。 Are there any other maven-modules or tricks which generate an error if raw types are used? 如果使用原始类型,是否还有其他maven模块或技巧会产生错误?
I don't know if it would help, but you can use the eclipse compiler in maven 我不知道它是否会有所帮助,但你可以在maven中使用eclipse编译器
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerId>eclipse</compilerId>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>1.8.2</version>
</dependency>
</dependencies>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.