Developing Bloomreach Experience Manager with JRebel and IntelliJ
Here's how you can use JRebel & IntelliJ IDEA to build and hack the Bloomreach Experience Manager source code. This will also help you to work with Plugins. The main advantage is whenever you modify a class, you don't need to recompile the source code, the changes are instantly loaded by JRebel. This examples below assume that you are working on Bloomreach Experience Manager source code, and checked it out already from the source code repository.
Enable JRebel
First, run the following command once for the entire project:
mvn -Djrebel -DskipTests clean install
This generates the rebel.xml automatically in target/classes for every module.
You can install the JRebel Plugin for IntelliJ IDEA. This plugin is just a convenience, so you don't need to keep a command line window lying around.
Disable IntelliJ hotswap
Go to File -> Settings -> Debugger -> HotSwap, and select Never for 'Reload classes after compilation'.
Force 'recompile' of CSS and Javascript
Go to File -> Settings -> Compiler, and add the following 'resource patterns':
;?*.css;?*.js
Whenever you now modify a Java, CSS, or Javascript file, build your project (Ctrl-F9) to let JRebel dynamically reload the changed files. The resource patterns ensure that also modifed .css and .js files are copied into the 'target' folder, so JRebel picks them up too.
Start the CMS in Wicket development mode
To prevent Wicket from caching HTML and CSS, the CMS should be started in Wicket development mode. The most convenient way to do this is via an extra command line option:
mvn -Pcargo.run -Djrebel -Dcargo.jvm.args='-Dwicket.configuration=development'
Tomcat should now log the following message during startup:
[INFO] [talledLocalContainer] ******************************************************************** [INFO] [talledLocalContainer] *** WARNING: Wicket is running in DEVELOPMENT mode. *** [INFO] [talledLocalContainer] *** ^^^^^^^^^^^ *** [INFO] [talledLocalContainer] *** Do NOT deploy to your live server(s) without changing this. *** [INFO] [talledLocalContainer] *** See Application#getConfigurationType() for more information. *** [INFO] [talledLocalContainer] ********************************************************************
Remote Debugger
Go to Run -> Edit Configurations -> Remote, and add a remote debugger configuration using port 8000.
Debugging multiple projects
When debugging CMS or plugin code, you want to make changes to the CMS or plugin project while debugging. The most convenient way to do this is to have the CMS, plugin, and end-project in one window. This can be done in IntelliJ by creating a separate pom project:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>gogreen</groupId> <artifactId>gogreen-parent</artifactId> <version>1.0</version> <packaging>pom</packaging> <modules> <module>cms</module> <module>gogreen</module> </modules> </project>
For each of the modules, create a symbolic link to the relevant checkout:
ln -s ../checkouts/hippo-go-green/trunk ./gogreen ln -s ../checkouts/hippo-cms7-cms/trunk ./cms
Open this project in IntelliJ. You will now have all the modules of both the cms and the gogreen in one project, making it possible to debug / build within the same window. The up-to-date source file is now available when stepping through the debugger.