users@maven-jaxb2-plugin.java.net

Compiling schemas located in jars

From: David J. M. Karlsen <david_at_davidkarlsen.com>
Date: Sat, 05 Dec 2009 16:56:47 +0100

Hi!

I have a problem I hope you can help me with on the list.
I want my schemas to be distributed in a separate jar, and depend on
this jar in other projects - and in these other projects I want to use
the jaxb2 maven2 plugin to generate the jaxb code.

I've been looking into the episodes and catalog examples - but they
don't math my usecase totally.

Some more info:
schemas.jar has this structure:
JAR_ROOT/xsd/eba/sct/pacs.002.001.02S2.xsd
(The schema defines the namespace
xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.002.001.02S2")

then in some other project I have:

<plugins>
      <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.7.2</version>
        <configuration>
          <forceRegenerate>true</forceRegenerate>
          <extension>true</extension>
          <args>
            <arg>-Xfluent-api</arg>
          </args>
          <plugins>
            <plugin>
              <groupId>net.java.dev.jaxb2-commons</groupId>
              <artifactId>jaxb-fluent-api</artifactId>
              <version>2.1.8</version>
            </plugin>
            <plugin>
              <!-- this is the artifact that contains the schema files -->
              <groupId>com.te.schemas</groupId>
              <artifactId>schemas</artifactId>
            </plugin>
          </plugins>
        </configuration>
        <executions>
          <execution>
            <id>SCT</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              
<catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver>
              <catalog>src/main/resources/catalog.cat</catalog>
              <debug>true</debug>
              <schemaIncludes>
                <schemaInclude>pacs.002.001.02S2.xsd</schemaInclude>
              </schemaIncludes>
              <episodes>
                <episode>
                  <groupId>com.te.schemas</groupId>
                  <artifactId>schemas</artifactId>
                </episode>
              </episodes>
            </configuration>
          </execution>
   

This fails with "no grammar defined".
what should my catalog file look like? And what do schemas.jar need to
contain (besides the schemas obviously).

Until now I've followed:
https://maven-jaxb2-plugin.dev.java.net/docs/guide.html and
http://markmail.org/message/3cls4g3kpetq3rgq#query:com.sun.tools.xjc.BadCommandLineException%3A%20grammar%20is%20not%20specified+page:1+mid:6evdulckwamjyjf4+state:results

but can't get it going.

--
David J. M. Karlsen - +47 90 68 22 43
http://www.davidkarlsen.com
http://mp3.davidkarlsen.com
Sent from my bog-standard SMTP client