Up To Date Checks - highsource/jaxb-tools GitHub Wiki
Introduction
To avoid unnecessary regeneration (which may be very time-consuming), the plugin checks, if the generated code is still up-to-date (copared to the source schemas and other files). If everything is up-to-date then code generation will be skipped. However, you can use the forceRegenerate=true
to force regeneration every time. This is explicitly not recommended.
The up-to-date check algorithm
The up-to-date check algorithm is as follows:
- Gather the URIs of the "source" resources:
- The
pom.xml
file of the project. - The resolved URIs of the catalog files and resources.
- The resolved URIs of the schema files and resources.
- The resolved URIs of the binding files and resources.
- URIs of the additionally configured
otherDepends
/otherDependsIncludes
/otherDependsExcludes
files.
- The
- Gather the URIs of the "target" resources:
- Scan the
generateDirectory
for files which match theproduces
pattern, and collect their URIs.
- Scan the
- Find out the latest timestamp of the "source" resources (timestamp of the resource update) and earliest timestamp of the "target" resources (timestamp of the generation).
- If timestamp of the update is later than the timestamp of the generation, or if some of the timestamps is unknown, regenerate.
- Otherwise - that is, if both update and generation timestamps are known and update was not later that generation, do not regenerate.
Configuration
The regeneration is controlled by the following configuration elements:
forceRegenerate
- Iftrue
, no up-to-date check is performed and the XJC always re-generates the sources. Otherwise schemas will only be recompiled if anything has changed (this is the default behavior). SettingforceRegenerate
totrue
is not recommended.- Configured catalogs, schemas and bindings.
otherDepends
- other files to check for updates. Deprecated, useotherDependsIncludes
/otherDependsExcludes
instead.otherDependsIncludes
/otherDependsExcludes
- patterns of other files to check for updates.produces
- patterns of of files produced by this plugin. Default value is**/*.*, **/*.java, **/bgm.ser, **/jaxb.properties
.
Finding out last modification timestamps for URIs
To perform the up-to-date-check, the plugin has to find out the last modification timestamp for each of the source URIs. These source URIs may be files, but also other URIs. The plugin supports the following URI schemes:
file
(a normal file) - last modification of the target file.jar
(a resource inside a JAR file) - last modification of the JAR file. It is assumed that if the JAR file was changed then the resource inside it was changed as well.http
orhttps
(Web resources) - last modification is taked from theLast-Modified
HTTP header. However, this is not reliable. Compiling schemas directly from Web resources is strongly discouraged anyway.
If the last modification timestamp could not be found out for some reason (for instance, the Web server does not return the header), it is assumed to be unknown and will consequently force regenration.
Up-to-date check for Maven artifact resources
You may note that the maven
scheme used in Maven artifact resources is not listed. This is because all the URIs are resolved prior to the check. So the Maven artifact resource URI will either be resolved into a jar
URI or a file
URI, both of which are supported.
So this up-to-date check also works with Maven artifact resources. If you use a schema from the Maven artifact then the plugin will check that artifact/resource for actuality.
Limitations
This up-to-date-check only works for resources directly configured in the plugin condiguration. If your schema a.xsd
import some other schema b.xsd
and that schema is not configured in the plugin configuration, it will not be considered during the up-to-date check. You may use otherDependsIncludes
and otherDependsExcludes
to configure additional resources to check.