Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

629 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

jaxb-plugins

XJC plugins that customize JAXB code generation for Jakarta EE (JAXB 3 / XJC 4).

The artifact is discovered by XJC via SPI (META-INF/services/com.sun.tools.xjc.Plugin). Each plugin is opt-in through a -X… command-line option.

Group ID io.github.rawvoid
Artifact ID jaxb-plugins
Java 21+
License Apache License 2.0
Repository https://github.com/rawvoid/jaxb-plugins

Documentation

Full per-plugin reference (options, lifecycle, limits, examples):

wiki/

Requirements

  • Java 21+
  • XJC / JAXB tooling compatible with GlassFish JAXB XJC 4.x (Jakarta namespace)
  • Optional runtime/annotation libraries on the XJC plugin classpath when enabling related plugins:
    • Lombok β€” -Xlombok
    • jackson-annotations β€” -Xjackson
    • Bean Validation API (jakarta.validation preferred) β€” -Xvalidation

Maven dependency

Add jaxb-plugins as a plugin dependency of your XJC Maven plugin (not only as a project compile dependency), then pass plugin arguments to XJC.

Example with org.jvnet.jaxb:jaxb-maven-plugin:

<plugin>
  <groupId>org.jvnet.jaxb</groupId>
  <artifactId>jaxb-maven-plugin</artifactId>
  <version><!-- your version --></version>
  <configuration>
    <args>
      <arg>-Xlombok</arg>
      <arg>-Xjava-time</arg>
      <!-- more -X… options -->
    </args>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>io.github.rawvoid</groupId>
      <artifactId>jaxb-plugins</artifactId>
      <version><!-- release version --></version>
    </dependency>
    <!-- when using -Xlombok / -Xjackson / -Xvalidation, add those APIs here too -->
  </dependencies>
</plugin>

Other XJC integrations (CXF cxf-xjc-plugin, CLI, Gradle, etc.) work the same way: put the jar on the XJC plugin classpath and pass -X… args.

Plugins

Option Role
-Xremove-getter Remove generated property getters
-Xremove-setter Remove generated property setters
-Xlombok Lombok annotations; optional getter/setter removal and builders
-Xconvert-name Custom NameConverter rules during binding
-Xrename-class Rename class/enum/element types in the model
-Xrename-multi-element-prop Rename multi-element properties (items, items2, …)
-Xpromote-nested-class Lift nested beans/enums toward package scope
-Xelement-wrapper Flatten pure collection shells with @XmlElementWrapper
-Xflatten-multi-element-prop Split multi-element properties into single fields
-Xdedupe-class Merge structurally redundant beans
-Xremove-unused-class Remove unreferenced classes and enums
-Xannotate Add/remove custom annotations
-Xgenerated Add @jakarta.annotation.Generated
-Xjackson Class-level Jackson defaults
-Xvalidation Bean Validation constraints from XSD
-Xjava-time Map XSD date/time types to java.time + adapters
-Xnamespace Namespace β†’ package mappings and @XmlSchema prefixes
-Xinheritance Inject implements / extends / Serializable
-Xcommon-interface Generate shared interfaces from common properties

Details, sub-options, and inter-plugin notes: wiki/README.md.

Build from source

mvn clean install

Run tests for the plugins module only:

mvn -pl plugins test

Project layout

jaxb-plugins/
β”œβ”€β”€ plugins/          # main artifact (plugin sources, SPI, tests)
β”œβ”€β”€ wiki/             # user documentation for each plugin
β”œβ”€β”€ pom.xml           # parent POM
└── LICENSE

License

Licensed under the Apache License, Version 2.0.

About

πŸš€ Modern JAXB plugins collection for Java XML binding - XJC plugins with JSR-310 date/time support, annotation processing, and code generation tools

Resources

Stars

25 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages