Hello castor users, When generating source code from multiple XSDs using castor-maven-plugin v1.5, one may experience random failure. Process itself will not fail, but its outputs are not generated well. Problem occurs if one configures plugin using packaging, schemaDirectory, without providing binding file, and when generateImportedSchemas is set to false, in case of multiple XSDs being processed referencing each other. In this case source code generation success will be dependent on order the XSDs are processed. E.g. if one xsd (1) references the other (2) and 1 becomes processed before 2, types generated from 1st XSD with attributes of type generated from 2nd XSD might not compile, because attributes will not have correct package reference (only types.%TypeName% without packaging prefix) - likely a bug in Castor CodeGen module.
In my case generateImportedSchemas has to be false, since some imported schemas don't have to be processed, only ones from a given directory. Correct me if I'm wrong, but I think currently one can not influence order XSDs will be processed. After checking the castor-maven-plugin source it seems schemas will be processed in order that is more dependent on alignment of stars than anything else (java.io.File.listFiles(), java.util.Set, ... no guarantees of order). Same goes for the processing success. Solution was to use binding.xml file and configure XML namespace to package name mapping. Then it seems, regardless of the order XSDs are processed, source code generator knows to resolve package for given XSD type/group/element/... based on its namespace and provided mapping. Maybe castor-maven-plugin could be improved, to first analyze all the XSDs before they are processed, check who imports whom, and based on that order the XSDs for processing, so do something similar maven reactor does at the start of the build by ordering modules to be built. Regards, Stevo.

