Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven 3 JavaDoc Plugin Conflicts with TestNG Groups

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.

like image 827
Luis R. Avatar asked Jun 26 '14 22:06

Luis R.


1 Answers

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
like image 184
Joakim Mjärdner Avatar answered Nov 07 '22 17:11

Joakim Mjärdner