Preeti
Preeti

Reputation: 89

Getting Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (default-cli)

I have an XSD file and I'm trying to generate jaxb classes for that using jaxb2-maven plugin, the problem I generate the classes running the command mvn jaxb2:xjc in command line. If I run the same command as goal in run configuration in eclipse I get

Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (default-cli)

If I only run mvn clean package install the classes are not getting generated. What am I doing wrong?

Here is my part of pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
    <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
    <schemaFiles>Trans.xsd</schemaFiles>
    </configuration>
</plugin>

Upvotes: 1

Views: 8216

Answers (1)

Mohamed
Mohamed

Reputation: 864

Please add a phase element in your execution configuration like this :

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <goals>
                <goal>xjc</goal>
            </goals>
            <phase>validate</phase>
        </execution>
    </executions>
    <configuration>
    <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
    <schemaFiles>Trans.xsd</schemaFiles>
    </configuration>
</plugin>

By doing that, your maven will execute the xjc goal when validating your project

Upvotes: 0

Related Questions