users@jaxb.java.net

Re: JAXB compilation plugin

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 28 Feb 2006 12:05:51 -0800

Jonathan Johnson wrote:
> Kohsuke and all,
>
> A new, working version 1.0 of the JAXB xjc compiler for Maven 2 has been
> submitted to java.net
>
> https://jaxb.dev.java.net/issues/show_bug.cgi?id=118

Yay!!

> If you are a maven 2 user this means you can invoke the xjc compiler using
> the Sun implementation of JAXB.
>
> There are two (2) dependent jars that are not yet in the maven repository.
> activation.jar and jsr173. My understanding is Kohsuke is working on
> getting these posted. In the meantime you can manually download and install
> them in your local repository. Kohsuke may also be adding this plugin to
> the java.net repository, in the meantime you will have to get the plugin
> source from java.net cvs.

Yes. I plan to add them to the maven repository.


> These instructions will be refined and posted with the plugin once the dust
> settles.
>
> To execute the JAXB xjc compiler for Maven 2 do the following:
>
> 1. Install activation.jar and jsr173 in your local repository
>
> 2. In your maven project create a directory \src\main\schemas and place one
> or more schemas there.
>
> 3. Add to your M2 pom.xml the following dependencies. These dependencies
> are discussed here:
> http://weblogs.java.net/blog/kohsuke/archive/2006/01/jaxb_jars_are_a.html
>
> <dependencies>
> <dependency>
> <groupId>jaxb</groupId>
> <artifactId>jaxb-api</artifactId>
> <version>2.0-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>jaxb</groupId>
> <artifactId>jaxb-impl</artifactId>
> <version>2.0-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>jaxb</groupId>
> <artifactId>jaxb-xjc</artifactId>
> <version>2.0-SNAPSHOT</version>
> </dependency>
> </dependencies>

Does people need to specify jaxb-xjc as the dependency? I thought only
the plugin depends on jaxb-xjc and not user app.

Also, I wonder if it's possible for us to define an m2 repository on
java.net so that jaxb-impl can specify a transitive dependency to jaxb
api and etc.


Do you have access to the www/ portion of the JAXB project? If you need
it to host your documentation, let me know. Also, we should think about
how to upload your plugin to the maven repository.


> 4. Add to your M2 pom.xml the following plugin. This plugin will not
> automatically download from the java.net repository yet but you can get the
> source from
>
> <plugin>
> <groupId>com.sun.tools.xjc.maven2</groupId>
> <artifactId>maven-jaxb-plugin</artifactId>
> <executions>
> <execution>
> <phase>generate-sources</phase>
> <goals>
> <goal>generate</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
> <includeSchemas>
> <includeSchema>catalog.xsd</includeSchema>
> </includeSchemas>
> <generatePackage>com.foo</generatePackage>
> <verbose>true</verbose>
> </configuration>
> <dependencies>
> <!--activation.jar can be manually installed in your
> local-->
> <!--Maven 2 repository from
> http://java.sun.com/products/javabeans/glasgow/jaf.html-->
> <dependency>
> <groupId>javax.activation</groupId>
> <artifactId>activation</artifactId>
> <version>1.0.2</version>
> </dependency>
>
> <!--jsr173.jar can be manually installed in your
> local-->
> <!--Maven 2 repository from
> http://www.ibiblio.org/maven/xmlbeans/jars-->
> <dependency>
> <groupId>javax.xml</groupId>
> <artifactId>jsr173</artifactId>
> <version>1.0</version>
> </dependency>
> </dependencies>
> </plugin>
>
> 4. In the above example change the <includeSchema> to one or more of your
> source schemas. Set the <generatePackage> to your desired package to
> generate.
>
> 5. From the command line execute the xjc compiler by invoking the maven 2
> lifecycle phase 'generate-sources' or the goal 'compile'.
>
> mvn generate-sources
>
> The xjc compiler will generate the java source files based on the xsd files
> found in includeSchemas.
>
>
>
> Additional information...
>
> This Maven 2 plugin is an adapter to the class com.sun.tools.xjc.XJC2Task.
> Most of its settings are passed from this plugin.
> https://jaxb-architecture-document.dev.java.net/nonav/doc/com/sun/tools/xjc/
> XJC2Task.html
>
> This plugin configuration settings are:
>
> <configuration>
> <!-- The source directory containing *.xsd schema and *.xjb binding files.
> <schemaDirectory></schemaDirectory>
>
> <!-- A list of regular expression file search patterns to specify the
> schemas
> to be processed. Searching is based from the root of schemaDirectory. If
> this is not set then all .xsd files in schemaDirectory will be
> processed. -->
> <includeSchemas></includeSchemas>
>
> <!-- A list of regular expression file search patterns to specify the
> schemas
> to be excluded from the includeSchemas list. Searching is based from
> the
> root of schemaDirectory. -->
> <excludeSchemas></excludeSchemas>
>
> <!-- A list of regular expression file search patterns to specify the
> binding
> files to be processed. Searching is based from the root of
> schemaDirectory. If this is not set then all .xjb files in
> schemaDirectory will be processed. The binding file that will be applied
> to the schema file. -->
> <bindings></bindings>
>
> <!-- If specified, generated code will be placed under this Java
> package. -->
> <generatePackage></generatePackage>
>
> <!-- Generated code will be written under this directory. If you specify
> target="doe/ray" and generatePackage="org.here", then files are generated
> to doe/ray/org/here. -->
> <generateDirectory></generateDirectory>
>
> <!-- Generate Java source files in the read-only mode if true is specified.
> false by default. -->
> <readOnly></readOnly>
>
> <!-- If set to true, the XJC binding compiler will run in the extension
> mode.
> Otherwise, it will run in the strict conformance mode. The default is
> false. -->
> <extension></extension>
>
> <!-- Specify the catalog file to resolve external entity references.
> Support
> TR9401, XCatalog, and OASIS XML Catalog format. See the catalog-resolver
> sample and this article for details. -->
> <catalog></catalog>
>
> <!-- Used in pair with nested <produces> elements. When this attribute is
> specified as "true", the files pointed to by the <produces> elements will
> be all deleted before the XJC binding compiler recompiles the source
> files. See the up-to-date check section for details. Default is
> false. -->
> <removeOldOutput></removeOldOutput>
>
> <!-- If verbose all the configured settings that are to be passed to the
> xjc
> compiler are logged. -->
> <verbose></verbose>
> </configuration>
>
>
>
> References
>
> Maven 2
> http://maven.apache.org/
>
> Maven 2 plugin matrix
> http://docs.codehaus.org/display/MAVEN/Maven+Plugin+Matrix
>
> Kohsuke Kawaguchi's Blog on JAXB jars are available on Maven repository
> http://weblogs.java.net/blog/kohsuke/archive/2006/01/jaxb_jars_are_a.html
>
> JAXB xjc compiler for Maven 2. Java.net issue tracking
> https://jaxb.dev.java.net/issues/show_bug.cgi?id=118
>
> Java.net Maven Repository
> https://maven-repository.dev.java.net/
>
> JavaBeans Activation Framework
> http://java.sun.com/products/javabeans/glasgow/jaf.html
>
> jsr173.jar
> http://www.ibiblio.org/maven/xmlbeans/jars-->
>
> The XJC2Task JavaDoc
> https://jaxb-architecture-document.dev.java.net/nonav/doc/com/sun/tools/xjc/
> XJC2Task.html
>
> The java.net maven repository.
> https://maven-repository.dev.java.net/nonav/repository/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com