I am trying to build my maven project which creates POJOs from .xds schema files. I am using cxf-xjc-plugin for xjc execution using below plugin definition.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>xjc</id>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
<configuration>
<sourceRoot>src/main/java/</sourceRoot>
<xsdOptions>
<xsdOption>
<xsd>src/main/resources</xsd>
<packagename>com.myapp.myXmlPojo</packagename>
</xsdOption>
</xsdOptions>
</configuration>
</execution>
</executions>
</plugin>
It fails with below error even when 'src/main/java' directory exists:
[DEBUG] Exception in thread "main" com.sun.tools.xjc.BadCommandLineException: cowardly refuses to write to a non-existent directory "src/main/java" [DEBUG] at com.sun.tools.xjc.Options.parseArgument(Options.java:524) [DEBUG] at com.sun.tools.xjc.Options.parseArguments(Options.java:827) [DEBUG] at org.apache.cxf.maven_plugin.XSDToJavaRunner.run(XSDToJavaRunner.java:170) [DEBUG] at org.apache.cxf.maven_plugin.XSDToJavaRunner.main(XSDToJavaRunner.java:360)
I tried deleting src folder and observed it recreates src/main/java but does not copy the POJOs and fails with above mentioned error. Please advise.
It probably doesn't like you using
src/main/java
as the location for writing generated java classes since that's the default location for non generated classes. Try changing this value to something under the target folder, like${basedir}/target/generated/src/main/java