java - 如何使用仅报告目标将 maven-surefire-report-plugin 集成到 maven-site-plugin

标签 java maven pom.xml maven-surefire-plugin maven-site-plugin

我有以下问题:

maven-surefire-report-plugin 调用生命周期目标test。这再次启动我的测试运行程序。为了防止这种情况,他们采取了以下解决方法: http://jira.codehaus.org/browse/SUREFIRE-257

我现在在将其实现到我的 POM 中时遇到困难。 他们在页面上有以下注释:

Note: As of version 2.8 this plugin requires Maven Site Plugin 2.1 or higher to work properly. Version 2.7.2 and older are still compatible with newer surefire versions, so mixing is possible.

我的 Maven 运行:“clean deploy site-deploy”

这是我的 POM 部分:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <configuration>
        <reportPlugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>index</report>
                            <report>dependencies</report>
                            <report>project-team</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <outputDirectory>${project.build.directory}/site</outputDirectory>
                    <reportsDirectories>
                        <reportsDirectories>${project.build.directory}/site/surefire-reports</reportsDirectories>
                    </reportsDirectories>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
            </plugin>
        </reportPlugins>
        <generateReports>true</generateReports>
        <inputEncoding>UTF-8</inputEncoding>
        <outputEncoding>UTF-8</outputEncoding>
    </configuration>
</plugin>

如何将其配置为仅触发 surefire-report:report-only 并且不调用 test 阶段(但其他所有操作均在 站点-阶段)?

最佳答案

在互联网上搜索了几个小时和一些东西后,我终于找到了方法。

目标必须是报告,如下所示:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>2.9</version>
    <configuration>
        <outputDirectory>${project.build.directory}/site</outputDirectory>
        <reportsDirectories>
            <reportsDirectories>${project.build.directory}/site/surefire-reports</reportsDirectories>
        </reportsDirectories>
    </configuration>
    <reportSets>
        <reportSet>
            <id>integration-tests</id>
            <reports>
                <report>report-only</report>
            </reports>
        </reportSet>
    </reportSets>
</plugin>

关于java - 如何使用仅报告目标将 maven-surefire-report-plugin 集成到 maven-site-plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23653625/

相关文章:

java - equals 方法重载时的行为如何?

java - 连续 2 个完整 GC 周期内存未清除

java - Jackson注释: some are seen,有些没有

java - 如何: Run maven integration tests against a test environment (database)

java - 无法解析依赖项: org. springframework.transaction

maven - 在 pom.xml 中设置 Maven 的代理(而不是在 settings.xml 中)

java - 如何将 json 放入 HTTPPost 请求正文中,然后在响应中读取正文

java - 如何让eclipse使用maven下载的包?

java - 试图调用一个不存在的方法...纠正类路径

java - 异步 ejb 方法调用中的事务传播