Maven JAXB2 XJC plugin: M2E plugin execution not covered

与世无争的帅哥 提交于 2019-12-02 19:34:52
Steve Perkins

It turns out that I did eventually find an answer! Eclipse's integration with Maven has known compatibility issues with numerous Maven plugins.

When you can successfully run a Maven build from the command-line outside of Eclipse, yet but Eclipse shows "execution not covered" errors in your POM, then try adding this plugin:

<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.codehaus.mojo</groupId>
                                    <artifactId>jaxb2-maven-plugin</artifactId>
                                    <versionRange>[1.3,)</versionRange>
                                    <goals>
                                        <goal>xjc</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

As indicated in the above comment, this plugin doesn't do anything outside of Eclipse. It simply tells Eclipse when to execute the JAXB plugin, since Eclipse isn't smart enough to figure that out on its own.

I found this snippet on another StackOverflow question, and adopted it to the "jaxb2-maven-plugin" plugin rather than the plugin at issue in the the other question.

davidfmatheson

You could also switch to the maven-jaxb2-plugin which has support in M2E. Steve Perkins' answer above is generally applicable for those plugins which M2E doesn't support, though.

I'm not sure if this applies to your environment, but if the app is split into maven modules then the best solution fitting my needs I found so far is to remove all affected modules from eclipse IDE. Whenever I need to regenerate I simply build from command line with mvn install. Eclipse is then using packages from repo and not trying to build on its own, no runOnIncremental fiddle-around needed (which I was using for quite some time), no red modules/lines, builds faster too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!