Search code examples
kotlingradleintellij-idea

How to update the Kotlin dependencies for IntelliJ IDEA plugin?


I am specializing on TypeScript and C#, but need to use the Kotlin + Gradle to develop the IntelliJ IDEA plugins.

In the build.gradle.kts there is the dependencies list seems to be similar with dependencies of package.json of Node.js:

plugins {
    // Java support
    id("java")
    // Kotlin support
    id("org.jetbrains.kotlin.jvm") version "1.7.10"
    // Gradle IntelliJ Plugin
    id("org.jetbrains.intellij") version "1.12.0"
    // Gradle Changelog Plugin
    id("org.jetbrains.changelog") version "1.3.0"
    // Gradle Qodana Plugin
    id("org.jetbrains.qodana") version "0.1.12"
}

How to check for the updates and update these dependencies?

I have not installed consciously the Java/Kotlin project building tools like Gradle (if to input gradle --help, it will be told that this application is undefined). However, is should be some non-cli method when using the IntelliJ IDEA.


Solution

  • Ah, welcome to the wonderful world of Gradle.

    Your insight is slightly off: you are looking at the plugins block there. Those are dependencies for your build code and not so much your application code (though plugins can add dependencies for the application and do really anything else in the build).

    For your application itself there is another block which looks like this:

    dependencies {
       // Declare a dependency on the Kotlin coroutines library in application code
       implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
    }
    

    As for how these get updated? Well simply change the version number (for plugins or dependencies) and Gradle will download the latest version for you. So the build.gradle.kts file is like a package.json, but there is no npm or yarn command is needed to install new dependencies each time: you just modify your build.gradle.kts. The build then should be deterministic based on what is in the build file.

    Checking for updates is not a first-order Gradle feature but you can look at plugins like the Gradle versions plugin.