Maven JAXB2 XJC plugin: M2E plugin execution not covered

19,219

Solution 1

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.

Solution 2

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.

Share:
19,219
Jean Logeart
Author by

Jean Logeart

All source snippets I post on Stack Overflow are under the CC0 licence ("No Rights Reserved" - public domain).

Updated on June 05, 2022

Comments

  • Jean Logeart
    Jean Logeart almost 2 years

    I am using using the jaxb2 xjc plugin for generating java files from a XSD. Therefore I used to configure my pom.xml as follows:

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <packageName>com.mypackage.model</packageName>
                    <schemaDirectory>${basedir}/src/main/resources/XSD</schemaDirectory>
                </configuration>
            </plugin>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                   <source>1.6</source>
                   <target>1.6</target>
               </configuration>
           </plugin>
        </plugins>
    </build>
    

    I changed my developing environment to Eclipse Indigo and this does not work any more. The error says: "Plugin execution not covered by lifecycle configuration". I understand I have to define the execution of my plugin differently so that it works in my new environment.

    I followed the instructions on this page M2E plugin execution not covered but the source files are not generated when executing the generate-sources phase.

    Could anybody show me how to exactly refactor my pom so that my files are properly generated?

    Thanks for helping!

  • Admin
    Admin over 11 years
    This morning I did the same as above and it fixed my eclipse error.
  • MJar
    MJar almost 8 years
    I use maven-jaxb2-plugin with latest version (0.13.1) in my project and still get the same error in eclipse as shown in the question. Only applying Steve Parkins' answer seams to fix it.