Search code examples
javaintellij-ideaintellij-plugin

IntelliJ Idea: how to expose classes, interfaces, annotations in developed plugins


I have created a plugin for IntelliJ Idea. In the plugin I have defined an annotation I want to use in my projects, but it doesn't seem to be accessible. How should I specify in the plugin.xml file the packages I want to expose?


Solution

  • When you install a plugin, it will be on a certain place - e.g. C:\Users\xxx\.IdeaIC14\config\plugins\...

    Now that you know where your jar file is, you can add it as a dependency to your project. If you use Maven, you can add something like this to your pom:

    <dependency>
        <groupId>yourplugin</groupId>
        <artifactId>yourplugin</artifactId>
        <version>1</version>
        <systemPath>C:\Users\xxx\.IdeaIC14\config\plugins\yourplugin.jar</systemPath>
        <scope>system</scope>
    </dependency>
    

    Or you can install the jar into your local repository and then use it as normal maven dependency.

    If not, then add the dependency directly in the project settings as it was any other jar.

    plugin.xml has nothing to do with any of this, this is all about jars and classpath. What you could do in your plugin is some user friendly inspections and actions, which would add the dependency for you.