Elastic Path Maven Commands
Elastic Path Maven Commands
Each Elastic Path project, Commerce Manager Server, Commerce Manager Client, ect. are Maven projects with a pom.xmlfile. POM.xml 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 a few of the commonly used Maven commands with Elastic Path.
For more in-depth information on Maven commands, refer to the guides on Maven's build cycle and plugins.
- Your Command Line's directory is set to the Elastic Path 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:
mvn install
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>
CM Server
mvn -f cmserver\pom.xml install
Storefront
mvn -f storefront\pom.xml install
Search
mvn -f search\pom.xml install
ActiveMQ JMS
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 6.13.0 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:
mvn tomcat7:run-war
Testing Your Code
To build and run Checkstyle, JUnit unit and integration tests, and third party license checks:
mvn install
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):
mvn pmd:check
- To run Checkstyle (To check your code for formatting and style)
mvn checkstyle:check
- To run third party license checks:
mvn licensing:check
- 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
mvn package
Assets.zip builds to your target folder and is deployed to your Maven Repository at ..\.m2\repository\com\elasticpath\assets-zip.
Database Commands
Changing Profiles
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
Cleaning Projects
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:
mvn clean
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:
mvn site
The database documentation is generated to: Elastic Path root/liquibase/schema-documentation/target/site/schemaspy