- What I am trying to achieve:
Run the maven spotbugs (findbugs) plugin during mvn site
command, but not mvn clean install
.
- What did I try:
I tried putting the spotbugs plugin in the build section of the pom.xml
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.2.0</version>
<configuration>
<outputDirectory>target/reports/findbugs</outputDirectory>
</configuration>
</plugin>
and I also put it in the reporting section of the pom in the reporting section of the pom
<reporting>
<plugins>
<plugin>
Either way, it seems when running mvn site spotbugs:spotbugs
, the plugin is running and trying to find bugs.
- Question
I would like the plugin not to run at mvn clean install time, but to run at mvn site time.
Where is the correct place to add the plugin then? In the build section or the reporting section of the pom?
The
site
lifecycle (maven.apache.org
) has dedicated phases that are executed in the following order:pre-site
site
post-site
site-deploy
These phases are only activated when we execute the
site
lifecycle (i.e. when we callmvn site ...
).If we want a plugin execution to execute only in the
site
lifecycle, we can bind the plugin's execution to one of those phases. For example, if we want to echo a message during thesite
lifecycle, we can use the following snippet:The plugin execution will only be executed when we run
mvn site ...
, but not when we execute, for example,mvn install ...
.