我在我的pom.xml中使用Apache Maven Checkstyle插件。我正在尝试从检查样式扫描中排除目标目录,但到目前为止还没有成功。这是我正在尝试的pom代码。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle-check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>checkstyles.xml</configLocation>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<consoleOutput>true</consoleOutput>
<includes>**\/*.java,**\/*.groovy</includes>
<excludes>**WHAT GOES HERE TO EXCLUDE THE TARGET DIRECTORY**</excludes>
</configuration>
</plugin>发布于 2018-09-14 21:40:46
在Apache Maven Checkstyle Plugin version3中,要指定源目录的位置,我们必须使用sourceDirectories参数。然后,我们只能指定要用于Checkstyle的应用程序/库和测试源的目录:
<sourceDirectories>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
</sourceDirectories>现在只对src/main/java和src/test/java进行分析。
下面是我的完整工作示例:
<!-- Apache Maven Checkstyle Plugin (checks Java code adheres to a coding standard) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDirectories>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
</sourceDirectories>
<!-- relates to https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml -->
<configLocation>/src/main/resources/checkstyle.xml</configLocation>
</configuration>
</plugin>发布于 2018-05-26 14:28:48
<excludes>**/generated/**/*</excludes>这将从插件中删除生成的文件。
https://stackoverflow.com/questions/50539287
复制相似问题