Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Generate Cortex Projects

Generate Cortex Projects

You need to generate the following projects in order to run the Cortex API web application:

  • Resource-Configuration Project - Contains an OSGI blueprint file (resource-extensions-configuration-blueprint.xml) that defines the list of resource bundles that Cortex API requires. For more information, see Creating Cortex Resources: Adding new resources to the Resource Layer.
  • Cortex API Web Application - Web application Cortex API runs inside of. This project defines all of the Maven artifacts to include in the running web application.
Note: Resource-Configuration Issue

Make sure that all resources referenced in the Resource-Configuration Project are also defined in Cortex API Web Application pom.xml or else your web application will be in an error state.

Why are we generating these projects?

You generate these projects so you have a local, customizable Resource-Configuration Project and a Cortex API Web Application. If you are customizing Cortex API, i.e. adding and removing resources, you need to customize these two projects to add or remove the resource references.

Generate Cortex API Resource-Configuration Project

Elastic Path provides a Maven Archetype to simplify the programmer's job of creating a new Resource-Configuration Project.

To generate the Resource-Configuration Project:

  1. Open a command prompt and navigate to your Extensions Directory.
  2. Run the following command to create a Cortex API Resource-Configuration Project:
    mvn archetype:generate -DarchetypeArtifactId=ep-cortex-dce-resource-configuration-archetype -DarchetypeGroupId=com.elasticpath.cortex.dce -DarchetypeVersion=<your-artifact-version>
    Tip: Stack Trace Tip

    You may see a stack trace preceded by a warning similar to the following:

    [WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
    org.apache.maven.wagon.TransferFailedException: Error transferring file: Connection timed out: connect
                

    This can occur if you are operating Maven in online mode. It can be safely ignored.

  3. Enter the following information when prompted:
    Table 1.
    Variable Value Example
    groupId The group ID of your company com.company.commerce-api.resource-integrations
    artifactId The artifact ID you want to use for the project commerce-api-resource-integrations
    version The version of the archetype artifact 1.0-SNAPSHOT
    package The base Java package structure of the customization (defaults to the groupId) com.company.commerce-api.resource-integrations
  4. In the command line, navigate to the newly created project directory and execute the following command to build the project and install it in your local .m2 repository:
    mvn install
    
    Tip: mvn install

    If you want to remove previous build artifacts before rebuilding, use mvn clean install instead.

    Tip: Troubleshooting Tip

    Build fails when generating the archetype? See: Build Troubleshooting.

Generate Cortex API Web Application

Elastic Path provides a Maven Archetype to simplify the programmer's job for creating a new Cortex API Web Application.

Warning: Cortex API DCE Wrapper

The instructions assume you have already mapped your Cortex API DCE wrapper to Elastic Path's core library following the instructions here: https://docs.elasticpath.com/display/EP690DEV/Mapping+the+Cortex+API+to+your+Core+Library Your Cortex API web application will fail to build if you have not mapped this project.

To generate Cortex API Web Application:

  1. Open a command prompt and navigate to your Extensions Directory.
  2. Run the following command to create a Cortex API Web Application:
    mvn archetype:generate -DarchetypeArtifactId=ep-cortex-dce-webapp-archetype -DarchetypeGroupId=com.elasticpath.cortex.dce -DarchetypeVersion=<your-artifact-version>
    Tip: Stack Trace Tip

    You may see a stack trace preceded by a warning similar to the following:

    [WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
    org.apache.maven.wagon.TransferFailedException: Error transferring file: Connection timed out: connect
                

    This can occur if you are operating Maven in online mode. It can be safely ignored.

  3. Enter the following information when prompted:
    Table 2.
    Variable Value Example
    groupId The group ID of your company com.company.commerce-api
    artifactId The artifact ID you want to use for the project commerce-api-webapp
    version The version of the archetype artifact 1.0-SNAPSHOT
    package The base Java package structure of the customization (defaults to the groupId) com.company.commerce-api
    resource-configuration-artifact-id The artifact ID of the resource configuration project you generated in the section above. commerce-api-resource-integrations
    resource-configuration-group-id The group ID of the resource configuration project you generated in the section above. com.company.commerce-api.resource-integrations
    resource-configuration-version The version of the resource configuration project you generated in the section above. 1.0-SNAPSHOT
  4. With an XML editor, open the POM file of your newly created project.
  5. Above the <dependencies> tag, add the following property.
    <properties>
    	<licensing.skip>true</licensing.skip>
    </properties>
  6. In the command line, change to the newly created project directory and execute the following command to build the project and install it in your local .m2 repository:
    mvn install -Pwith-oauth2-resource
    Tip: mvn clean install tip

    If you want to remove previous build artifacts before rebuilding, use mvn clean install instead.

    Tip: Troubleshooting Tip

    Build fails when generating the archetype? See: Build Troubleshooting.