Model Resources
Expansion resources can also include components which can be added to your application if the expansion resource is present. This is a useful way to make reusable components which can be shared and versioned.
To add a component directory to your expansion resource, add a models.xml
file to your resources:
<modelResource>
<path>components</path>
</modelResource>
Path should define the location of the component directories within the jar.
The above xml would correspond to a project with a structure:
src/
main/
resources/
components/
models.xml
customers/
model/
harvest/
ext/
orders/
model/
harvest/
ext/
pom.xml
When expanding with this ModelResource, the component directory will be extracted in the local target directory and will be handled in the same way as components in the source directory.
When developing ModelResources, it is convenient to test with a SNAPSHOT
version that you install in your local Maven
cache though the mvn clean install
command.
If you want to use this SNAPSHOT version in a project, make sure you run the maven command to expand with the clean
lifecycle as mvn clean expanders:expand
.
Since, the expansion process unpacks the components from an expansion resource to the target folder, it needs to be removed if we want to update the files. This folder is managed by maven and will not be updated with a new copy of the SNAPSHOT you install unless the clean stage is used to remove the target folder.
This article describes the packaging of components. But the same thing can be done with other Modules.