Wie kann ich Dateien ausschließen, die von der Code-Coverage von SonarQube mit JaCoCo maven-plugin

Ich habe da ein großes Problem mit der integration von JaCoCo maven-plugin für die code-Abdeckung von SonarQube 6.0.

Ich habe ein multi-Modul-Maven-Projekt können sagen :

master
    |--core
    |--web
    |--process

in der master-pom.xml ich habe setted ein reporting-Profil wie :

<profile>
        <id>reporting</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>pre-unit-test</id>
                            <!--<phase>test</phase> -->
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <!-- Sets the path to the file to write the execution data to. -->
                                <destFile>${sonar.jacoco.reportPath}</destFile>
                                <!-- Connection with SureFire plugin -->
                                <propertyName>sonarUnitTestArgLine</propertyName>
                            </configuration>
                        </execution>
                        <execution>
                            <id>post-unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <!-- Sets the path to where the execution data is located. -->
                                <dataFile>${sonar.jacoco.reportPath}</dataFile>
                                <!-- Sets the output directory for the code coverage report. -->
                                <outputDirectory>${jacoco.ut.outputdir}</outputDirectory>
                            </configuration>
                        </execution>

                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <forkMode>once</forkMode>
                        <argLine>${sonarUnitTestArgLine} -XX:MaxPermSize=512M -Xms512m -Xmx512m</argLine>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

in der childs, I überlasten Sie die Konfiguration, indem Sie einige Ausnahmen :

<!-- First attempt -->
<properties>
    <sonar.jacoco.excludes>**/model/**/*</sonar.jacoco.excludes>
</properties>

<!-- Second attempt -->
<properties>
    <sonar.coverage.exclusions>**/model/**/*</sonar.coverage.exclusions>
</properties>

<!-- Third attempt -->
<profiles>
    <profile>
        <id>reporting</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <!-- Exclude model classes (POJO's) -->
                            <exclude>**/model/**/*.class</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

die Idee hier ist, um das Pojo des code-coverage - ( wir tun es auch für andere Arten von Klasse ...)

Wenn ich das mvn-Kommando-Zeile :

mvn clean generate-sources install verify -P reporting -fn

Alle meine Berichte sind auch generiert, aber in Sonar, die exculsions nicht berücksichtigt ...

Bitte können Sie mir helfen, dieses Problem zu beheben ?

InformationsquelleAutor Gilles Bodart | 2017-01-18

Schreibe einen Kommentar