Make IDEA's Plugin Deployer exclude libraries with non-runtime scope?

I'm developing an IDEA plugin and I use Maven to manage my library dependencies and to build the final source and binary artifacts. But during development I would like to use IDEA's Make and Run to launch the plugin and test it. The problem is that in my pom.xml I have dependencies to some libraries (such as IDEA's openapi and a bunch of testing frameworks) which must not be copied to the \plugins-sandbox\plugins\*\lib folder when I run the plugin - including the openapi jar causes my plugin to not load.

Dependencies in my pom.xml are (the IDEA jars are in my local Maven repository, so that I can build the plugin with Maven):

        
        
            com.intellij.idea
            openapi
            ${idea.version}
            provided
        

        
            com.intellij.idea
            extensions
            ${idea.version}
            provided
        

        
            com.intellij.idea
            annotations
            ${idea.version}
            provided
        

        
        
            org.jdave
            jdave-junit4
            1.0-rc1
            test
        

        
            junit
            junit
            4.4
            test
        

    
]]>


When I run the plugin module within IDEA, the following files are copied to the plugins-sandbox:


The library which causes problems is openapi-7.0.1.7364.jar. When it is present, my plugin will fail with the following exception:

java.lang.IllegalStateException: class with name "net.orfjackal.extformatter.plugin.ReformatAction" should be instance of com.intellij.openapi.actionSystem.AnAction
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:16)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:55)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getAction(ActionManagerImpl.java:138)
at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:225)
...


I've tried unchecking the Export checkboxes for the libraries in Module Settings, but that doesn't help. IDEA's plugin deployer should not include to the plugin package those libraries which are marked as a compile/provided/test/system scope dependencies in pom.xml. Only runtime scope dependencies should be included.

4 comments

You should compile your plugin with an IDEA SDK, where the openapi.jar (and any other IDEA-related jar) is part of the SDK. That way it won't get copied into the sandbox, as it isn't treated as a library anymore.

0

Thanks. I removed the IDEA-related jars from module libraries and now I can run the project from within IDEA. (Earlier I used a .bat which built the project with maven, copied the generated files to plugins-sandbox and ran the command for starting IDEA in the sandbox.) All the testing-scope libraries are still unnecessarily copied to the sandbox, but fortunately that hasn't yet caused me problems.

Anyways, it would be better if IDEA would handle the Maven dependency scopes in a smarter way. Should I file a JIRA issue?

0

Yes, please mark it with Maven Integration.
Thanks

0

Please sign in to leave a comment.