Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Plugin Development - Gradle does not find dependency of IntelliJ

I am currently developing a plugin for IntelliJ and trying to use another built-in IntelliJ Plugin as dependency (git4idea). As described in the IntelliJ Plugin Development documentation, I added the required JARs to my class Path in Project Structure: Project Structure Dialog Screenshot

I also added <depends>Git4Idea</depends> to my plugin.xml file.

IntelliJ finds these jars now and Code Completion works well, no errors found... But when I try to build the Plugin with gradle I get ClassNotFound errors or errors like this:

TkGitflowBaseImpl.java:15: error: package git4idea.commands does not exist
import git4idea.commands.Git;
                        ^

Obviously, Gradle does not find these jars. Since they are part of the IntelliJ installation, I can't just add them to a lib folder and add them as local jars in the build.gradle file. As Gradle JVM, I chose the exact same JVM I chose as JVM behind the IDEA Platform SDK, so the jars should be available to Gradle.

Do you know how I can help Gradle find these jars or add them as "provided" dependencies without adding them to a lib folder?

I am using IntelliJ IDEA 2017.2.5 and Gradle 4.2.1

like image 289
Moritz Hohmeier Avatar asked Dec 05 '17 13:12

Moritz Hohmeier


People also ask

How do I sync Gradle dependencies in IntelliJ?

We can configure the settings for how IntelliJ IDEA syncs with Gradle by pressing the settings icon in the Gradle tool window, and selecting Auto-Reload Settings. We can set IntelliJ IDEA to automatically reload the project after "Any changes" in the build script files, so changes are automatically reloaded.

How do I add a dependency in Gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.

How do I refresh all Gradle dependencies in IntelliJ?

We can do this by: Selecting one of the suggestions in the message; Pressing on the Refresh Gradle icon in the top right, Using the keyboard shortcut ⇧⌘I (macOS), or Ctrl+Shift+O (Windows/Linux).

What is the difference between IntelliJ IDEA and Gradle plugin?

Both plugins are bundled and enabled by default. IntelliJ IDEA lets you add and manage dependencies in your Gradle project. You can add dependencies, and view them in the diagram. Any dependency added to the project is managed by Gradle. The best way to add or manage a dependency is in the build.gradle file.

How do I add a dependency in IntelliJ Gradle?

Click Add and reload your project. IntelliJ IDEA adds a dependency to the build.gradle file. IntelliJ IDEA also adds the dependency to the Dependencies node in the Gradle tool window and to the External Libraries in the Project tool window.

How do I enable cyclic dependencies in IntelliJ?

Besides the transitive dependencies, IntelliJ IDEA also indicates cyclic dependencies in the Gradle tool window. If you add a dependency configuration of the source set, it will be displayed in the Gradle tool window as well. Make sure you have the bundled Diagrams and Gradle Extension plugins enabled.

How do I create a new plugin for IntelliJ Platform?

Creating a new Gradle-based IntelliJ Platform plugin can be handled with the New Project wizard or the IntelliJ Platform Plugin Template, a pure and preconfigured boilerplate. The plugin provides a number of tasks to the Gradle build system that helps create and maintain plugins for IntelliJ-based IDEs.


1 Answers

After reading through the documentation of the IntelliJ Gradle Plugin (https://github.com/JetBrains/gradle-intellij-plugin), I saw that that a "=" was missing in the build.gradle file like:

intellij {
    version '2017.2.5'
    pluginName 'pluginname'
    plugins = ['Git4Idea']
}

instead of

intellij {
    version '2017.2.5'
    pluginName 'pluginname'
    plugins ['Git4Idea']
}
like image 81
Moritz Hohmeier Avatar answered Sep 23 '22 18:09

Moritz Hohmeier