Skip to content

A Gradle plugin to run the XJC binding compiler during a build

License

Notifications You must be signed in to change notification settings

dlmiles/gradle-xjc-plugin

 
 

Repository files navigation

CI-Gradle-build

CI Targets: Java 8 and Java 11 for plugin project builder

Plugin artifact supports Java 8, Java 11, Java 17 and Java 21

For use with Gradle 5.6 through Gradle 8.7

Gradle XJC Plugin

Invokes the xjc binding compiler from a Gradle build.

Features

  • Supports XJC Tool com.sun.xml.bind versions 2.1 (legacy), 2.2, 2.3, 2.4, 3.0 (jakarta) and 4.0 (jakarta) which is the reference implementation now hosted by Eclipse® foundation under the EE4J project.

  • Supports JAXB™ specification -target versions 2.0, 2.1, 2.2, 2.3, 3.0 (jakarta).

  • Automatically enable XJC code generation for each source set in your project. Project structural use of multiple src/<name>/schema/ folders to organise bindings and schemas.

  • Support XJC through classpath isolation to better control visibility of data presented to the tool separate from the Gradle build itself.

  • Producing and consuming episodes.

  • Dependency based catalog sources with maven: and classpath: URI resolution (similar to maven-jaxb2-plugin) as well as the standard file,jar,jar:file,http,https sources.

  • XJC tool plugin extension support, including custom plugins you may provide an implementation for.

Requirements

The Gradle plugin itself:

  • Gradle 5.6 or higher including

    • 5.6 or later using JDK8 or JDK11

    • 7.3 or later using JDK8, JDK11 or JDK17

    • 8.5 or later using JDK8, JDK11, JDK17 or JDK21

  • JDK 1.8 or higher (when running Gradle)

  • See also Gradle build tool Java compatibility matrix at https://docs.gradle.org/current/userguide/compatibility.html for which this plugin is consistent with

The XJC Tool requirements:

  • If using XJC Tool 4.x or later, the XJC Tool requires JDK 11 or higher while this plugin only requires 1.8 or higher, earlier versions of XJC Tool are compatible with JDK 1.8

  • Some specific XJC Tool versions may have been published with incorrect byte code compatibility, resulting in those versions not running on the Java SE version they intended to target

  • See section XJC Tool Runtime Java Compatibility

Quick Start

Apply the org.unbroken-dome.xjc plugin to your Gradle build script and add an appropriate dependency on the JAXB API:

settings.gradle(.kts)
pluginManagement {
    repositories {
        maven {
            //url = uri("https://dlmiles.github.io/gradle-xjc-plugin/java8/maven2")
            url = uri("https://maven.pkg.github.com/dlmiles/gradle-xjc-plugin")
            content {
                // this repository *only* contains artifacts for specific groups
                includeGroup("org.unbroken-dome.xjc")
                includeGroup("org.unbroken-dome")

                includeGroup("org.darrylmiles.forked.org.unbroken-dome.xjc")
                includeGroup("org.darrylmiles.forked.org.unbroken-dome")
            }
            credentials {
                // github requires any valid credentials even to GET packages
                username = System.getenv("GITHUB_USERNAME")
                // this token requires scope 'read:packages'
                password = System.getenv("GITHUB_TOKEN")
            }
        }
    }

    // Official releases only
    gradlePluginPortal()
}
build.gradle(.kts)
plugins {
    id("org.unbroken-dome.xjc") version "2.2.0"
}

dependencies {
    implementation("javax.xml.bind:jaxb-api:2.3.0")
}

Put your schemas (.xsd), binding customization files (.xjb) and catalogs (.cat) into src/main/schema.

That’s it! The plugin will automatically invoke XJC to generate code from your schemas and include it the main Java compilation.

About

A Gradle plugin to run the XJC binding compiler during a build

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Kotlin 100.0%