21

I'm trying to import and run the IntelliJ git4idea (Git Integration) plugin in order to play around and contribute some of my own code.

I've pulled the Intellij community edition from the github repo, and imported the git4idea plugin as a project. I'm running the Intellij community edition

My main issue is this:

After importing all the modules, the git4idea module comes up as a general module type, and not a plugin module type.

enter image description here

This means that when trying to create a new run\debug configuration, I get [none] under "Use classpath of module", instead of of the ability to select the git4idea plugin. This obviously results in a "Run configuration error: no plugin module specified for configuration".

enter image description here

So the question is - How can I change the general type of imported "git4idea" to plugin type?

Or better yet, what are the steps required in order to import and build/debug/run a plugin from the Intellij community edition repo?

Dylan Corriveau
  • 2,561
  • 4
  • 29
  • 36
OpherV
  • 6,787
  • 6
  • 36
  • 55

4 Answers4

44

I was able to solve this by manually reordering file directories, sorting out dependencies and editing the .iml file. The type of plugin is defined by changing type="JAVA_MODULE" to type="PLUGIN_MODULE".

...

This is the answer given by Dmitry Jemerov on the official Jetbrains plugin development forum:

The easiest answer to this is "don't". The IntelliJ IDEA Community Edition project is set up to be developed as a whole, and the dependencies are set up accordingly. If you want to hack on the Git plugin, you simply run IDEA using the provided run configuration, it runs with all plugins enabled, and you simply make whatever changes you need and test them using the main run configuration.

If you really want, you can set up a new plugin module and point it to the source code of the git4idea plugin inside the IntelliJ IDEA Community Edition Git checkout. This is not too hard, but it's something you'll need to do from scratch, and you can't use the existing .iml file.

bharal
  • 15,461
  • 36
  • 117
  • 195
OpherV
  • 6,787
  • 6
  • 36
  • 55
  • 4
    Thank you for sharing your solution. I was looking to do this using Ultimate edition and editing the .iml file did the trick. – Mark McDonald Jul 06 '15 at 03:52
  • 3
    Got to your project root folder, you can find *.iml, cool, this did the trick type="JAVA_MODULE" to type="PLUGIN_MODULE". – sreekumar Feb 28 '16 at 06:04
  • I imported an existing project and found that I could not run it as a plugin. Changing type="JAVA_MODULE" to type="PLUGIN_MODULE" solved my problem. Many thanks. Reminds that we may have to fill the .iml file with something like the below. – Zhipeng.C Jan 17 '17 at 11:24
  • 1
  • 1
    See https://github.com/ligasgr/intellij-xquery/blob/master/idea.gradle for a way to do this when you are using Gradle for generating the project files. – centic Oct 10 '17 at 10:49
  • and what do you do if you are using Ultimate and don't want the CE sources? – Alwyn Schoeman Jan 30 '18 at 19:03
5

I had the same no plugin module specified for configuration issue. To work around it, instead of importing, I created a new plugin project and used the existing code directory.

anon
  • 4,163
  • 3
  • 29
  • 26
  • I'm not yet sufficiently knowledgeable in IntelliJ IDEA CE to troubleshoot effectively. As such, I'd get lost pursuing this thread's marked solution ("reordering file directories and sorting out dependencies"... I'd likely lose hours). I'm looking to get things going quickly, gradually learning my surroundings from a foundation of functioning examples. As such, I favoured this answer and quickly, within minutes, got my sample plugin working with the approach it describes. – UpLate Feb 24 '18 at 17:52
5

After changing type="JAVA_MODULE" to type="PLUGIN_MODULE" in *.iml file I was getting following error -

Error running 'IdeaPlugin': Wrong SDK type for plugin module

To fix this go to -

  1. Module Settings -> Platform settings -> SDKs.
  2. Click on Add new SDK
  3. Select Intellij Platform plugin SDK
  4. For home directory select your Inetllij installation dir
  5. Select JAVA SDK you want to use with it.

Once this is added got to Module Settings again

  1. Module Settings -> Project settings -> project.
  2. In Project SDK change the JAVA sdk to the SDK we just added in the above steps.
  3. Run/Debug you plugin now.
Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
5

when you import the intelij plugin projects

You should run the 'runIde' task in gradle.

Step-by-step instruction

  1. Build your IDEA plugin (usually done with gradle build).
  2. Start Intellij IDEA.
  3. If you have any project opened, go to menu "File->Close all projects" to return to Intellij IDEA startup screen.
  4. Install the plugin you've just built: on the left side of the "Welcome to Intellij IDEA" startup screen go to "Plugins", then click "gear" icon on the right side, it's located to the right of "Marketplace" and "Installed". From the pop-up menu select "Install Plugin from Disk...", navigate to plugin file (usually in build folder) and click "Ignore and continue" when you see the warning message saying something about signature.
  5. Restart Intellij IDEA.
  6. Open the folder with your IDEA plugin.
  7. Wait until IDEA imported your Gradle project.
  8. Put breakpoints inside your plugin code so you can debug it.
  9. Go to menu "Run->Edit configurations".
  10. In the "Run/Debug Configurations" window on the left side click "+".
  11. Select "Gradle" from the pop-up menu.
  12. On the right side change "Name" to "gradle-run-ide" (without quotes).
  13. On the right side under "Run", inside "Tasks and arguments" field enter runIde ("i" must be capital, other letters small).
  14. Click "OK" to save changes.
  15. Go to menu "Run->Debug 'gradle-run-ide'".
  16. A new, black-colored IDEA window should appear.
  17. In this black-colored IDEA window do whatever you need to do in order to invoke methods of your plugin. When you invoke them, the first IDEA window should stop you on breakpoints you set previously.

Happy debugging.

izogfif
  • 6,000
  • 2
  • 35
  • 25
Bhond
  • 51
  • 1
  • 6