Maven 3 JavaDoc插件与TestNG组冲突 [英] Maven 3 JavaDoc Plugin Conflicts with TestNG Groups

查看:96
本文介绍了Maven 3 JavaDoc插件与TestNG组冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下内容:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>${maven-javadoc-plugin.version}</version>
    <executions>
        <execution>
            <id>javadoc-jar</id>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

在包装或安装过程中可以正常工作的

Which works fine during packaging or installing:

mvn install或mvn软件包,但是,当我尝试指定要为测试运行的TestNG组时:

mvn install or mvn package, however, as soon as I try to specify a TestNG Group to run for the tests:

mvn install -Dgroups=somegroup

测试完成运行后失败,并显示以下错误:

it fails with the following error after tests finish running:

[错误]无法执行目标org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar(javadoc-jar) 在项目ibd.database.api上:无法解析mojo的配置 org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar作为参数 #:在org.apache.maven.plugin.javadoc.options.Group类中找不到默认设置器

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (javadoc-jar) on project ibd.database.api: Unable to parse configuration of mojo org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar for parameter #: Cannot find default setter in class org.apache.maven.plugin.javadoc.options.Group

感谢您提供任何信息或指导.

Thanks for any info or guidance on this.

推荐答案

问题是surefire和javadoc插件都使用-Dgroups参数,在您的情况下,javadoc插件找不到"somegroup".

The problem is that both the surefire and javadoc plugins use the -Dgroups parameter, and in your case the javadoc plugin cannot find the "somegroup".

据我所知,目前尚无干净的解决方案,但是您可以通过在pom.xml中定义自定义属性来解决此问题:

As far as I know there is no clean solution for this, but you can do a workaround by defining a custom property in your pom.xml:

<properties>
    <surefire.groups></surefire.groups>
</properties>

然后在surefire配置中使用该属性:

Then use the property in the surefire configuration:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    ...
    <configuration>
         <groups>${surefire.groups}</groups>
    </configuration>
</plugin>

现在,您可以使用surefire.groups属性从命令行运行测试:

Now you can run the tests from command line using the surefire.groups property:

mvn install -Dsurefire.groups=somegroup

这篇关于Maven 3 JavaDoc插件与TestNG组冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