Multi plugin system

I want my “plugin universe” to be modular. A lot of plugins share the same code (such as Util etc). How can I make it possible, that my other plugins can use the code from the “core”-plugin/project?

Make a “core” plugin with all the repeated utility and other classes and in your other plugins depend on it using Plugin annotations dependencies argument

Add your main plugin to the plugin-dependencies:
@Plugin(id = "someId", name = "someName", version = "someVersion", dependencies = "required-after:YOUR_MAIN_PLUGIN_ID")
and add your main plugin to the build-path of all others :smiley:

Thanks :smiley: How would I set a dependency on the project in Intellij?

From IntelliJ (version 13, not sure if it’s changed in updates):

  • File->Project Structure
  • Go to the “Modules” section, select your plugin
  • Click on the “Dependencies” tab. From there you will be able to add dependencies that are available to the project.

I’m assuming here that you’ve got your plugin set up as an intelliJ module. If not then I’m not sure how it would be done.

1 Like

I can add the a module dependency to the core plugin but I can’t use its classes…
Edit: Never mind, got it to work after some trying. Thank you :smiley:

For anyone else, who is new to this kind of stuff and wants to do this (IDEA 15):

  • Open gradle menu (menu to the right)
  • Click “Attach Gradle Project”, Select build.gradle of your target project
  • Click “OK”
  • Go to File → Project Structure → Modules
  • Select your current project (not the target project), switch to “Dependencies”-tab
  • Click Add → Module Dependency → Select the target project
  • Select the the target project in the module list and switch to the “Sources”-tab
  • Mark the directory, that is the source directory of your target, as source

Also consider adding this to the file of your target project (it will prevent that your source directory is unmarked upon gradle refresh):

sourceSets {
    main {
        java {
            srcDirs = ['relative path to your source directory']

    test {
        java {
            srcDirs = ['relative path to your source directory']

Glad you got it working, thanks for posting more detailed instructions. I don’t use Gradle so I didn’t even think of how that would work.