Could not find goal 'setup' in plugin org.apache.maven.plugins:maven-clover-plugin:2.4
Symptoms
When integrating Clover into a build, for example:
mvn clean clover:setup test clover:aggregate clover:clover
the build fails with an error like this:
[ERROR] Could not find goal 'setup' in plugin org.apache.maven.plugins:maven-clover-plugin:2.4 among available goals aggregate, check, instrumentInternal, instrument, log, clover, save-history -> [Help 1]
org.apache.maven.plugin.MojoNotFoundException: Could not find goal 'setup' in plugin org.apache.maven.plugins:maven-clover-plugin:2.4 among available goals aggregate, check, instrumentInternal, instrument, log, clover, save-history
Cause
1) The maven-clover2-plugin is declared in pom, but goals called from a command line have the 'clover' prefix.
or
2) Neither the clover-maven-plugin is declared in pom.xml nor the <pluginGroup>com.atlassian.maven.plugins</pluginGroup> in .m2/settings.xml and you use goals prefixed with 'clover' from a command line.
Resolution
Clover plugin for Maven has been renamed in Clover 4.1. Therefore:
- for Clover 3.x.x and Clover 4.0.x the plugin is named com.atlassian.maven.plugins:maven-clover2-plugin and thus goals have the clover2 prefix
- since Clover 4.1.1 the plugin is named com.atlassian.maven.plugins:clover-maven-plugin and thus goals have the clover prefix
1) Declare the com.atlassian.maven.plugins pluginGroup in .m2/settings.xml to ensure that Maven will not try to resolve 'clover' goals to a very old Clover 2.4 (org.apache.maven.plugins:maven-clover-plugin).
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
<pluginGroup>com.atlassian.maven.plugins</pluginGroup>
</pluginGroups>
...
</settings>
2) Upgrade to Clover 4.1.1 or newer and use goals with the 'clover' prefix (e.g. 'mvn clean clover:setup test clover:clover').
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.1.1</version>
</plugin>
3) In case you must stay with Clover older than 4.1.1, use goals with the 'clover2' prefix (e.g. 'mvn clean clover2:setup test clover2:clover').
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>4.0.6</version>
</plugin>