Maven 3 JavaDoc Plugin Conflicts with TestNG Groups

半腔热情 提交于 2019-12-10 15:42:58

问题


I have the following:

<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 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:

[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.


回答1:


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".

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>

Then use the property in the surefire configuration:

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

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

mvn install -Dsurefire.groups=somegroup


来源:https://stackoverflow.com/questions/24441210/maven-3-javadoc-plugin-conflicts-with-testng-groups

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!