Maven网站没有链接到Jacoco报告

时间:2015-02-08 19:49:09

标签: maven maven-3 pom.xml maven-site-plugin jacoco-maven-plugin

我可以从个人资料'test'生成Jacoco报告,并保存在网站文件夹中。但是当我执行包含网站生成描述的配置文件'documentacion'时,我会在网站上获得所有报告链接,但链接到Jacoco报告除外,但此报告仍显示在网站文件夹中。

这是我POM的一部分(我减少了一些不重要的部分):

<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">
    <dependencies>
        <!-- Tests -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <!-- Dependencia para el informe de traducción -->
        <dependency>
            <groupId>com.googlecode.l10n-maven-plugin</groupId>
            <artifactId>l10n-maven-plugin</artifactId>
            <version>1.8</version>
        </dependency>
        ....
    </dependencies>
    <!-- Configuración común a todas las fases -->
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.fxml</include>
                </includes>                
                <excludes>
                    <exclude>package-info.java</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.css</include>
                    <include>**/*.png</include>
                    <include>**/*.fxml</include>
                    <include>**/*.ttf</include>
                    <include>*.properties</include>
                    <include>version.prop</include>
                </includes>
            </resource>
        </resources>
    </build>
    <!-- Perfiles -->
    <profiles>
        ......
        <profile>
            <id>documentacion</id>            
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                <defaultGoal>site:site</defaultGoal>
                <plugins>
                    <!-- Site -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                        <version>3.4</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.2.201409121644</version>
                    </plugin>   
                </plugins>
            </build>            
            <reporting>
                <excludeDefaults>true</excludeDefaults>
                <outputDirectory>${project.build.directory}/site</outputDirectory>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                        <version>2.8</version>
                        <configuration>
                            <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                        </configuration>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>summary</report>
                                    <report>index</report>
                                    <report>dependencies</report>
                                    <report>project-team</report>
                                    <report>license</report>
                                    <report>scm</report>
                                    <report>cim</report>
                                    <report>mailing-list</report>
                                    <report>issue-tracking</report>
                                </reports>  
                            </reportSet>
                        </reportSets>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <version>3.3</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <version>2.13</version>
                        <configuration>
                            <configLocation>config/sun_checks.xml</configLocation>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jxr-plugin</artifactId>
                        <version>2.5</version>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>findbugs-maven-plugin</artifactId>
                        <version>3.0.0</version>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>l10n-maven-plugin</artifactId>
                        <version>1.0-alpha-2</version>
                        <configuration>
                            <locales>
                                <locale>es</locale>
                            </locales>
                        </configuration>
                    </plugin>        
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-changes-plugin</artifactId>
                        <version>2.11</version>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>changes-report</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.10.1</version>
                        <configuration>
                            <useStandardDocletOptions>false</useStandardDocletOptions>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-report-plugin</artifactId>
                        <version>2.18.1</version>
                    </plugin>
                </plugins>
            </reporting>
        </profile>
        <profile>
            <id>test</id>            
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                <defaultGoal>validate test</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <testFailureIgnore>true</testFailureIgnore>                            
                            <additionalClasspathElements>
                                <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                            </additionalClasspathElements>
                            <argLine>-Dfile.encoding=UTF-8</argLine>
                            <skipTests>${skip.unit.tests}</skipTests>
                        </configuration> 
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.2.201409121644</version>
                        <executions>
                            <execution>
                                <id>pre-unit-test</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
                                    <propertyName>surefireArgLine</propertyName>
                                </configuration>
                            </execution>
                            <execution>
                                <id>post-unit-test</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <configuration>
                                    <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
                                    <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>    
        </profile>
    </profiles>   
</project>

那么,我如何获得Jacoco报告的网站链接?

1 个答案:

答案 0 :(得分:0)

最后,我可以修复我的POM,以便从maven网站获得Jacoco和Surefire报告的链接。

<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>
    ...
    <dependencies>
        <!-- Tests -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        ...
    </dependencies>
    <profiles>
        <profile>
            <id>desarrollo</id>
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                <defaultGoal>clean package</defaultGoal>
                <plugins>    
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>2.5</version>
                        <configuration>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                    <mainClass>com.***.App</mainClass>
                                </manifest>
                            </archive>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>documentacion</id>            
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                <defaultGoal>site:site</defaultGoal>
                <plugins>
                    <!-- Site -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                        <version>3.4</version>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.2.201409121644</version>
                    </plugin>   
                </plugins>
            </build>            
            <reporting>
                <excludeDefaults>true</excludeDefaults>
                <outputDirectory>${project.build.directory}/site</outputDirectory>
                <plugins>
                    <!-- Plugin para generar el site con los reports -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-project-info-reports-plugin</artifactId>
                        <version>2.8</version>
                        <configuration>
                            <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                        </configuration>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>summary</report>
                                    <report>index</report>
                                    <report>dependencies</report>
                                    <report>project-team</report>
                                    <report>license</report>
                                    <report>scm</report>
                                    <report>cim</report>
                                    <report>mailing-list</report>
                                    <report>issue-tracking</report>
                                </reports>  
                            </reportSet>
                        </reportSets>
                    </plugin> 
                    <!-- Reporte tests -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-report-plugin</artifactId>   
                        <version>2.18.1</version>   
                    </plugin>  
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.2.201409121644</version>
                    </plugin>   
                <!-- More report plugins place here (PMD, checkstyle...) -->                    
                </plugins>
            </reporting>
        </profile>
        <profile>
            <id>test</id>            
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <build>
                <defaultGoal>validate test</defaultGoal>
                <plugins>                    
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <outputDirectory>${project.build.directory}/site</outputDirectory>
                            <reportsDirectories>
                                <reportsDirectories>${project.build.directory}/site/surefire-reports</reportsDirectories>
                            </reportsDirectories>
                            <testFailureIgnore>true</testFailureIgnore>                            
                            <additionalClasspathElements>
                                <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                            </additionalClasspathElements>
                            <argLine>${argLine} -Dfile.encoding=UTF-8</argLine>
                        </configuration>        
                        <executions>
                            <execution>
                                <id>default-test</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>  
                    <!-- Test report -->
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.2.201409121644</version>
                        <executions>
                            <execution>
                                <id>default-prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>default-report</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>default-check</id>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>    
        </profile>
    </profiles>   
</project>