首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从maven-checkstyle-plugin扫描中排除*target*目录

从maven-checkstyle-plugin扫描中排除*target*目录
EN

Stack Overflow用户
提问于 2018-05-26 12:21:24
回答 2查看 3.5K关注 0票数 2

我在我的pom.xml中使用Apache Maven Checkstyle插件。我正在尝试从检查样式扫描中排除目标目录,但到目前为止还没有成功。这是我正在尝试的pom代码。

代码语言:javascript
复制
        <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>
EN

回答 2

Stack Overflow用户

发布于 2018-09-14 21:40:46

在Apache Maven Checkstyle Plugin version3中,要指定源目录的位置,我们必须使用sourceDirectories参数。然后,我们只能指定要用于Checkstyle的应用程序/库和测试源的目录:

代码语言:javascript
复制
<sourceDirectories>
  <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
  <sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
</sourceDirectories>

现在只对src/main/javasrc/test/java进行分析。

下面是我的完整工作示例:

代码语言:javascript
复制
<!-- 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>
票数 3
EN

Stack Overflow用户

发布于 2018-05-26 14:28:48

代码语言:javascript
复制
<excludes>**/generated/**/*</excludes>

这将从插件中删除生成的文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50539287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档