Elastic Path Maven Commands
Elastic Path Maven Commands
The Elastic Path Commerce projects, Commerce Manager Server, Commerce Manager Client, and so on are Maven projects with a pom.xmlfile. POM files contain configuration details and dependency information required for building, installing, cleaning, packaging, and running each of the Elastic Path Maven projects.
This page lists some of the commonly used Maven commands with Elastic Path Commerce.
- Your Command Line's directory is set to the source code home.
- Your developer environment is set up according to these instructions: Setting up your Developer Environment
Build Everything Excluding CMClient, archetypes, and demo store data
To build all the projects, but not build the cmclient, run the itests (this command still builds the itests), generate the archetypes, or load the demo store data, run the following command from the source code root directory:
Build Everything including archetypes and demo store data
To build all the projects, including the archeytpes and demo store data, but not build the CMClient (see Build The CMClient ), run the following command:
mvn install -Pwith-assets,with-archetypes -DskipAllTests
Build Each Web Application Separately
Run the following commands from your source code root directory. i.e., C:/<source>
mvn -f cmserver\pom.xml install
mvn -f storefront\pom.xml install
mvn -f search\pom.xml install
mvn -f jms\activemq-broker\pom.xml install
Install Archetypes and Web Application JARs to your local .m2 repository
To install the Web App archetypes, the out-of-the-box Web Application JAR projects, and the Cortex resource archetype to your local .m2 repository, open a command line and navigate to your source code root directory and run one of the following commands:
- Storefront Web App archetype installation:
mvn install -f storefront\pom.xml -Pwith-archetypes -DskipAllTests
- Search server Web App archetype installation:
mvn install -f search\pom.xml -Pwith-archetypes -DskipAllTests
- Commerce Manager Web App archetype installation:
mvn install -f cmserver\pom.xml -Pwith-archetypes -DskipAllTests
- Schema extension archetype installation
mvn install -f liquibase\pom.xml -Pwith-archetypes -DskipAllTests
If your application server is started in debugging mode, you can change code in the ep-core project dynamically. Your changes will take effect (hot swapped) immediately unless you changed the interface/method signature (in other words, new methods will not work and removed methods will continue to work as before). However, if you stop your application server, you will still need to run the above Maven tasks to apply the changes statically.
If you changed the interface, you need to run the above tasks and restart your application server.
When running mvn install, you may experience a java.lang.OutOfMemoryError: unable to create new native thread error. To solve this issue, run mvn install again or increase Maven's MVN_OPTS memory setting.
When you add/change/delete the Spring configuration file domainModel.xml in the com.elasticpath.core, com.elasticpath.storefront or com.elasticpath.cmserver project, you may need to rebuild the Storefront or Commerce Manager server projects for the changes to take effect.
By default, the .JAR file or .WAR files generated by Maven don't contain the source code. To include the source files, include -Pwith-source-jars:
mvn -f core\pom.xml package -Pwith-source-jars
Running Web Applications in Tomcat
Elastic Path provides Tomcat users the ability to run individual web applications through a command line using Maven.
Make sure your <wtp-developer> profile in your .m2\settings.xml is commented out. For more information on the wtp-developer profiles, see Elastic Path Maven Profiles.
This starts up Cortex in http on port 9080
Running Storefront, Search, and CMServer Web Applications
To run a the Storefront, Search, or CMServer web applications:
- In the Command Line, navigate to the project directory of the web application you wish to run. (ie. ep-storefront-webapp)
- Run the following Maven command to start Tomcat:
Testing Your Code
To build and run Checkstyle, JUnit unit and integration tests, and third party license checks:
To build Checkstyle, JUnit unit and integration tests, third party license checks, and PMD:
mvn install -Dcheckin
To skip running the tests (this still builds the projects)
mvn install -DskipAllTests
Run testing tasks for each projects independently. From the root directory of the project:
- To run PMD (To check for good coding practices):
- To run Checkstyle (To check your code for formatting and style)
- To run third party license checks:
- To run an individual JUnit test:
mvn install -Dtest=<test_class_name>
- To run an individual JUnit integration test:
mvn install -Dit=<test_class_name>
Normally you don't need to run PMD and Checkstyle if PMD and Checkstyle are set up correctly in Eclipse as the plugins can report the same warnings and errors in Eclipse. In addition, you can run JUnit tests from within Eclipse by selecting a Test class and choosing "Run as... JUnit Test".
Build the Assets Directory
The following commands builds the Assets directory on your local machine. See Managing Assets for more information on Application and Storefront assets. The command creates an assets directory with simlinks in your C:\users\<username>\ep-assets. The simlinks link to the assets folders in your source directory.
mvn -f asset-repository\pom.xml generate-resources
You can also use the following command to create the assets directory while building the source code:
mvn install -Pwith-assets
This is effectively the same as running mvn install in the root, followed by mvn install in the asset-repository directory.
Build the Assets.zip and Deploy to Maven Repository
The assets.zip contains your Application and Storefront assets. See Managing Assets for more information on the Application and Storefront assets. To create the assets.zip file: From <EPSource>\asset-repository\assets\assets-zip, run
Assets.zip builds to your target folder and is deployed to your Maven Repository at ..\.m2\repository\com\elasticpath\assets-zip.
Populate demo data for the snapitup store
Run the following command in your Commerce Engine home directory:
mvn -f stores\snapitup-populate-database\pom.xml -Dimport package
If you enable or disable one of these profiles: mysql-dev-db, oracle-dev-db, mssql-dev-db, or wtp-developer, you must update the database the settings associated with these profiles by running this command:
mvn -f stores\snapitup-populate-database\pom.xml process-resources -P update-settings
Sometimes, the source code and binaries in a project may get out of sync. For example, old versions of libraries that are no longer used still exist and cause conflicts with newer versions. Use the clean targets to remove old, unused binaries from the project. To clean all Elastic Path projects, go to the root Elastic Path directory and run:
To clean a single project, execute the following:
mvn -f <path-to-project>\pom.xml clean
Building .WAR Files
Maven can build your web application into .WAR files for deployment on Tomcat and Oracle WebLogic. In the command line, change to your Web Application directory and execute one of the following commands:
For deployment on Apache Tomcat 7:
mvn install -Pwith-tomcat-war
For deployment on WebLogic:
mvn install -Pwith-weblogic-war
If you want to remove previous build artifacts before rebuilding, use mvn clean install instead.
Build the Database Documentation
Liquibase can build your database documentation with SchemaSpy, an open source Java-based tool for generating database documentation. SchemaSpy is included in Elastic Path's source code release; however, you must install Graphviz to generate the table view relationship images.
To build the database documentation:
Go to Elastic Path root>/liquibase/schema-documentation and run:
The database documentation is generated to: Elastic Path root/liquibase/schema-documentation/target/site/schemaspy