XJC episode with maven

馋奶兔 提交于 2019-12-25 04:21:12

问题


How can I generate an episode with maven? I now get an error message: an operand is missing (org.apache.cxf:cxf-xjc-plugin:2.4.0:xsdtojava:generate-sources:generate-sources)

Here my plugin:

<plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-xjc-plugin</artifactId>
            <version>2.4.0</version>
            <configuration>
                <extensions>
                    <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.4.0</extension>
                </extensions>
            </configuration>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xsdtojava</goal>
                    </goals>
                    <configuration>
                        <xsdOptions>
                            <xsdOption>
                                <extension>true</extension>
                                <xsd>my.xsd</xsd>
                                <packagename>mypackage</packagename>
                                 <extensionArgs>
                                  <arg>-episode</arg>
                                 </extensionArgs>
                            </xsdOption>
                        </xsdOptions>
                    </configuration>

                </execution>
                <execution>
                 <configuration>
                        <xsdOptions>
                 <xsdOption>
                        <extension>true</extension>
                          <xsd>my.xsd</xsd>
                        <extensionArgs>
                            <arg>-Xdv</arg>
                        </extensionArgs>
                    </xsdOption>
                        </xsdOptions>
                    </configuration>

                </execution>


            </executions>

Edit: Creation of the episode works fine. In another project the jar file containing the episode is given in though the episodes attribute. But I get an Exception: Error while parsing schema(s).Location [ file:/D:/workspace/XXX/src/test/resources/XXX.xsd{45,32}]. om.sun.istack.SAXParseException2: compiler was unable to honor this conversion customization. It is attached to a wrong place, or its inconsistent with other bindings. nested in com.sun.istack.SAXParseException2: (the above customization is attached to the following location in the schema)

Which is the xsd with episode info that will be included in the final product. Its some xjc:javaType adapter reference on that line. Can that cause problems?


回答1:


Different plugin from what you're using, but below snipped used to work for me few years back. You might want to see if more recent version of plugin is available etc. Also tweak to use your schema and remove bindings customization if not needed.

  <plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.7.0</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <schemaDirectory>${basedir}/src/main/xsd</schemaDirectory>
      <schemaIncludes>
        <schemaInclude>Core.xsd</schemaInclude>
      </schemaIncludes>
      <bindingDirectory>${basedir}/src/main/xjb</bindingDirectory>
      <bindingIncludes>
        <bindingInclude>JaxbBindings.xjb</bindingInclude>
      </bindingIncludes>
      <generateDirectory>${project.build.directory}/generated-sources/jaxb</generateDirectory>
      <episode>true</episode>
      <episodeFile>${project.build.directory}/generated-sources/jaxb/META-INF/sun-jaxb.episode</episodeFile>
      <verbose>true</verbose>
    </configuration>
    <dependencies>
      <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.1.10</version>
      </dependency>
      <dependency>
        <groupId>org.jvnet.jaxb2_commons</groupId>
        <artifactId>jaxb-xjc</artifactId>
        <version>2.1.10</version>
      </dependency>
    </dependencies>
  </plugin>


来源:https://stackoverflow.com/questions/9928518/xjc-episode-with-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!