BnJ
BnJ

Reputation: 1044

Add generated sources to classpath

I use maven-jaxb2-plugin. It generate my classes in the correct directory, but on Eclipse Neon.2 Release (4.6.2), the folder is not automaticaly added to the classpath.

Here is my plugin config :

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.13.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <addCompileSourceRoot>true</addCompileSourceRoot>
                <generateDirectory>${project.build.directory}/generated-sources/jaxb</generateDirectory>
                <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                <generatePackage>foo.bar.pojo</generatePackage>
            </configuration>
        </plugin>
    </plugins>
</build>

Is it possible with maven-jaxb2-plugin to define the genearted directory as source folder ? If yes, how ?

Eclipse shows me an error in the pom.xml on <execution> :

Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate: com/sun/xml/bind/api/ErrorListener

Upvotes: 1

Views: 1957

Answers (1)

BnJ
BnJ

Reputation: 1044

To fix my problem, I had to change the version of the plugin.

From :

<version>0.13.1</version>

To :

<version>0.12.1</version>

Upvotes: 2

Related Questions