简体   繁体   中英

How to use gradle in intellij idea plugin project?

I am developing an idea plugin, and it is an intellij idea project.

I want to use gradle to manage the dependency.

How to config?

There is now a Gradle plugin for building IntelliJ Platform Plugins. In order to use it, you will need to add the following snippet to your build.gradle file.

plugins {
  id "org.jetbrains.intellij" version "0.0.31"
}

apply plugin: 'org.jetbrains.intellij'

For more information, please see this guide to help you get started.

Ok, there are multiple ways to create an IntelliJ project, "templates" if you like, and unfortunately you can only pick one of them ( IntelliJ plugin or gradle ).

Thankfully, it's easy to configure a project for gradle in IntelliJ.

First, create a new project from the IntelliJ Platform Plugin template. You don't need to choose any Additional Libraries and Frameworks . This will give you a project structure including META-INF/plugin.xml and the Project SDK should be something like IDEA IU-129.451 .

From here, simply create a new file named build.gradle at the top level of your project, including for example this line:

apply plugin: 'java'

Now, close the project. You can now use File -> Import Project... , choose the build.gradle file that you just created, and import the project. Accept the defaults for importing and hit OK .

The project is now opened with both gradle and intellij plugin enabled!

Notice that the source root src has disappeared and you will need to right click on src in the Project pane and select Mark Directory As -> Source Root .

To prepare the plugin for deployment, there is still the menu option in the Build menu for that - if you want to automate that part via gradle, good luck and please let us know how it's done ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM