Java – M2e still provides the error that “plug-in execution is not overridden by lifecycle configuration”, even if explicit binding is used in custom plug-ins

I'm building a plug - in for code generation

I have followed the steps here to learn how to create a plug-in: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html

Plug in source:

/**
 * @goal helloworld
 * @phase generate-sources
 */
public class SampleMojo extends AbstractMojo
{
    @Override
    public void execute() throws MojoExecutionException,MojoFailureException
    {
        getLog().info("Hello,world.");
    }
}

Usage:

<plugins>
        <plugin>
            <groupId>com.sample</groupId>
            <artifactId>sample-maven-plugin</artifactId>
            <version>0.0.1</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>                     
                    <goals>
                        <goal>helloworld</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

The plug-in itself works, but in eclipse, I always get the "life cycle not covered" error

I read through "how to solve" plugin execution not covered by lifecycle configuration "for spring data Maven builds". I think if I create my own plug-in and set @ phase and @ goal annotations, it will get rid of this error I really don't want to put the "lifecycle mapping metadata" node in POM

Does anyone have any suggestions on this? Do I need to write something special for M2e to make the error disappear?

Solution

K. Claszen's answer is correct, but I want to fill in some additional details

A. Why M2e do you like this?

The key to this behavior is to prevent M2e consuming too many resources through incremental (and possibly endless) changes

B. M2e version 1.1 is not 'released'

Currently M2e 1.1 is still a milestone Users need to use this update site to install / upgrade to it: http://download.eclipse.org/technology/m2e/milestones/1.1 (I also have to uninstall 'M2e SCM connector' to upgrade it)

Now, except in its POM It may be more troublesome for your users to insert "quick fix" code snippets outside the XML file But in the long run, using it is a good thing

C. Overview of making your Maven plugin m2e-1.1 compatible

As K. claszen described, most of the information is here: M2e compatible Maven plugins

Some key points:

>The execution information is defined in the file – Src / main / resources / meta inf / M2e / lifecycle mapping metadata XML – for format, see M2e compatible Maven plugins. > If you have enabled incremental execution, mojo will need to communicate correctly with the Maven API:

>Specify for org codehaus. plexus / plexus-build-api / 0.0. 1 dependencies (current content at the time of writing) > use org codehaus. plexus. build. incremental. Buildcontext to: > check whether the relevant resources have changed > notify Maven about the relevant write operations performed by the plug-in so that it knows the compilation source, etc

D. Substitutes

If 1.1 is not a realistic choice for your users, you can:

>Create an 'M2e extension Eclipse Plug-in' (!!!), Also known as' M2e connector 'and contribute it to the market Good luck. > Inform your plug-in user to select M2e 'quick repair', and then manually change < ignore / > line to < execute / > There are other so questions / answers that cover this

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>