我想禁止在项目中使用某些注释。特别是来自lombok的@SneakyThrows注释。 一种方法是在构建maven工件时失败。 是否有一些现有的插件可以达到这个目标?
我认为可以使用像checkstyle这样的静态代码分析器。但我不想为它写新的规则。
如果存在这样的gradle插件,那么有趣吗?
答案 0 :(得分:0)
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${basedir}</basedir>
<includes>
<include>target/**/*.java</include>
</includes>
<regex>false</regex>
<replacements>
<replacement>
<token>@SneakyThrows</token>
<value>@@@@ I-DONT-THINK-SO @@@@</value>
</replacement>
</replacements>
</configuration>
</plugin>