JAXB 4.0.x plugin that adds some commonly needed functionality.
- Version 5.x requires Java 17 and builds on ph-commons v12.
- Version 4.0.3 was the last version requiring Java 11 and builds on ph-commons v11.
- The old version for JAXB 2.2 was called
ph-jaxb22-plugin
This project is licensed under the Apache 2 license.
Add something like the following to your pom.xml to use this artifact:
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<version>4.0.11</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- regular plugin configuration goes here -->
<args>
<!-- other direct arguments like -no-header -->
<arg>-Xph-default-locale</arg>
<arg>en_US</arg>
<arg>-Xph-annotate</arg>
<arg>-Xph-fields-private</arg>
<arg>-Xph-code-quality</arg>
<arg>-Xph-implements</arg>
<arg>java.io.Serializable</arg>
<arg>-Xph-equalshashcode</arg>
<arg>-Xph-tostring</arg>
<arg>-Xph-list-extension</arg>
<arg>-Xph-bean-validation11</arg>
<arg>-Xph-csu</arg>
<arg>-Xph-cloneable2</arg>
</args>
</configuration>
<dependencies>
<dependency>
<groupId>com.helger</groupId>
<artifactId>ph-jaxb-plugin</artifactId>
<!-- Use the right version below -->
<version>5.1.1</version>
</dependency>
</dependencies>
</plugin>For usage with JAXB 2.2 use this dependency:
<dependency>
<groupId>com.helger</groupId>
<artifactId>ph-jaxb22-plugin</artifactId> <!-- different!!! -->
<version>2.3.3.3</version>
</dependency>ph-annotate- Create@org.jspecify.annotations.NonNull/@org.jspecify.annotations.Nullableannotations in all bean generated objects as well as in theObjectFactoryclassesph-bean-validation10- inject Bean validation 1.0 annotations (JSR 303)ph-bean-validation11- inject Bean validation 1.1 annotations (JSR 349)ph-cloneable(since 2.2.11.7) - implementclone()ofCloneableinterface andcloneTo(target). This requires the created code to depend on ph-commons.ph-cloneable2(since 2.2.11.12) - implementclone()ofCloneableusingcom.helger.commons.lang.IExplicitlyCloneableinterface andcloneTo(target). This requires the created code to depend on ph-commons ≥ 9.1.8.ph-code-quality- fix some issues that cause warnings in the generated code.- All
ObjectFactoryQNamemembers are made public. - Adding JavaDocs to all
ObjectFactoryJAXBElement<...> create...methods
- All
ph-csu- add@CodingStyleguideUnawareannotations to all classes. This requires the created code to depend on ph-commons.ph-default-localelocale- set Java default locale to the specified parameter. Use e.g.en_USph-equalshashcode- auto implementequalsandhashCodeusingcom.helger.commons.equals.EqualsHelperandcom.helger.commons.hashcode.HashCodeGenerator. This requires the created code to depend on ph-commons.ph-fields-private- mark all fields as privateph-implementsfullyQualifiedInterfaceName[,otherInterfaceName]- implement 1-n interfaces in all classes/enums (e.g.java.io.Serializable)ph-list-extension- add additional methods forListtypes:void set...(List)- set a newListboolean has...Entries()- returnstrueif at least one entry is presentboolean hasNo...Entries()- returnstrueif no entry is presentint get...Count()(orget...ListCount) - returns the number of contained entriesT get...AtIndex(int)- get the element at the specified indexvoid add...(T)- add a new entry to the list
ph-offset-dt-extension(since 2.3.3.2) - add additional methods for Offset* date time types using theirLocalcounterpartsph-package-null-marked(since 5.1.1) - add theorg.jspecify.annotations.NullMarkedannotation to all generated packagesph-tostring- auto implementtoStringusingcom.helger.commons.string.ToStringGenerator.getToString(). This requires the created code to depend on ph-commons >= 8.6.2.ph-value-extender(since 2.3.1.3) - create additional constructors with the 'value' as argument as well as getter and setter for the value
v5.1.1 - 2025-11-16
- Added new plugin
ph-package-null-marked - Heavily improved for JSpecify annotations to avoid setting invalid ones
v5.1.0 - 2025-11-02
- Updated to ph-commons 12.1.0
- Updated to use JSpecify Nullable/NonNull annotations
v5.0.1 - 2025-09-12
- Added handling for type
Serializableincloneplugin
v5.0.0 - 2025-08-24
- Requires Java 17 as the minimum version
- Updated to ph-commons 12.0.0
- The generated code requires ph-commons 12.0.0
v4.0.3 - 2023-09-20
- If the
ph-list-extensionis used andget...Count()is already present, aget...ListCount()is created instead
v4.0.2 - 2023-04-20
- Improved debug logging further
- Fixed consistency error in
ph-value-extenderplugin. See issue #5 - thx @hujian19
v4.0.1 - 2023-04-17
- Improved logging, so that the
-debugswitch of XJC is honoured
v4.0.0 - 2022-09-13
- Updated to JAXB 4.0
- Requires at least Java 11
- Changed the artifact ID from
ph-jaxb22-plugintoph-jaxb-plugin - Changed all the internal namespaces from
com.helger.jaxb22.plugintocom.helger.jaxb.plugin - Added new plugin
-Xph-namespace-prefixto force a certain prefix via@XmlNsannotation
v2.3.3.3 - 2021-05-02
- Requires ph-commons 10.1.0
- Plugin
-Xph-offset-dt-extensionnow also supportsXMLOffsetDate - Added class
PeriodDurationas being "not clonable"
v2.3.3.2 - 2021-03-21
- Updated to ph-commons 10
- Added new plugin
-Xph-offset-dt-extension - Removed plugin
-Xph-tostring-legacy
v2.3.3.1 - 2020-10-05
- Cloneable plugins now create a "HashMap" instead of a "CommonsHashMap"
v2.3.3.0 - 2020-09-17
- Updated to Jakarta JAXB 2.3.3
v2.3.2.6 - 2020-04-29
- Fixed an error in cloning if an enumeration from an episode was referenced
v2.3.2.5 - 2020-04-24
- Ignoring static fields if the global binding
fixedAttributeAsConstantProperty="true"is used
v2.3.2.4 - 2019-12-12
- Added class
DataHandleras being "not clonable"
v2.3.2.3 - 2019-10-04
- Fixed a missing
@Validannotation for anonymous nested types (issue #2)
v2.3.2.2 - 2019-05-07
- Using unbounded version instead of limiting to Java 12.x
v2.3.2.1 - 2019-05-06
- Version number reflects latest JAXB version in use
- Updated to ph-commons 9.3.3 with Java 12 support
v2.3.1.5 - 2019-05-05
- Started Java 12 support
v2.3.1.4 - 2019-01-26
- Fixed JavaDoc error in created code when constructor parameter is a List
v2.3.1.3 - 2019-01-25
- Integrated
ph-ubl-valuefrom ph-ubl as asph-value-extenderinto this project.
v2.3.1.2 - 2018-12-01
- Added creation of bean validation
@Validannotation. Cascading bean validation now works properly.
v2.3.1.1 - 2018-11-22
- Added support for JAXB 2.3.1 when using Java 9 or higher - still works with JAXB 2.2.11 for Java 8
- Updated to ph-commons 9.2.0
- Created code requires at least ph-commons 9.2.0
v2.2.11.13 - 2018-10-31
- Added
QNameas an immutable type for cloning
v2.2.11.12 - 2018-10-31
- Added option
-Xph-cloneable2to implementCloneablebased on thecom.helger.commons.lang.IExplicitlyCloneableinterface. That means that created code requires at least ph-commons 9.1.8.
v2.2.11.11 - 2018-03-13
- Fixed a problem in
cloneTowithnullListvalues
v2.2.11.10 - 2017-11-05
- Updated to ph-commons 9.0.0
v2.2.11.9 - 2017-02-16
- Added option
-Xph-tostringrequires ph-commons >= 8.6.2 - Added option
-Xph-tostring-legacy
v2.2.11.8 - 2016-07-27
- Fixed bug in cloning of abstract class
v2.2.11.7 - 2016-06-10
- JDK8 is required
- Added generic cloning
- the
ph-csusettings is now also applied on nested generated classes
v2.2.11.6 - 2015-07-21
- Fixed error in
getXXXCountmethod name
v2.2.11.5 - 2015-07-01
- Extended
ph-list-extensionwith theaddmethod - Updated to ph-commons 6.0.0
v2.2.11.4 - 2015-03-31
- Disabled the parameter renaming in the PluginCodeQuality so that JavaDocs can be generated with Java 8
v2.2.11.3 - 2015-03-11
v2.2.11.2 - 2015-02-06
- Extended
ph-csufor all enums as well
v2.2.11.1 - 2015-02-06
- Added new option
ph-csuto add the CodingStyleguideUnaware annotation to all classes
v2.2.11 - 2014-12-02
- linked against JAXB 2.2.11
v2.2.7 - 2014-08-24
- linked against JAXB 2.2.7
My personal Coding Styleguide | It is appreciated if you star the GitHub project if you like it.