I am developing a plugin for IntelliJ IDEA. The way I am going about this is by creating a plugin project in IDEA, then packaging this into a jar with appropriate META-INF/plugin.xml
, and installing the plugin from the jar.
The problem is that I would like to add a dependency on org.scala-lang:scala-library:2.11.0
. I have this specified as a library dependency in the IDEA project, but this information never seems to get passed along to the generated JAR.
How can I include this information in such a way that IntelliJ IDEA will recognize it?
Press Alt+Insert to open the Generate context menu. From the context menu, select Add dependency. In the Dependencies tool window, in the search field, start typing the name of your dependency. In the list of results select the one you need and click Add.
From the main menu, select File | Project Structure Ctrl+Alt+Shift+S , and go to Modules | Dependencies. In the next dialog, click Edit, and then click Configure next to the Include transitive dependencies option. Select the dependencies you want to include in the library and click OK.
Reload a Maven project If you want to control the importing process of your project, you can manually trigger the action. In the Maven tool window, right-click a linked project. On invoking this action, IntelliJ IDEA parses the project structure in the Maven tool window.
As far as I understand, you want to bundle some library (e.g. scala library) with your plugin. This is pretty simple.
Go to Project Settings, select module and go to Dependencies tab. Set scope for the library you want to bundle to 'Compile'. In this example it is 'checker-framework' library. 'groovy-2.3.6' library will not be bundled due to its scope set to 'Provided'. Save changes.
Prepare plugin for deployment
Then you got plugin, zipped, ready for deployment (uploading to repo or installing locally) in the root of project. It will contain lib
folder with all necessary jars.
The officially supported plugin dependency management solution is to use Gradle with the gradle-intellij-plugin, via Gradle's dependencies
or the intellij.plugins
entry points. If you want to add a dependency on an artifact (ex. hosted on Maven Central), then configure dependencies
just as you normally would in a Gradle based project:
buildscript {
repositories {
mavenCentral()
}
}
dependencies {
compile("org.scala-lang:scala-library:2.11.0")
}
The intellij.plugins
entry point will add an artifact in the current project, as well as a <depends>
tag to your plugin.xml
file. To install an external plugin alongside your own, for example if you are using the Plugin Extensions feature (suppose the plugin is hosted on the JetBrains Plugin Repository), use the following snippet:
plugins {
id "org.jetbrains.intellij" version "0.2.13"
}
intellij {
//...
plugins "org.intellij.scala:2017.2.638"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With