Regenerate classes after changes in XSD files from maven dependency in maven-jaxb2-plugin

1.2k views Asked by At

I have XSD files in A project, and I generate classes in B project, so my maven configuration of B is like that:

         <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>${maven-jaxb2-plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemas>
                    <schema>
                        <dependencyResource>
                            <groupId>some.group</groupId>
                            <artifactId>some.artifact</artifactId>
                            <version>${project.version}</version>
                            <resource>some.xsd</resource>
                        </dependencyResource>
                    </schema>
                </schemas>
                <generatePackage>some.package</generatePackage>
                <generateDirectory>src/main/gen</generateDirectory>
                <forceRegenerate>false</forceRegenerate>
            </configuration>
        </plugin>

But now, when I change XSD file, that changes are not seen by Eclipse Maven Builder, and classes are not regenerated. When I change forceRegenerate property to true, Eclipse is endless regenerating those classes in infinitive loop.

Is there any solution, other than setting forceRegenerate property to true only when I change something in code?

1

There are 1 answers

0
lexicore On

Disclaimer: I am the author of the maven-jaxb2-plugin.

As I take from your configuration, you compile your schema from a dependency resource:

       <configuration>
            <schemas>
                <schema>
                    <dependencyResource>
                        <groupId>some.group</groupId>
                        <artifactId>some.artifact</artifactId>
                        <version>${project.version}</version>
                        <resource>some.xsd</resource>
                    </dependencyResource>
                </schema>
            </schemas>
            <generatePackage>some.package</generatePackage>
            <generateDirectory>src/main/gen</generateDirectory>
            <forceRegenerate>false</forceRegenerate>
        </configuration>

I.e. from a Maven artifact.

Maven artifacts are currently not checked for actuality, please file an feature request here.