In addition to Eclipse, the Intellij IDE is a great tool for developing on top of Broadleaf Commerce (half of our team uses it to develop the Broadleaf platform itself). This guide will take you through the steps to setup the Broadleaf Commerce demo site in Intellij so that you can modify, build and run it.
First, you should decide if you want to fork the Heat Clinic Demo Site or if you want to wipe its history and start your own. If you choose to fork, you will see history of our check-ins on your
upstream remote, and you'll be able to pull in changes that we make pretty easily. However, if your site will diverge from Heat Clinic drastically, you may be better off cloning the project, deleting the
.git folder, and initializing a new repository.
We suggest you start with the latest stable release branch (at the time of this writing it is BroadleafCommerce-3.1.x), or if you want the bleeding edge features, check out the develop branch.
You can check out the demosite project directly through Intellij or through external means, but regardless of how you get the source, we suggest you not allow Intellij to automatically create the project. Rather, we'll create it manually ourselves.
POM.xmlof the repository you cloned.
1.7.0_25in this guide).
Note: If you haven't set one, Intellij will ask you to add an SDK. You can also change the SDK via the Project Structure menu. You can easily do this by right-clicking on the project root folder and selecting Open Module Settings. Select the Project option on the left and select the SDK you want in the Project SDK dropdown.
At this point, you should have a project structure in intellij resembling the following (I named my project DemoSite, but yours may be different):
At this point, you have a project that may be fully built and executed. To build the project in preparation for running it:
Once the maven install is complete, you have several options for running the site. You can use the ant scripts packaged with the project to launch a standalone version of the site and admin in a jetty instance, or use the common application container support built directly into intellij (recommended).
If you want to use the ant scripts for whatever reason, separate build.xml files are included in the admin and site modules that launch each app under a standalone version of jetty listening on ports 8081 and 8080, respectively. Make sure these ports are not already in use on your computer before attempting to launch. You can mount these ant files in the Ant Build view in intellij and execute the jetty-demo task from each. When both jetty instances have completed starting up, you can access the admin and site at http://localhost:8081/admin and http://localhost:8080, respectively. The username and password for the admin login is admin/admin.
The preferred method is to run the project using the intellij native support for various application containers. In this example we'll use Tomcat 7.
When finished your dialog should look something like this - click OK at the bottom of the dialog.
At this point we have a valid configuration for launching both the admin and demo site. However, the only thing we're missing is a database instance to point at. The easiest way to get a demonstration database running is to use the Hypersonic HSQL instance from the ant launch script.
If you haven't already, mount the build.xml from the site module in the intellij ant view and execute the start-db task. Note - this is a very low performing option and should only be used for demonstration purposes. For a better database configuration, follow our MySQL configuration guide at: http://docs.broadleafcommerce.org/current/MySQL.html.
Once the demo database is started, you're ready to launch Tomcat. Make sure your Tomcat 7 instance is selected in the configuration dropdown at the top of the intellij interface and click the start button.
Intellij will proceed to launch Tomcat with both the site and the admin application. When Tomcat has finished starting, you can access the admin at http://localhost:8080/admin and the demosite at http://localhost:8080. The username and password for the admin login is admin/admin.
Note: If you wish to only load only one application remove one opf the exploded wars from the tomcat run configuration.
The Broadleaf Commerce team makes extensive use of JRebel during our development of the platform and we recommend our users do the same during development of their Broadleaf-based projects. Adding JRebel support to intellij is relatively easy by installing the JRebel plugin:
The default configuration for your demosite build will already generate rebel.xml files for your project's modules, so you don't need to worry about anything beyond installing and configuring the plugin in the IDE. Once the plugin is successfully installed, you will see several new button options (run and debug) for launch Tomcat with JRebel support. We typically suggest running debug with jrebel support during development.
Once you click the JRebel debug button, intellij will launch Tomcat in debug mode with JRebel support. This will allow you to add/edit Java classes in your implementation and immediately see the effect of the change without restarting the application container, which can be a huge timesaver.