在一个多模块项目中,有一个在目录[master-slave]
master ansible_host=192.168.231.102
slave ansible_host=192.168.231.92
[master]
master ansible_host=192.168.231.102
中生成一些源代码,我正在尝试使maven checkstyle插件跳过这个生成的源目录。尽管已经为target/generated-sources/xjc3/com/...
标记尝试了许多语法,但它仍在扫描此源目录。 有没有人知道如何从审核中删除此生成的源目录?
<excludes>
这是插件调试输出,它显示它保持包含生成的源目录:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>checkstyle</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.7</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>cloudstack-checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>cloud-style.xml</configLocation>
<consoleOutput>true</consoleOutput>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<includes>**\/*.java</includes>
<excludes>**\/deps\/,**\/test\/,**\/target\/,**\/bin\/,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/apidoc\/,**\/generated-sources\/,**\/generated-sources\/*,**\/generated-sources\/**,**\/generated-sources\/**\/*.*,**/generated-sources/**/*.*,**/generated-sources/**/*,**/generated-sources/**,**/generated-sources/*,**/generated-sources/*.*</excludes>
</configuration>
</plugin>
答案 0 :(得分:1)
如果您的所有模块都具有一致的源文件夹位置,则可以将源文件夹锁定为“真实”源
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<sourceDirectories>
<sourceDirectory>src/main/java</sourceDirectory>
</sourceDirectories>
</configuration>
</plugin>
答案 1 :(得分:1)
我还在maven中运行代码生成,该代码还将目标对象/生成的对象添加为源目录,并使checkstyle中的任何源目录过滤选项都无效。
以下解决方案有效: 您必须使用一个明确的checkstyle-suppressions.xml配置文件并从您的配置中激活它:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
[...]
用于排除目标文件夹的禁止文件如下所示:
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="[/\\]target[/\\]" checks=".*" />
</suppressions>