Skip to main content

Expansion Steps

AdditionalExpansionSteps are a way to add logic before or after expanding.

Some of the AdditionalExpansionSteps provided by the ExpandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. you may already know:

  • ExtDirectoryCopierStep: copies the ext directories for each Component to the expansion folder from the source directory
  • ExtDirectoryHarvesterStep: harvests the customizations in the ext directories
  • OverlayDirectoryCopierStep: copies overlay files after expansion

Setup​

AdditionalExpansionSteps have 2 components:

  • An XML file describing the step
  • A java implementation implementing the AdditionalExpansionStepImplementation interface
<additionalExpansionStep name="MyExpansionStep" xmlns="https://schemas.normalizedsystems.org/xsd/prime-core/2022/10/1/additionalExpansionStep">
<packageName>net.democritus.some.package</packageName>
<!-- Can be Application, Component or even Elements, like DataElement -->
<elementTypeName>Application</elementTypeName>
<!-- Always java, no alternatives yet -->
<type>java</type>
<!-- phase of the expansion when to run the step -->
<phase>expansion</phase>
<!-- If defined, this expansionStep will only run when the technology is present -->
<technology name="EJB3"/>
<!-- condition when to run the step -->
<isApplicable>true</isApplicable>
<!-- set to false to exclude this step -->
<active value="true"/>
</additionalExpansionStep>

packaging

AdditionalExpansionSteps are packaged just like ExpandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. and Features by the expansionResource mojo of the expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact.-maven-plugin. Just make sure you have an XML with the additionalExpansionStep tag and the name of the expansionStep ends with Step.

Copy files from Classpath to Expansion​

During the expansion process, it's a common requirement to include static assets or configuration files from your expansion-resource into the generated output (the expansion directory). This can be achieved using an ExpansionStep, leveraging Java's ClassLoader to access files packaged with your expansion-resource.

Context: When and Why You Need This​

Your plugin might need to copy files for various reasons:

  • Static Assets: HTML templates, CSS files, JavaScript files for a web applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution..
  • Configuration Files: Default configuration for generated code or external tools.

An ExpansionStep is the ideal place for this logic, as it operates within the controlled environment of the expansion process.

A detailed guide on how to create this ExpansionStep can be found in the Developer Hub: How to Copy files from Classpath to Expansion