配置检查样式

您可以通过在 Eclipse 中创建/导入您的 Checkstyle Check Configuration 来配置 checkstyle,然后在您的 pom 中指定:

  • 额外的构建命令
  • 附加项目性质
  • 附加配置来创建 .checkstyle 文件。

请参阅下面的示例,确保在check-config-name中指定正确的值。

<project>
  [...]
  <build>
    [...]
    <plugins>
      [...]
       <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-eclipse-plugin</artifactId>
          <configuration>
            <additionalBuildcommands>
              <buildcommand>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</buildcommand>
            </additionalBuildcommands>
            <additionalProjectnatures>
              <projectnature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</projectnature>
            </additionalProjectnatures>
            <additionalConfig>
              <file>
                <name>.checkstyle</name>
                <content>
                  <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true">
    <fileset name="all" enabled="true" check-config-name="<YOUR CHECKSTYLE CONFIG NAME HERE>" local="false">
        <file-match-pattern match-pattern="." include-pattern="true"/>
    </fileset>
    <filter name="NonSrcDirs" enabled="true"/>
</fileset-config>
]]>
                </content>
              </file>
            </additionalConfig>
          </configuration>
        </plugin>
      [...]
    </plugins>
    [...]
  </build>
  [...]
</project>