Reputation: 145
What happens for me is that every time there is a maven build, all my files get regenerated. I don't want that since i have made no changes to my .xsd file and what happens is that, because they were regenerated, git treats them as there were changes to those files.
Here's my configuration:
<execution>
<id>myExecution</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/MySchema.xsd</schemaDirectory>
<generatePackage>com.mypackage</generatePackage>
<generateDirectory>src/main/java</generateDirectory>
<episode>false</episode>
</configuration>
</execution>
is there a way arround this?
Upvotes: 1
Views: 2542
Reputation: 1608
I'm also looking for the same solution you need.
To avoid time consuming in recompile code each time, in maven i've created two profile.
The first profile is used only for re-create classes from XSD: the plugin is inside the profile
<profile>
<id>create-from-xsd</id>
<plugins>
<plugin>
... maven jax plugin ...
</plugin>
<plugins>
<profile>
and then the other profile without the plugin.
When I need jax-b, I select the profile 1 and the classes are generated; In the other cases I use profile 2.
Upvotes: 0
Reputation: 19445
Never ever write generated source into the src/main/java directory. Just use the default generateDirectory value (${project.build.directory}/generated-sources/xjc) - it's automatically added to the compile sources.
It is best practice to place all artifacts generated by the build process into the maven target directory (aka ${project.build.directory}).
Also, I recommend that you use the Codehaus JAXB-2 Maven Plugin as it seems to be much better maintained.
Upvotes: 2