How can I compile against "provided" JAR dependencies?

 I'm trying to build my project into an IntelliJ plugin. From within my language/plugin, I want to drive actions inside IntelliJ Ultimate and from other community plugins.

To be able to compile my project, I need to be able to compile against these libraries, of course. However, since they are "provided" by the user's IDE, I don't want to package these when building my plugin.


Are there any example projects that show how to do this?


Currently, I have a solution where I've added my JARs, which generate stubs. When I add this in my language solution, e.g. such that I can access it from behaviors/actions, this works fine.


However, when building the plugin (generates an ant script, intellij plugin), it complains about "dependencies that aren't visible from from the current module". The only way I can avoid the error so far is by manually including the JARs in the ZIP file. But, of course, I don't want/can't do that.


Sometimes, I was able to build my plugin, but I think it was only because of stale caches: I had the language built, then I fiddled around with the module setup to get the plugin to build. I found that I could remove the "JAR" entry in the stub solution, while still keeping the stubs entry. Then, the plugin built fine. However, on the next language rebuild, the JAR was missing again.

Comment actions Permalink

So, I got this working somehow, along with some help from Kemal (thanks again!)


I feel that what I have now is a hack.


First off, here is the goal:

I want to talk to IntelliJ ultimate components from within intentions and actions.

It works:

2018-04-19 20:05:09,345 [ 29492] ERROR - vided.intentions.TestIntention - xml/html tag value 
2018-04-19 20:05:09,345 [ 29492] ERROR - vided.intentions.TestIntention - xml attribute
2018-04-19 20:05:09,345 [ 29492] ERROR - vided.intentions.TestIntention - xml attribute references java class
2018-04-19 20:05:09,345 [ 29492] ERROR - vided.intentions.TestIntention - xml attribute value
2018-04-19 20:05:09,345 [ 29492] ERROR - vided.intentions.TestIntention - xml tag


Hack? What is the right way?

I feel what I have now is a hack. I use two workaround currently:

  • Set the macro idea_home to some inexistent path
  • Manually set idea_home in the run configuration for the Ant script

If I don't set the idea_home macro explicitly, I get the following error:

Setting it to `.` like seen in mpsPlugin etc, IntelliJ will prefix relative paths in the ant file with ${idea_home}, which then makes Ant search for my project-relative stuff in idea_home, which isn't great. As a solution, I set `idea_home` to `.git`, which doesn't appear anywhere in my relative paths that are output to ant, so MPS doesn't replace the paths with $idea_home, they're left alone as they should be.


Because I've set idea_home to a default value, MPS doesn't provide it by default in the Ant run configuration. Interestingly, I didn't need to do this on my first attempt in a different solution. I found out that this is, because I only later introduced the default value for the macro, and MPS doesn't decide what parameters to feed to ant on demand, but rather caches that in the run configuration.


Is there an easier way to get this to work?


This is my primary build file:


This is the stub solution:

Here is a build script that doesn't build anything, it just defines the structural search plugin such that I can depend on it and get the right dependencies in the `plugin.xml` file.


I also tried using an external layout, and reference that somehow, but I couldn't get it to access the JAR via that layout.

Comment actions Permalink

I have filed a bug for the "Error: cannot resolve local path: ${variable}...jar, macro has no default value". Since the error can be circumvented as described (which won't make MPS find the JAR, either), treating this situation as an error doesn't seem to bring any benefit.


Please sign in to leave a comment.