I have to develop a plugin for Eclipse but I prefer IntelliJ IDEA as IDE. Is it possible to configure IDEA for Eclipse plugin development?
It might be possible using Osmorc, but I haven't tried that. However, I have a method that works (using IntelliJ 2017.1, but it should be similar for other versions). It does not require Eclipse Tycho, which I couldn't use because my plugin used XCore which doesn't seem compatible with Tycho.
Inside IntelliJ
Import module from external model
In order to not mess up the Eclipse projects, I selected "Keep project and module files in ~/IdeaProjects/MyIntelliJProject
Open up the Project Structure (Ctrl + Alt + Shift + S)
/opt/eclipse/plugins
directory (or wherever eclipse was installed)ECLIPSE
library as the last dependency.At this point, you should be able to code and run tests in IntelliJ, but to actually run the plugin, you have to use Eclipse. That's a bit messy, though.
My solution was to run the same command that Eclipse does when you run your plugin:
Open up the Debug perspective. You should see something like this:
Right click > properties on the /usr/lib/jvm/...
(may be different Java JVM)
Copy the Command Line:
Elsewhere, in your favorite editor, make a new bash file (I put this file in my IntelliJ project folder), and paste this command in there.
Note that when Eclipse runs the command, it runs from a working directory of /opt/eclipse/
(or wherever eclipse is installed), so we need to add a cd /opt/eclipse/
beforehand. Let's do it in a new shell as well:
(cd /opt/eclipse && /usr/lib/jvm/java-8-oracle/bin/java ...)
If this bash script is run, it should be the same as if we ran from Eclipse.
In IntelliJ, create a new Bash run configuration (Alt + Shift + F10 > Edit Run Configurations). Make the "Script:" field contain the path to the bash file we just created.
Also, add "Build Project" to the "Before launch" options.
Additionally, tick the "Single instance only" box.
If we now run that configuration, it should work. However, we still cannot debug from within IntelliJ. This fixes that:
Copy the "Command line arguments for running remote JVM". For me that is
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
I liked the workflow for suspend=y
better; basically it means that the eclipse application won't start up until we attach the debugger.
Copy your bash file and add these arguments:
(cd /opt/eclipse && /usr/lib/jvm/java-8-oracle/bin/java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 ...)
Add another Bash run configuration for IntelliJ that runs this new script (and also runs "Build Project" beforehand, and is "Single instance only").
Now, to debug your Eclipse plugin, run the Debug Bash Configuration, then run your Remote Configuration.
At the end, this is what my run configurations look like:
At this point, the only thing Eclipse is needed for is editing my .xcore
files since Eclipse generates Java code from that, and XCore doesn't have a way to be run from the terminal.
It should be possible by using Eclipse Tycho.
You'll be using maven and that works perfectly with IntellIj.
Tycho is focused on a Maven-centric, manifest-first approach to building Eclipse plug-ins, features, update sites, RCP applications and OSGi bundles. Tycho is a set of Maven plugins and extensions for building Eclipse plugins and OSGi bundles with Maven.