# 3rd Party Tools

## Maven Plugins

To generate &binding.spec.name; classes from an XML schema in Maven project, there are multiple community plugins available:

- The most advanced and feature-full Maven plugin for XML Schema compilation: highsource maven-jaxb2-plugin

  Using highsource maven-jaxb2-plugin

      <build>
          <plugins>
              <plugin>
                  <groupId>org.jvnet.jaxb2.maven2</groupId>
                  <artifactId>maven-jaxb2-plugin</artifactId>
                  <executions>
                      <execution>
                          <goals>
                              <goal>generate</goal>
                          </goals>
                      </execution>
                  </executions>
              </plugin>
          </plugins>
      </build>

  See the maven-jaxb2-plugin user guide for configuration details.

- A Maven plugin originating from MojoHaus which has been updated for &binding.spec.name; 3+ by Evolved Binary: MojoHaus jaxb-maven-plugin

  Using MojoHaus jaxb-maven-plugin

      <build>
          <plugins>
              <plugin>
                  <groupId>com.evolvedbinary.maven.mojohaus</groupId>
                  <artifactId>jaxb-maven-plugin</artifactId>
                  <executions>
                      <execution>
                          <id>schemagen</id>
                          <goals>
                              <goal>schemagen</goal>
                          </goals>
                      </execution>
                  </executions>
              </plugin>
          </plugins>
      </build>

  See the MojoHaus jaxb-maven-plugin documentation for configuration details.

- A Maven plugin originating from java.net which has been updated for &binding.spec.name; 3+ by Evolved Binary: jvnet jaxb-maven-plugin

  Using jvnet jaxb-maven-plugin

      <build>
          <plugins>
              <plugin>
                  <groupId>com.evolvedbinary.maven.jvnet</groupId>
                  <artifactId>jaxb-maven-plugin</artifactId>
                  <executions>
                      <execution>
                          <id>generate</id>
                          <goals>
                              <goal>generate</goal>
                          </goals>
                      </execution>
                  </executions>
              </plugin>
          </plugins>
      </build>

  See the jvnet jaxb-maven-plugin documentation for configuration details.

Alternatively to community plugins, there are tooling artifacts jaxb-xjc and jaxb-jxc, which can be used for java from XML schema generation and vice versa.

Using &binding.impl.name; tooling artifacts

    <!-- Tooling dependencies -->
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-xjc</artifactId>
        <version>&version;</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-jxc</artifactId>
        <version>&version;</version>
    </dependency>

    <!-- Invoke tooling API (Java 11) -->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
            <!-- Generate java sources from schema -->
            <execution>
                <id>xjc</id>
                <goals>
                    <goal>exec</goal>
                </goals>
                <configuration>
                    <executable>java</executable>
                    <arguments>
                        <argument>--module-path</argument>
                        <modulepath/>
                        <argument>-m</argument>
                        <argument>com.sun.tools.xjc</argument>
                        <argument>-p</argument>
                        <argument>com.example</argument>
                        <argument>-d</argument>
                        <argument>${project.build.directory}/generated-sources</argument>
                        <argument>${project.build.directory}/classes/schema.xsd</argument>
                    </arguments>
                </configuration>
            </execution>

            <!-- Generate XML Schema from sources -->
            <execution>
                <id>jxc</id>
                <goals>
                    <goal>exec</goal>
                </goals>
                <configuration>
                    <executable>java</executable>
                    <arguments>
                        <argument>--module-path</argument>
                        <modulepath/>
                        <argument>-m</argument>
                        <argument>com.sun.tools.jxc</argument>
                        <argument>-d</argument>
                        <argument>${project.build.directory}/generated-sources</argument>
                        <argument>${project.build.directory}/classes/com/example/Author.java</argument>
                        <argument>${project.build.directory}/classes/com/example/Book.java</argument>
                    </arguments>
                    <longModulepath>false</longModulepath>
                </configuration>
            </execution>
        </executions>
    </plugin>

See also xml schema compiler usage.

`schemagen` and `xjc` command line scripts are available only in the zip distribution.

## XJC Plugins

Various people in the community have developed plugins for XJC that you can use today. These plugins allow you to enhance/alter the code generation of XJC in many different ways. See for example JAXB2 Basics Pligins.

## RDBMS Persistence

Lexi has developed the HyperJAXB3 project for RDBMS persistence support for the &binding.impl.name;.