Skip to end of metadata
Go to start of metadata

In the directory where the Elastic Path source code was extracted, there is a build.xml file. This is the main Ant build file. It contains targets that apply to all the Elastic Path projects, for example, clean-all and build-all. Each project (com.elasticpath.cm, com.elasticpath.sf, etc.) has its own build.xml file as well, which you can use when working with that project.

This page lists a few of the more commonly used Ant tasks. To get the complete list of Ant tasks in a build.xml file, run ant -p in the corresponding directory.

It is assumed that your current directory is the directory where you extracted the Elastic Path source distribution, and that you have set up Ant according to the instructions in Setting up Ant.

Building the applications

  • To do a complete build of all web applications and the CM client, run:
    ant all
  • To only build the com.elasticpath.sf project:
    ant -f com.elasticpath.sf/build.xml build
  • To only build the com.elasticpath.cm project:
    ant -f com.elasticpath.cm/build.xml build
  • To only build the com.elasticpath.search project:
    ant -f com.elasticpath.search/build.xml build
  • To only build the com.elasticpath.connect project:
    ant -f com.elasticpath.connect/build.xml build-services
  • To only build the com.elasticpath.cmclient:
    ant -f com.elasticpath.cmclient/build.xml build-product
    If your application server is started in debugging mode, you can change code in com.elasticpath.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 ant tasks to apply the changes statically.

    If you changed the interface, you need to run the above tasks and restart your application server.

    When you add/change/delete the Spring configuration file domainModel.xml in the com.elasticpath.core, com.elasticpath.sf or com.elasticpath.cm 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 Ant scripts don't contain the source code. To include the source files, include -Dswitch.archive.source="yes":

ant -f com.elasticpath.core/build.xml jar -Dswitch.archive.source="yes"
ant -f com.elasticpath.sf/build.xml war -Dswitch.archive.source="yes"

Testing Your Code

You can run testing tasks for each of the projects independently.

NOTE: Running the Cobertura test coverage Ant task requires that you:

  • download the the JavaNCSS version 21.41 zip file: http://www.kclee.de/clemens/java/javancss/javancss21.41.zip
  • extract ccl.jar, rename it to javancss-ccl-21.41.jar and place it into /LIBS/javancss/ccl
  • extract javancss.jar, rename it to javancss-javancss-21.41.jar and place it into /LIBS/javancss/javancss

When you add/change/delete java code in a project, from that project's root directory you can run various checks and testing tasks:

  • To run junit tests:
    ant junit
  • To run pmd (To check for good coding practices):
    ant pmd
  • To run checkstyle (To check your code for formatting and style)
    ant checkstyle
    The tasks for the cmclient are slightly different for junit/pmd/checkstyle:
    junit/pmd/checkstyle-plugin -Dplugin="pluginName"

    Tasks for all the plugins (as listed in the all.plugins property) can be run as follows:

    ant junit/pmd/checkstyle-all
    Normally you don't need to run pmd and checkstyle ant tasks if pmd and checkstyle are set up correctly in Eclipse.
    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".

Adding libraries

To add jars to your project, see Adding Libraries.

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, run:

ant clean-all

To clean a single project, execute the following:

ant -f com.elasticpath.<project_name>/build.xml clean
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.