У меня есть проект Maven с несколькими модулями, включая org.eclipse.cdt.core
. По какой-то причине клиент хочет построить org.eclipse.cdt.core
.Как исключить пакеты из анализа CheckStyle в проекте mavenized multi-module?
Я хочу создать агрегированный отчет Checkstyle, из которого исключены некоторые файлы, включая все классы org.eclipse.cdt.core.*
(включая подпакеты).
Для этой цели я указал excludes
бирку
<excludes>**/org/eclipse/cdt/core/**/*,org.eclipse.cdt.core/src/**/*,../org.eclipse.cdt.core/src/**/*,org.eclipse.cdt.core/**/*</excludes>
Тогда я побежал mvn clean checkstyle-aggregate site
, открывшего файл target/checkstyle-result.xml
и нашел следующие строки в нем:
<file name="C:\dev\ide\org.eclipse.cdt.core\src\org\eclipse\cdt\core\AbstractExecutableExtensionBase.java">
<error line="0" severity="error" message="File does not end with a newline." source="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck"/>
<error line="10" severity="error" message="Line is longer than 80 characters (found 81)." source="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck"/>
<error line="15" severity="error" message="Line is longer than 80 characters (found 83)." source="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck"/>
Это означает, что мой <excludes>
тег не работает.
Затем я положил линий
<properties>
<checkstyle.skip>true</checkstyle.skip>
</properties>
в pom.xml
файлов всех модулей, которые будут исключены из Checkstyle, но это не помогло.
Как я могу сгенерировать отчет CheckStyle (XML или HTML), без результатов для определенных модулей (кроме того, что вы принимаете 180 МБ большого target/checkstyle-result.xml
и удаляете из него все «неправильные» файлы?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mycompany-parentproject</groupId>
<artifactId>com.mycompany.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<tycho-version>0.21.0</tycho-version>
<tycho-extras-version>0.21.0</tycho-extras-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<antrun-version>1.7</antrun-version>
</properties>
<pluginRepositories>
<pluginRepository>
<id>Codehaus repository</id>
<url>http://repository.codehaus.org/</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<site>
<id>${project.artifactId}-site</id>
<url>${project.baseUri}</url>
</site>
</distributionManagement>
<build>
<plugins>
<plugin>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
</environments>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-versions-plugin</artifactId>
<version>${tycho-version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<format>'mycompany_'yyyyMMddHHmm</format>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../com.mycompany.module1</module>
<module>../com.mycompany.module2</module>
<module>../com.mycompany.module3</module>
<module>../org.eclipse.cdt.core</module>
</modules>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.8</version>
<configuration>
<configLocation>sun-coding-standard.checkstyle.xml</configLocation>
<excludes>**/org/eclipse/cdt/core/**/*,org.eclipse.cdt.core/src/**/*,../org.eclipse.cdt.core/src/**/*,org.eclipse.cdt.core/**/*</excludes>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<reportSets>
<reportSet>
<id>aggregate</id>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<xmlOutput>true</xmlOutput>
</configuration>
<reportSets>
<reportSet>
<id>aggregate</id>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</reportPlugins>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Обновление 1 (25.09.2014 13:03 MSK): Пытались использовать фильтры подавления путем добавления
<configuration>
<configLocation>sun-coding-standard.checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
с Checkstyle-suppressions.xml равна
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files="[\\/]org.eclipse.cdt.core[\\/]" checks="[a-zA-Z0-9]*"/>
<suppress files="[\\/]org[\\/]eclipse[\\/]cdt[\\/]core[\\/]" checks="[a-zA-Z0-9]*"/>
<suppress files="[\\/]org.eclipse.cdt.core[\\/]" checks="."/>
<suppress files="[\\/]org[\\/]eclipse[\\/]cdt[\\/]core[\\/]" checks="."/>
</suppressions>
Это не помогло.
Добавление <suppressionsFileExpression>checkstyle.suppressions.files</suppressionsFileExpression>
к вышеуказанному разделу <configuration>
также не помогло.
Как назвать этот файл? – zygimantus