0

I am very new to Maven, and I am facing the situation that I need to execute plugin specified in pom.xml which generates java classes from xsd. This plugin is specified in build section so I need to compile all the code before it is triggered. Is there some way how to trigger the plugin with all its configuration specified in pom.xml directly?

I have searched online and the suggested way was to call

mvn org.apache.cxf:cxf-xjc-plugin:2.6.1:xsdtojava

(this is my plugin), but I am getting error Must specify xsdOptions, so from my understanding it is just calling the plugin without he config specified in pom.xml.

If someone could help me, it would be great. I can not edit the pom.xml!

Jakub Znamenáček
  • 766
  • 1
  • 4
  • 18
  • First show your pom file ...the question is: `I can not edit the pom.xml!` what do mean by that? If you have to change to get it working you have to change the pom.xml file... – khmarbaise Jan 26 '22 at 09:14
  • It should be working, just when I have to generate the java classes I first need to compile all the code. I wanted to know, if there is way how to just generate the java classes without compiling the code. – Jakub Znamenáček Jan 26 '22 at 09:16
  • It's not possible to override plugin configs unless you first replace them with project properties. See https://stackoverflow.com/a/35048568/410939 – Alex Jan 26 '22 at 09:24
  • Hi Alex, thanks for reply, actually I am not trying to override the config from the pom.xml. I would like to use it. But for some reason when I run the command it my question, it is complaining that xsdOptions are not specified, but they are in the pom.xml. When I run maven install, the plugin is triggered and generates the java classes correctly. I would just like to generate the code without starting the compilation of the code. – Jakub Znamenáček Jan 26 '22 at 09:32
  • Integrate the calling of the generation into your pom file thats the only solution. Afterwards you can simply build by: `mvn clean verify`... nothing special needed to be done (it's easier not only for you also for others...) – khmarbaise Jan 26 '22 at 09:42
  • @JakubZnamenáček Calling the plugin directly on the cli like you do ignores any other config in the pom.xml (as you noticed). Plugins from the pom.xml are configured to run with a maven phase, so there's no way to run only the plugin. Did you try running `mvn generate-sources`? It will really help to see your pom.xml and the relevant plugin definition. – Alex Jan 26 '22 at 10:57

0 Answers0