Bjørn Mølgård Vester created CXF-8924:
-----------------------------------------
Summary: Make Wsdl2Java generate code in a deterministic way for
reproducible builds
Key: CXF-8924
URL: https://issues.apache.org/jira/browse/CXF-8924
Project: CXF
Issue Type: Improvement
Affects Versions: 4.0.1
Reporter: Bjørn Mølgård Vester
When you run the wsdl2java tool on a collection of schemas, it will generate a
class "ObjectFactory" with method names taken from the schemas.
Currently, the order of these methods is not predictable as it depends on the
hash code of the absolute file path to the schemas. The file paths may change
depending on where you have, for instance, checked out the code. It is also
normal for a CI server to check out code in folders named after the branch or
pull request.
Besides the benefits of having [reproducible
builds|[https://reproducible-builds.org/],] for us, it also breaks our build
cache that fingerprints the input schemas and the generated code that may
differ depending on where it was built. This causes cache misses that again
lead to unnecessary long build times.
The issue arises in the class SchemaCollection. Here, schemas are added to a
class XmlSchemaCollection from the xmlschema-core Apache project, with a system
ID that includes the absolute file path to the schema. The schemas are later
returned ordered by the hash code of the system ID (among other things), which
changes depending on the paths.
This issue can be fixed either in CXF by not using full paths for system IDs,
by sorting the schemas during code generation by name and namespace for
instance, or finally, it can be solved by letting XmlSchemaCollection return
schemas in the same order as they were added. I think the latter is the most
elegant solution, so I've opened an issue for that project and submitted a PR:
https://issues.apache.org/jira/browse/XMLSCHEMA-65.
If that PR is accepted and a new version is released, I would like CXF to
update to that version. If not, it would be great if a fix could be made to CXF
itself.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)