Cortex Web Application POMs
Cortex Web Application POMs
Cortex has a number of web applications with overlapping dependencies. To simplify the Cortex web application POMs, we created a parent webapp POM. All Cortex web apps inherit from this parent POM. This simplifies the web application POMs as it reduces the amount of duplicate code in the POMs. The parent POM defines the dependencies once and then all web application project POMs inherit from it, rather than each web application POM defining same dependencies.
- ep-cortex-dce-webapp-parent
- ep-cortex-dce-webapp
- ep-cortex-tutorial-dce-webapp
- ep-cortex-stubs-webapp
Understanding Cortex Webapp POMs
POM (project object model) is an XML file containing a list of your project's dependencies. Each Cortex resource, carts, profiles, and so on, is a dependency. If you add a new resource, remove an existing resource, or swap a new one in, you need to update your project's webapp POM.
dependencies
executions
Element | Description |
---|---|
<execution> | ep-cortex-dce-webapp-parent has an execution group configured for each Cortex resource. Having them separated into like this allows you to more easily override them in your ep-cortex-dce-webapp POM. |
<goal> | Defines the goal of the execution group. In most cases, the goal is : <goal>copy</goal>. This goal means the dependency in the execution group is to be copied over to the <outputDirectory> for deployment. |
<outputDirectory> | Defines where the execution group copies to. |
<artifactItem> | Defines the groupId and the artifactID for the dependency. |
Example: Web Application POM
... <dependencies> <dependency> <groupId>com.elasticpath.tutorials</groupId> <artifactId>example-assets-resource-integration</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> .... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> ... !-- Profiles resource server and CE integration --> <execution> <id>copy-profiles-resource-and-integration-OSGi-bundles</id> <phase>prepare-package</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${war-bundle-directory}</outputDirectory> <artifactItems> <artifactItem> <groupId>com.elasticpath.rest.resource</groupId> <artifactId>ep-resource-profiles</artifactId> </artifactItem> <artifactItem> <groupId>com.elasticpath.rest.integration.epcommerce</groupId> <artifactId>ep-resource-profiles-epcommerce</artifactId> </artifactItem> </artifactItems> </configuration> </execution> <!-- Purchases resource server and CE integration --> <execution> <id>copy-purchases-resource-and-integration-OSGi-bundles</id> <phase>prepare-package</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${war-bundle-directory}</outputDirectory> <artifactItems> <artifactItem> <groupId>com.elasticpath.rest.resource</groupId> <artifactId>ep-resource-purchases</artifactId> </artifactItem> <artifactItem> <groupId>com.elasticpath.rest.integration.epcommerce</groupId> <artifactId>ep-resource-purchases-epcommerce</artifactId> </artifactItem> </artifactItems> </configuration> </execution>
Standard POM Use Cases
- Adding New Resources - Update your webapp POM with the new resource. For more information, see Writing Your First Resource
- Adding Libraries to the Web Application POMs - When adding new libraries to your webapp, update your webapp POM with the new library. For more information, see Adding third party jars to Cortex API.
Disabling Out-Of-The-Box Resources - Out-of-the-box Cortex resources are defined in the dce-webapp parent POM. In some cases, this POM will be unavailable for developers to modify, so if they want to disable one of the OOTB resources they need to override it in their Cortex web application POM.
The instructions below describe how to disable the assets resource as an example. Be careful when you disable an OOTB resources, as other resources may depend on it.
To disable the out-of-the-box assets resource:- Add the following <excludeArtifactIds> element to the Cortex web app POM,
as shown below in the example below. This excludes the assets resource from
being included in the build and effectively removes it from Cortex.
... <dependencies> <!-- Add Extension resources or Integration modules as maven dependencies here. --> <dependency> <groupId>com.elasticpath.tutorials</groupId> <artifactId>example-assets-resource-integration</artifactId> <version>1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <!-- Override Assets CE Integration and use an example integration instead. --> <execution> <id>copy-assets-resource-and-integration-OSGi-bundles</id> <phase>prepare-package</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${war-bundle-directory}</outputDirectory> <artifactItems> <artifactItem> <groupId>com.elasticpath.rest.resource</groupId> <artifactId>ep-resource-assets</artifactId> </artifactItem> <artifactItem> <groupId>com.elasticpath.tutorials</groupId> <artifactId>example-assets-resource-integration</artifactId> </artifactItem> </artifactItems> </configuration> </execution> <execution> <id>copy-cortex-OSGi-bundles</id> <phase>prepare-package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${war-bundle-directory}</outputDirectory> <includeScope>provided</includeScope> <includeGroupIds>com.elasticpath.rest,com.sun.jersey,com.fasterxml.jackson</includeGroupIds> <excludeArtifactIds>ep-resource-assets-epcommerce</excludeArtifactIds> </configuration> </execution>
- Using a command line, change directories to your Cortex web application folder and execute
the following to rebuild Cortex:
mvn clean install
.
- Add the following <excludeArtifactIds> element to the Cortex web app POM,
as shown below in the example below. This excludes the assets resource from
being included in the build and effectively removes it from Cortex.