Maven auto-clean on package - eclipse

I'm having some troubles trying to auto-clean each time i run mvn package.
I've added in the POM :
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
But i'm getting the following error from M2Eclipse :
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-clean-plugin:2.5:clean (execution: auto-clean, phase: initialize)
I've tried other phases like "validate" or "generate-resources" but i'm always getting the same error.

It's not a Maven problem, it's m2eclipse. I haven't used it in a long time, but apparently when you add some plugin executions, you have to add additional configuration to m2eclipse. There's a lengthy description of this error on the Eclipse wiki.

Related

maven: Plugin execution not covered by lifecycle configuration

I use eclipse and have included following dependency in my pom.xml:
<dependency>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.7</version>
</dependency>
When using this plugin:
<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.7</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
I get this error within eclipse ide:
Plugin execution not covered by lifecycle configuration:
org.jboss.jandex:jandex-maven-plugin:1.0.7:jandex
(execution: make-index, phase: process-classes)
when clicking to "Discover new m2 connectors", I get the error:
No marketplace entries found to handle jandex-maven-plugin:1.0.7:jandex in Eclipse.
Please see Help for more information.
How can I solve this?
Solution:
Added <?m2e ignore?> in pom.xml:
<!-- https://www.eclipse.org/m2e/documentation/release-notes-17.html#new-syntax-for-specifying-lifecycle-mapping-metadata -->
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version><dependency>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.7</version>
<executions>
<execution>
<!-- added: -->
<?m2e ignore?>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
The Jandex plugin doesn't have a connector for Eclipse.
Just add an ignore rule. Eclipse will do that for you if you choose the right option and will add an ignore rule to your pom.xml.
Turns out1 that you should not ignore Jandex plugin in Eclipse. Otherwise your #QuarkusTests might fail with ArC/CDI errors.
I've created a PR adding the required m2e config to the plugin2. Once that is merged and released there should be no lifecycle issue anymore.
1 https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Jandex-Plugin.20in.20Eclipse.20m2e
2 https://github.com/wildfly/jandex-maven-plugin/pull/18
Looks like there is a updated Jandex version 1.0.8 that may have fixed this problem. I was referencing the quarkus documentation on a multi-module-maven which links to 1.0.7. I had a few issues running in quarkus:dev mode. Once I realized there was a 1.0.8 update, all my problems went away.

Maven exec plugin not running

I am trying to executing a powershell script that writes to a file during a maven build.
I am invoking the build with mvn clean install through Eclipse IDE.
This is the plugin in my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/.my-file.ps1</executable>
</configuration>
</plugin>
</plugins>
The powershell script is a hidden file so that's why I have a . in front of the file name.
However, the plugin is not executing and I am following the instructions in the official documentation.
You are running mvn clean install which will go through various build phases, but your exec plugin execution is not attached to any phase. You'll have to either:
Attach your execution to a phase by adding the <phase> element to your execution, for example to attach it to the pre-integration-test phase:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>my-exec</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/.my-file.ps1</executable>
</configuration>
</plugin>
Or call specifically the exec goal using mvn exec:exec command.
If you are not familiar with the Maven lifecycle and various phases of a build, read the Introduction to the Build Lifecycle guide, or specifically the Plugins part to learn more about plugins executions and phases attachment.

Maven Javadoc - Unable to generate Javadoc

I have the following dependency and build in my pom file. I'm able to manually create the javadoc with a Maven command. I can also succesfully perform a build. The output doesn't mention javadoc at all. I've also tried leaving out the output directory paths. POM File
Dependency section:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
</dependency>
and then the build section:
<build>
<finalName>D</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<outputDirectory>${project.build.directory}/javadoc</outputDirectory>
<reportOutputDirectory>${project.reporting.outputDirectory}/javadoc</reportOutputDirectory>
<version>2.8</version>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The Maven Javadoc plugin doesn't run by default and needs to be bound to one of the default Maven lifecycle phases.
Here's how I would write the plugin's configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<outputDirectory>${project.build.directory}/javadoc</outputDirectory>
<reportOutputDirectory>${project.reporting.outputDirectory}/javadoc</reportOutputDirectory>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>site</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
Notice how I added an extra phase element to the execution. This will bind it to the "site" goal so that javadocs are generated when you run mvn site. Check Introduction to the Build Lifecycle if you want one of the default Java build phases.
Also note that I ditched the version parameter; by default, it should use your POM's version anyway.

