Back in my NetBeans times I wrote several articles (1, 2) about using Zeroturnarounds JRebel to develop NetBeans plugins faster by not restarting nor reloading the whole target-platform. JRebel is a Java agent, so it can be used with nearly every Java-based application. Even for developing IDEA plugins. And here is how you do it:
- Buy a JRebel license or get a free one for your open-source plugin at myRebel
- Install the JRebel plugin for IDEA from the plugin manager (for bundling JRebel, a configuration UI and debugging support)
- Activate the plugin using the license from step 1
- Update the your Run- or Debug configuration with the Java agent configuration – based on the standard documentation)
- Run / debug your plugin using the configuration created above – JRebel should show its banner and an IDEA instance should load
- Edit your Java sources as normal and when you want to get the changes reloaded then compile the project/all the changed files (thus the sources are compiled into class-files and JRebel can pick up the changes)
- Reinvoke your plugins actions (or what ever) in the target platform – your changes should be picked up
Note 1 Not all changes will be picked up. JRebel does not have yet official support for this usage scenario. Especially changes in the plugin.xml won’t be picked up. But within existing or new Java classes you can code and refactor as much as you like!
Note 2 If you are on Mac OS consider to install JRebel separately. I had issues to set the Java agent with the bundled JRebel from the JRebel IDE plugin. Do you see the culprit in
-agentpath:/Users/markiewb/Library/Application Support/IntelliJIdea2017.2/jr-ide-idea/lib/jrebel6/lib/libjrebel64.dylib? The whitespace!
Note 3 Of course this also works when you write plugins for the other Java based IntelliJ platform IDEs like WebStorm, PHPStorm and so on.
If you are using the free Community Edition of IntelliJ IDEA you probably noticed that there is no Tomcat support. The integration is included only in the commercial Ultimate Edition.
If won’t buy a license for whatever reason, you still can create some basic Tomcat integration even in the free IDEA Community Edition.
How to start the Tomcat from within the IDE?
Create an ‘External Tool’ configuration for the Tomcat
The command is
catalina jpda run to start the tomcat in debug mode at the default port
Now the Tomcat can be started from several places within the IDE
and even the output of the process is printed to its run console.
Tip: If you want the External Tool to be integrated as a Run Configuration please checkout the other post and plugin.
How to start a debug session for started Tomcat?
Create a run configuration which starts a remote debugging session at
Switch to ‘Logs’ tab and configure that the log files are also integrated
After starting the run configuration, the debugger is attached to the Tomcat and the log files of the tomcat are shown within the IDE.
How to deploy a WAR file from a Maven based webapp to the Tomcat?
The steps are to run
mvn war:war first to create the WAR and then to copy it to the webapp directory of the Tomcat.
One approach is to create a ‘Maven’ run configuration with the commandline:
war:war org.codehaus.mojo:wagon-maven-plugin:upload-single -Dwagon.fromFile=FULL_PATH_TO_WAR_FILE -Dwagon.url=file://FULL_PATH_TO_TOMCAT\webapps\ (Don’t forget to change placeholders!)
This creates the WAR file and copies it to the Tomcat via the
Other approaches could be:
- Create a batch script (which invokes maven and copies the WAR), integrate it as an ‘External Tool’ configuration OR
- Use the remote synchronizer plugin OR
- Integrate an Ant target to copy the file OR
- … more ideas at stackoverflow or here
- Buy a license for IntelliJ IDEA Ultimate Edition and you do not have use the described workarounds. (The personal license is quite affordable IMO and even allowed to use at work . No, I am not paid or sponsored by JetBrains.)
- Try other plugins for IDEA CE, which also provide Tomcat integration