Plugin modules as maven poms

Hi,

I'm not sure how the other plug writers configure their projects, but I've been using maven for it for a few months now and it globally works well.

Maven support that is now integrated into IDEA is nice to setup dependencies, but it also creates some issues.
1 / IDEA has no clue that a given pom is in fact a "plugin module" and not a regular java module. Indeed there is no maven artifact type for it. So when open the pom, IDEA creates a project with a java module. If you want to use this module, you need to manually edit the generated iml file to change the module type to type="PLUGIN_MODULE".
2/ to be able to build your plugin you need to provide dependencies on openapi.jar and some other idea provided dependencies (annotations, jdom, extensions in my case).
Problems come when you try to run your module : IDEA loads the classes in the wrong class loader as they appear in both the IDEA runtime, and in your dependencies.
You then have to remove those IDEA provided dependencies from your module dependencies

I'm wondering if there would be a friendly way to do the above, or if the recommended (and supported) way to handle plugins is to stick with iml files

3 comments
Comment actions Permalink

I dealt with your issue #2 just today to resolve the openapi.jar. Maven suggests 2 ways to resolve such dependencies that may not be redistributable and not found in the main repositories. Artifacts with javax packages is a specific example. The first is for local repositories which I used.

mvn install:install-file -DgroupId=com.intellij.idea -DartifactId=openapi -Dversion=7.0 -Dclassifier=7126 -Dpackaging=jar -Dfile=/path to idea home/lib/openapi.jar

Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=com.intellij.idea -DartifactId=openapi \
-Dversion=7.0 -Dclassifier=7126 -Dpackaging=jar -Dfile=/path/to/file \
-Durl=[url] -DrepositoryId=[id]

Then the dependency is:

com.intellij.idea openapi 7.0 provided 7126 ]]>

I like having openapi-7.0-7126.jar in my local repository because it tells me exactly from which version it came. It also let's me have all the versions co-exist and not create conflicts.

Good point about your issue #1. I wonder if having a Facet for plug-ins would be a feasible thing to do. It's probably a good bit of rework but seems like it would fit the model nicely.

0
Comment actions Permalink

Steve Swing wrote:

I dealt with your issue #2 just today to resolve the openapi.jar.
Maven suggests 2 ways to resolve such dependencies that may not be
redistributable and not found in the main repositories. Artifacts
with javax packages is a specific example. The first is for local
repositories which I used.


I wonder if we can talk JetBrains into setting up their own Maven2
repository that these artifacts are published to from TeamCity.

That way keeping everyone using the same groupId/artifactId's...

0
Comment actions Permalink

THanks for answering but this is not what I was concerned with.

I've written a pom for my plugin (http://ideamksplugin.googlecode.com/svn/trunk/pom.xml) and i've done it like you suggest, using provided scope for the several jetbrains libraries needed to build the plugin (openapi, annotations and forms_rt).

The problem I am encountering is
- you cannot use the IDEA maven integration because it has no clue this module it is constructing from the pom should be a PLUGIN module and not a plain java one
- IDEA has no real support for provided scope, thus when you run the plugin, the classpath is faulty, resulting in ClassLoading issues because IDEA provided libraries (the same than above) have to be loaded by IDEA itself and not from your plugin classpath. THus you need to manually alter your module's classpath, removing openapi, annotations, jdom, extensions and forms_rt (which have to be added to IDEA's jdk)


ps : i'm publishing a shell script for installing the IDEA files needed into the local repository
http://ideamksplugin.googlecode.com/svn/trunk/install-idea-files.bat

0

Please sign in to leave a comment.