I’m using the cxf-xjc-plugin to generate java files from xsd. The plugin by default creates the files in the target/generated directory, which makes sense because all stuff that can be generated should be placed there.
But now I can’t work with these java files because they are not listed in the classpath.
What is the best practise to get access to the generated objects? I don’t really want them to be placed in some source directory because then I get tonnes of compiler warning, because the plugin doesn’t generate java code according to my code style settings.
Can the plugin somehow also trigger a compile for these generated files and place the final class files somewhere on the classpath? I can’t find any guidance or examples how other people handle this quite common issue.
A plugin that generates sources should automatically add the folder to the projects compile source roots, to be compiled by the compiler plugin. This will only work if the plugin is bound to the correct lifecycle phase
generate-sources, which happens before thecompilephase.If the cxf plugin does not add the necessary source roots, you could use the build helper plugin to do this manually.