Supercharge your XML binding with next-gen JAXB plugins!
Tired of boring, boilerplate-heavy JAXB code generation? Say hello to JAXB Plugins Collection β your ultimate toolkit for making XML binding actually fun again! π
This collection of powerful plugins transforms the way you work with JAXB, giving you superpowers to customize, optimize, and streamline your generated code like never before.
Built on a rock-solid foundation with our AbstractPlugin class that makes creating new plugins a breeze. Features annotation-based configuration, automatic option parsing, and extensible text parsers.
Time travel made easy!
Bring your JAXB code into the 21st century with full JSR-310 (java.time) support. Automatically maps XSD date/time types to modern Java time API classes.
π₯ Use Cases:
- Use
LocalDateTimeinstead ofXMLGregorianCalendar - Support
ZonedDateTimefor timezone-aware dates - Custom date formatting with patterns
- Auto-generate XmlAdapter classes
β‘ Quick Start:
-Xjsr310 \
-adapter-package=com.example.adapters \
-mapping \
-xsd-type=dateTime \
-target-class=java.time.LocalDateTime \
-pattern=yyyy-MM-dd HH:mm:ssπ Command Structure:
-Xjsr310 \
-adapter-package=package.name \
-mapping \
-xsd-type=xsdType \
-target-class=java.time.Class \
-pattern=dateFormat \
-adapter=custom.AdapterClass \
-regex=fieldPatternπ― Default Mappings:
xs:dateTimeβLocalDateTimexs:dateβLocalDatexs:timeβLocalTimexs:gYearMonthβYearMonthxs:gYearβYearxs:gMonthDayβMonthDayxs:gDayβIntegerxs:gMonthβMonthxs:durationβDuration
Your annotation wizard!
Add, remove, or customize annotations on generated classes, fields, methods, and packages. Perfect for integrating with frameworks like Jackson, Hibernate, or your custom annotations.
π₯ Use Cases:
- Add
@JsonPropertyannotations for JSON serialization - Inject validation annotations (
@NotNull,@Size) - Add Lombok annotations (
@Data,@Builder,@Accessor) - Remove unwanted JAXB annotations
- Apply custom framework annotations
β‘ Quick Start:
-Xannotate \
-add-to-class \
-anno=@com.example.MyAnnotation \
-regex=.*Person \
-add-to-field \
-anno=@com.fasterxml.jackson.annotation.JsonProperty("value") \
-regex=.*nameπ Command Structure:
-Xannotate \
-add-to-class|-add-to-field|-add-to-method|-add-to-package \
-anno=@AnnotationClass(param="value") \
-regex=pattern \
-remove-from-class|-remove-from-field|-remove-from-method|-remove-from-package \
-anno=AnnotationClass \
-regex=patternThe naming ninja!
Take control of how JAXB converts XML names to Java identifiers. Customize class names, field names, method names, and package names with precision.
π₯ Use Cases:
- Convert snake_case XML to camelCase Java
- Apply custom naming conventions
- Fix awkward auto-generated names
- Map legacy XML to modern Java standards
β‘ Quick Start:
-Xconvert-name \
-class-name \
-token=XMLDocument \
-name=Document \
-variable-name \
-regex=(.*)_ID \
-name=$1Idπ Command Structure:
-Xconvert-name \
-class-name|-variable-name|-interface-name|-property-name|-constant-name|-package-name \
-token=originalName \
-regex=pattern \
-name=newNameThe wrapper eliminator!
Simplify your generated code by automatically flattening wrapper classes. Moves @XmlElementWrapper and @XmlElement annotations to the using field and optionally removes the wrapper class entirely.
π₯ Use Cases:
- Clean up collection wrapper classes
- Reduce boilerplate code
- Improve API readability
- Optimize memory usage
β‘ Quick Start:
-Xelement-wrapper \
-remove-wrapper-class=trueThe namespace navigator!
This plugin is deprecated and may be removed in future versions.
Take control of XML namespace to Java package mappings. Define custom mappings and automatically generate JAXB binding files.
π₯ Use Cases:
- Map namespaces to meaningful package names
- Avoid default package naming conflicts
- Support multiple schema versions
- Clean up package structure
β‘ Quick Start:
-Xnamespace \
-mapping \
-ns=http://example.com/schema \
-package=com.example.schema \
-prefix=exπ Command Structure:
-Xnamespace \
-mapping \
-ns=namespaceURI \
-package=java.package.name \
-prefix=xmlPrefixThe getter ghost!
Remove unnecessary getter methods from generated classes when you only need setters or direct field access.
π₯ Use Cases:
- Create immutable-like structures
- Reduce method count for cleaner APIs
- Optimize for specific use cases
- Custom access patterns
β‘ Quick Start:
-Xremove-getterThe setter slayer!
Remove unnecessary setter methods from generated classes when you only need getters or want read-only objects.
π₯ Use Cases:
- Create read-only DTOs
- Enforce immutability
- Secure data transfer objects
- Clean API design
β‘ Quick Start:
-Xremove-setterThe namespace prefix master!
Take control of XML namespace prefixes in generated @XmlSchema annotations. Define custom mappings between XML namespaces and their prefixes, and automatically update package-info.java files.
π₯ Use Cases:
- Set consistent XML namespace prefixes across generated code
- Customize prefixes for specific packages using regex patterns
- Manage multiple namespaces in complex XML schemas
- Replace default JAXB-generated prefixes with meaningful ones
β‘ Quick Start:
-Xns-prefix \
-config \
-xmlns \
-ns=http://example.com \
-prefix=exπ Command Structure:
-Xns-prefix \
-config \
-package=package.regex.pattern \
-xmlns \
-ns=namespaceURI \
-prefix=xmlPrefix \
-xmlns \
-ns=anotherNamespace \
-prefix=anotherPrefix \
-config \
-package=another.package.regex \
-xmlns \
-ns=namespaceURI \
-prefix=prefixπ― Advanced Examples:
# Apply to all packages
-Xns-prefix -config -xmlns -ns=http://example.com -prefix=ex
# Package-specific configuration
-Xns-prefix -config -package=com\.example\.* -xmlns -ns=http://example.com -prefix=ex
# Multiple namespaces for a package
-Xns-prefix -config -package=com\.example\.* -xmlns -ns=http://example.com -prefix=ex -xmlns -ns=http://test.com -prefix=tstAdd this to your Maven pom.xml:
<dependency>
<groupId>io.github.rawvoid</groupId>
<artifactId>jaxb-plugins</artifactId>
<version>1.0.0</version>
</dependency><plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<version>4.0.12</version>
<configuration>
<plugins>
<plugin>
<groupId>io.github.rawvoid</groupId>
<artifactId>jaxb-plugins</artifactId>
<version>1.0.0</version>
</plugin>
</plugins>
<args>
<arg>-Xjsr310</arg>
<arg>-Xannotate</arg>
<arg>-Xconvert-name</arg>
<arg>-Xns-prefix</arg>
</args>
</configuration>
</plugin>xjc -d src -p com.example \
-extension \
-Xjsr310 \
-Xannotate \
-Xconvert-name \
-Xns-prefix \
schema.xsdxjc schema.xsd \
-d src/main/java \
-p com.example.api \
-extension \
-Xjsr310 \
-adapter-package=com.example.adapters \
-mapping \
-xsd-type=dateTime \
-target-class=java.time.LocalDateTime \
-Xannotate \
-add-to-class \
-anno=@com.fasterxml.jackson.annotation.JsonInclude(JsonInclude.Include.NON_NULL) \
-add-to-field \
-anno=@com.fasterxml.jackson.annotation.JsonProperty("value") \
-regex=.*\.value \
-Xconvert-name \
-class-name \
-regex=(.*)Type \
-name=$1DTO \
-variable-name \
-regex=(.*)_ID \
-name=$1Id \
-Xnamespace \
-mapping \
-ns=http://api.example.com \
-package=com.example.apixjc -d src \
-Xjsr310 \
-mapping \
-xsd-type=dateTime \
-target-class=java.time.Instant \
-mapping \
-xsd-type=date \
-target-class=java.time.LocalDate \
-pattern=yyyy-MM-dd \
-Xelement-wrapper \
-remove-wrapper-class=true \
-Xremove-getter \
schema.xsdxjc schema.xsd \
-d src/main/java \
-p com.example.domain \
-extension \
-Xannotate \
-add-to-class \
-anno=@lombok.Data \
-anno=@lombok.experimental.Accessor(chain = true) \
-regex=.* \
-Xremove-getter \
-Xremove-setterπ― What this does:
- Adds
@Dataannotation to all generated classes (generates getters, setters, toString, equals, hashCode) - Adds
@Accessor(chain = true)for fluent builder pattern - Removes JAXB-generated getter methods (replaced by Lombok)
- Removes JAXB-generated setter methods (replaced by Lombok)
- Results in clean, modern Java classes with Lombok-powered functionality
git clone https://github.com/rawvoid/jaxb-plugins.git
cd jaxb-plugins
mvn clean installRequirements:
- Java 21+
- Maven 3.6+
Got an awesome plugin idea? Found a bug? Want to make things even better? We'd love your help! π
- Fork this repo
- Create your feature branch (
git checkout -b feature/amazing-plugin) - Commit your changes (
git commit -m 'Add mind-blowing plugin') - Push to the branch (
git push origin feature/amazing-plugin) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- π Report issues on GitHub Issues
- π¬ Join the discussion in Discussions
- Built with β€οΈ using JAXB Reference Implementation
- Inspired by the amazing JAXB Annox project
- Thanks to all the contributors who make this project awesome!
β If this project made your JAXB life easier, give it a star! β
Made with β and π΅ by Rawvoid