mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
106 stars 77 forks source link

can't load global.xjb #41

Closed silvanopessoa closed 8 years ago

silvanopessoa commented 8 years ago

jaxb2-maven-plugin

can't load global.xjb

<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    jaxb:extensionBindingPrefixes="xjc">

    <jaxb:globalBindings>
        <xjc:simple />
        <xjc:serializable uid="-1" />
        <xjc:javaType name="org.joda.time.DateTime" xmlType="xs:dateTime" adapter="br.com.silvano.connect.adapters.DateTimeAdapter" />
        <xjc:javaType name="org.joda.time.LocalDate" xmlType="xs:date" adapter="br.com.silvano.connect.adapters.LocalDateAdapter" />
    </jaxb:globalBindings>
</jaxb:bindings>
<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>JAXB generate content classes</id>
                    <phase>install</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <target>2.0</target>
                        <encoding>UTF-8</encoding>
                        <extension>true</extension>
                        <arguments>
                            <argument>-Xcommons-lang:ToStringStyle=br.com.silvano.connect.util.JsonToStringStyle</argument>
                            <argument>-Xannotate</argument>
                            <argument>-Xcommons-lang</argument>
                        </arguments>
                        <sources>
                            <source>${basedir}/../canonical-schema/src/main/resources/br/com/silvano/schemas/v1/crm</source>
                        </sources>
                        <xjbSources>
                            <xjbSource>src/main/resources/br/com/silvano/xjb/v1</xjbSource>
                        </xjbSources>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>br.com.silvano</groupId>
                    <artifactId>connect-util</artifactId>
                    <version>1.0.0-SNAPSHOT</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                    <version>${commons-lang3-version}</version>
                </dependency>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-commons-lang</artifactId>
                    <version>2.4</version>
                </dependency>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-annotate</artifactId>
                    <version>1.0.1</version>
                </dependency>
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-validator</artifactId>
                    <version>${hibernate-validator-version}</version>
                </dependency>
                <dependency>
                    <groupId>br.com.silvano</groupId>
                    <artifactId>connect-dto</artifactId>
                    <version>1.0.1-SNAPSHOT</version>
                </dependency>
            </dependencies>
        </plugin>
lennartj commented 8 years ago

Note that the schemaLocation path must point to the XSD file relative to the xjb file. Hence, your global.xjb file should contain an attribute called schemaLocation working like the following:

<jxb:bindings schemaLocation="../xsd/address.xsd" node="//xsd:schema">
      <jxb:schemaBindings>
         <jxb:package name="com.example.myschema"/>
      </jxb:schemaBindings>
 </jxb:bindings>