IDEA independent building?

Answered

Hello,

 

I'm using the gradle-intellij-plugin to build a IntelliJ plugin for the language "PureBasic". The plugin should run in any IntelliJ based IDE, thats why I don't depend on stuff like the SDK functionality as it is "not recommended to use “SDK” in non-IntelliJ IDEA IDEs" (https://www.jetbrains.org/intellij/sdk/docs/reference_guide/project_model/sdk.html).

However I also cannot implement the BuilderService without depending on Java stuff (or IDEA). It would be nice if someone can tell me that I am wrong with this, but I haven't found any plugin implementing the stuff correctly according to the distributed documentation on the web.

 

---

 

According to the "External Builder API" (https://www.jetbrains.org/intellij/sdk/docs/reference_guide/frameworks_and_external_apis/external_builder_api.html) documentation I'd have to:

  1. Create a jps-plugin Module inside my main plugin
  2. The jps-plugin should not depend on the whole platform, such that external builders like gradle etc. can run it without loading a complete IDE
  3. The Jetbrains Project System (JPS) is abstracting the project structure and settings stored within the project as well as global settings, such that we do not need to parse the project files completely by hand.

Now according to the gradle-intellij-plugin (https://github.com/JetBrains/gradle-intellij-plugin), I can build the jps-plugin by setting the intellij.type = 'JPS'. Now there comes the problem:

  1. The correct way according to documentation would be
    intellij {
    type = 'JPS'
    // no plugins
    }
    Tons of errors like these will come up: package org.jetbrains.jps.builders does not exist
  2. This one removes the org.jetbrains.jps.builders package problems, but it depends on the java plugin
    intellij {
    type = 'JPS'
    plugins = ['java']
    }
    So it depends on the java plugin, finds the builders stuff, but still throws these errors:
    package org.jetbrains.jps.model does not exist
    package org.jetbrains.annotations does not exist.
  3. This one works, but is probably defaulting to type = 'IC' together with the full java subsystem?
    intellij {
    type = 'jps'
    plugins = ['java']
    }
    So it will load the full environment for the external build system?

 

As you can read in the gradle-intellij-plugin source code (https://github.com/JetBrains/gradle-intellij-plugin/blob/442132424293b3ca2eaa09b2189f80bf5c6c724b/src/main/groovy/org/jetbrains/intellij/dependency/JpsIdeaDependency.groovy#L7), the JPS type basically wants to have the dependencies ['jps-builders.jar', 'jps-model.jar', 'util.jar'] and in jps-builders.jar I expected the org.jetbrains.jps.builders package, but it doesn't seem to "link" to it without plugins = ['java'].

 

The plugin which I think is closest to the documentation is the Erlang plugin, however it does not specify the intellij.type at all, such that it defaults to 'IC' and is bloated according to the gradle-intellij-plugin, isn't it? The rust plugin doesn't even have a jps-plugin. Can someone help me with this?

 

---

 

The source code of my plugin is stored on github:

https://github.com/Bradan/intellij-purebasic

And the file I refer to is this

https://github.com/Bradan/intellij-purebasic/blob/master/jps-plugin/build.gradle

2 comments
Comment actions Permalink

Hello, your observations are correct. Basically JPS requires Java plugin to be present, as it contains most of its functionality. Thus. JPS cannot be used outside of IDEs with bundled Java support currently. We'll update the docs with a corrresponding note, thanks.

0
Comment actions Permalink

Thank you for your response and sorry for my late one.

In the mean time I've tried to come up with a solution that fits all IDEs, however it would be nice if someone more experienced inside the source code than me could guide me to a good way, because the best one I've found would be creating a new action for compiling specifically only the sources of the custom language.

Another experiment I made was implementing an own ProjectTaskRunner (canRun & run), however I didn't really understand the (Async)Promise<Result> concept. It always succeeds and never shows the error specified through setError("Hello"). Besides this, I'm not sure if it would work e.g. inside WebStorm, as there is no build button at all. How do I get the build button in WebStorm without creating a custom action?

Are the developers trying to generalize the building, such that I can assume jps-plugins with BuilderServices will be supported by all IDEs in the future?

0

Please sign in to leave a comment.