...
Code Block | ||||
---|---|---|---|---|
| ||||
<!-- Method #1: (recommended) Import from relative model namespace. Imports from classpath relative to namespace of importing model, in this case some.model.namespace. This would try resolving from some/model/namespace/../../other_model/namespace/other_model.xml. Evaluating ../.. would give us resource some/other_model/namespace/other_model.xml --> <import model="../../other_model/namespace/other_model.xml" /> <!-- Method #2 (recommended): Import from full model namespace. This will work if generated sources are compiled and added to classpath. For example if we have project dependencies where one project imports a model XML from another project, the original XML file is not available, but the one in the produced jar is. Therefore, we are getting file from classpath, where project dependency containing import is added to the classpath. For maven this also works within the same project if code generation for imported other_model.xml is run first. So, when we reach in pom the code generation of model.xml, other_model.xml is already generated and xml is copied to target/classes/some/other_model/namespace/other_model.xml. target/classes is already in classpath so this will resolve successfully to other_model.xml--> <import model="some/other_model/namespace/other_model.xml" /> |
The reason why reason why this works is that the result of running code generation would be:
...