Reputation: 100000
Kind of tired of not knowing this. "report" is not a maven lifecycle. How do we tell Maven to run reporting during a certain lifecycle. If "report" is not a lifecycle or phase, then what does <goal>report</goal>
actually mean? When will report get run? How do we run it directly/only?
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Vexingly, when I run this:
mvn org.jacoco.jacoco-maven-plugin:report
or this:
mvn jacoco-maven-plugin:report
I get this error:
[ERROR] No plugin found for prefix 'org.jacoco.jacoco-maven-plugin' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/oleg/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
When I run this:
mvn clean prepare-package
then I get an output directly as I would hope for:
target/site/jacoco
but I don't understand why the mvn jacoco-maven-plugin:report
commands would fail.
Upvotes: 0
Views: 682
Reputation: 35795
For the theory:
Maven has goals, phases and lifecycles.
A lifecycle consists of a sequence of phases. Each phase will execute a number of attached goals. A goal is the actual code that will be executed.
When you tell Maven to execute a phase, it will run the lifecycle from the beginning up to that phase. When you tell Maven to execute a goal, it will just run that goal. Goals and phases can be easily distinguished, as goals have :
in their name.
In your first snippet, you attached the goal report
to the phase prepare-package
, so it will run if you call mvn prepare-package
or any later phase as mvn install
.
If a plugin is already defined in the POM (or parent POM, or Maven super POM), you can call it on the command line with mvn jacoco-maven-plugin:report
. Otherwise you need a fully qualified name in the form mvn groupId:artifactId:version:goal
.
Upvotes: 4
Reputation: 455
report is a goal defined in JaCoCo Maven plug-in.
Please check this.
https://www.eclemma.org/jacoco/trunk/doc/maven.html
Usage of plugin together with maven-site-plugin without explicit selection of reports might lead to generation of redundant aggregate reports. Specify reportSets explicitly to avoid this:
<project>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<!-- select non-aggregate reports -->
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
Upvotes: 1