Plugin error: execution not covered by lifecycle configuration

I am trying to use the maven-warpath-plugin available here. But I keep getting an error in my pom.xml file that says:
Plugin execution not covered by lifecycle configuration: org.appfuse.plugins:maven-warpath-plugin:2.1.0:add-classes (execution: default, phase: generate-sources)
How do I resolve this? Here is my pom.xml snippet for the plugin:
<plugin>
<groupId>org.appfuse.plugins</groupId>
<artifactId>maven-warpath-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>add-classes</goal>
</goals>
</execution>
</executions>
</plugin>
Eclipse offers me a quickfox tip to "discover new m2e connectors" to resolve this error. I have installed most of the connectors available that seem to apply but the error is still there. Any ideas how I could make this work?
This is the new behaviour of m2e (which replaced the old m2eclipse plugin). To specify what eclipse should do with the plugin you have to configure the build lifecycle mapping in the project's pom.xml - or install a connector (which decides if the plugin needs to be executed in an eclipse build or not) if it exists.
As there seems to be no connector for the maven-warpath-plugin yet you have to define the behaviour in the pom. You can use the second eclipse quickfix for this (Permamnently mark goal add-classes in pom.xml as ignored in eclipse build). This will add the following section to your pom:
<build>
......
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.appfuse.plugins
</groupId>
<artifactId>
maven-warpath-plugin
</artifactId>
<versionRange>
[2.1.0,)
</versionRange>
<goals>
<goal>add-classes</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
You can change the <ignore> action to <execute> if you want to process the plugin in each eclipse build (on import, clean, ...).
The plugin configuration is eclipse specific and does not make the pom.xml look nicer - but at least it has no influence on the Maven build....
Also see the answer How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds
Error pom.xml: Plugin execution not covered by lifecycle configuration: org.bsc.maven:maven-processor-plugin:3.3.3:process
my project is ProjectA, it's created by maven version 3.3.3 and i used eclipse version 4.5. But when install eclipse version 2021 - 4.20, then I open projectA on eclipse (version 4.20) errors appear in pom.xml: error detail: Plugin execution not covered by lifecycle configuration: org.bsc.maven:maven-processor-plugin:3.3.3:process (execution: process, phase: process-resources)
I don't know why appears on eclipse's new version 4.20. Error appear "execution"
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-resources</phase>
<configuration>
Thank you very much for help!

Clover+Maven+Eclipse

I am using eclipse + maven2 to build my applications.
I need to start working with clover.
My question is therefore: from your experience, what is the best way to combine these 3.
I mean, I know there is a clover plugin for eclipse, there is also a clover plugin for maven2 and of course there is maven plugin for eclipse (m2eclipse - which I am already using).
What should I use and how?
Thank you.
Under Eclipse, use the Clover Eclipse Plugin.
Under Maven, use the Maven Clover Plugin. Add a Clover Report to the site generation:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<configuration>
[...]
</configuration>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
<reporting>
<plugins>
[...]
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<configuration>
[...]
</configuration>
</plugin>
</plugins>
</reporting>
[...]
Optionally, you can check for a test coverage percentage and fail the build in case of non-compliance:
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<configuration>
<targetPercentage>80%</targetPercentage>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>instrument</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
The maven build remains the master. Run it using your preferred method (command line or m2eclipse).
I'm using the clover-report along with the automated site generation by maven. For that you just have to add the clover plugin to your POMs reporting section as describes here. That way you can also get a historical report about your code coverage.
Calling/starting the maven process is done via the m2eclipse plugin and that's it. But you could also use all 3 plugins. So for example install the clover plugin for eclipse so that you don't have to generate the whole site again and again when you only want the code coverage (with the clover plugin for eclipse you can see the coverage right inside eclipse) and use the clover maven plugin to generate a "final" code coverage for any released piece of code. The m2eclipse plugin is not really needed for neither clover-maven nor clover-eclipse but it's nice when working with eclipse and maven.