Develop and debug DBeaver in IntelliJ IDEA

Well, that's a tricky part.

Intro

Why

DBeaver is based on Eclipse Platform and it seems logical to develop it in Eclipse IDE. However, many people find that even latest Eclipse Java IDE isn't that good and convenient as IntelliJ IDEA.
I personally also prefer to develop in IDEA, mostly because of historical reasons but also because of many really helpful features in it.
Anyhow, here we will try to open DBeaver project in IDEA, write code, compile, run and eventually debug (as Java debugger really rocks in IDEA).

How

It is quite easy to open the project, see module structure and even compile.
But running/debugging is the most tricky part because it requires Eclipse runtime workspace and only Eclipse IDE can create one (IDEA doesn't support this and nobody can blame JetBrains for that).
So, we'll still need Eclipse to configure workspace for debugger. But once you will do this you will no longer need to run Eclipse (until plugins structure or versions will change).

Let's start!

Instructions

Opening DBeaver in IDEA

  1. Create some folder where you will clone DBeaver repositories. Note: all repositories must be located in the same folder. For example dbeaver-ce.
  2. cd dbeaver-ce
  3. git clone https://github.com/dbeaver/dbeaver.git
  4. git clone https://github.com/dbeaver/dbeaver-idea-project.git
  5. Optional: git clone https://github.com/dbeaver/dbeaver.wiki.git (skip it if you don't need WIKI)
  6. Start IDEA->Open. select folder dbeaver-ce/dbeaver-idea-project
  7. Now you can see DBeaver modules structure:
  8. You can edit code but you can't compile because there are no Eclipse dependencies configured.

Prepare Eclipse IDE and workspace

  1. Perform all steps described in Develop in Eclipse article. Use just cloned dbeaver-ce/dbeaver as sources root.
  2. Eventually you should be able to compile and run DBeaver from Eclipse
  3. Remember where you Eclipse IDE is located (let's say eclipse-ide-path)

Configuring dependencies and compile

  1. Now we need to add Eclipse dependencies in IDEA project configuration.
  2. Open File->Project structure....
  3. Make sure you have proper project Java SDK configured (Java 8+)
  4. Go to Global libraries.
  5. Create new library ECLIPSE (name and case are important)
  6. Click "Add" button. Select folder eclipse-ide-path/plugins.
  7. Recent IDEA should add all Eclipse jars as dependencies. But in in some IDEA versions you will also need to add some other folders manually:
  8. eclipse-ide-path/plugins/org.jkiss.bundle.apache.batik*/lib.
  9. eclipse-ide-path/plugins/org.jkiss.bundle.apache.poi*/lib.
  10. eclipse-ide-path/plugins/org.jkiss.bundle.apache.poi*/ooxml-lib.
  11. eclipse-ide-path/plugins/org.jkiss.bundle.jfreechart*/lib.
  12. eclipse-ide-path/plugins/org.jkiss.bundle.sshj*/lib.
  13. Eventually you see something like this:
  14. Now you should be able to compile the project. Just hit CTRL+F9 and wait.

Running and debugging

DBeaver is Eclipse RCP and must be started using Eclipse Equinox Launcher bundle. This is a special jar file which resides in Eclipse plugins folder and we need to add it to dependencies directly in order to be able to debug.

  1. Add launcher config as jar dependency for module dbeaver. Locate the jar org.eclipse.equinox.launcher_*.jar in the eclipse-ide-path/plugins/ folder. Like this:
  2. Open debug configuration "Debug DBeaver Community" and change path in parameters -configuration and -dev.
    Replace path before .metadata with path to your Eclipse workspace. Eventually it should look like this this:
  3. Click ok and run debugger. DBeaver must start. Now you can enjoy debugging in IDEA :)

Problems

Most likely something will go wrong as these instructions are quite long. Don't be afraid, rechecks configuration, try again. IF nothing helps - don't hesitate to ask in tickets or by email.