New intelliJPlatformResolver helper to control the IntelliJ Platform Gradle Plugin dependency extraction

In the latest IntelliJ Platform Gradle Plugin 2.6.1-SNAPSHOT, I’ve introduced a new mechanism for resolving the IntelliJ Platform artifacts and extracting them into the custom location.
This feature allows you to keep extracted IDEs in a specific place and not rely on the Gradle transformer. The transformer has a known issue of re-extracting the already-present archive if the Gradle build file’s classpath changes, resulting in multiple extracted IDE copies being present in the Gradle cache.

To utilize this incubating feature, replace the main IntelliJ Platform dependency definition (such as create(type, version)) with:

val intelliJPlatformResolver = project.intelliJPlatformResolver()

dependencies {
    intellijPlatform {
        local(
            intelliJPlatformResolver.resolve(
                type = providers.gradleProperty("platformType"),
                version = providers.gradleProperty("platformVersion"),
            )
        )
    }
}

By default, IDEs are extracted in the PROJECT_DIR/.intellijPlatform/ides/ directory. Each IDE directory name is set to $type-$version. Both cache directory and name composition can be adjusted with i.e.:

val intelliJPlatformResolver = intelliJPlatformResolver {
    cacheDirectory = layout.dir(provider { File("/home/me/ides") })
    
    name = { it: RequestedIntelliJPlatform ->
        val today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
        "${it.type}-${it.version}-$today"
    }
}

See also:

4 Likes

intelliJPlatformResolver is not longer accessible in version 2.7.0, any update on this? Thanks!

This is now covered by the useCustomCache flag available when declaring a dependency on the IntelliJ Platform.
See: Dependencies Extension | IntelliJ Platform Plugin SDK

I was just able to get this working; because it wasn’t as non-trivial to enable this flag + specify where the IDEs directory would land, below is my notes:

  1. Change your build script dependencies section to look like below:

    dependencies {
        intellijPlatform {
            create(
                type = IntelliJPlatformType.fromCode(platformType),
                version = platformVersion
            ) {
                useCustomCache = true
            }
    
            ...
        }
    }
    

    (Or, instead of create, one of the IDE-specific targets like intellijIdeaUltimate for IU)

  2. Add the below to your gradle.properties file

    org.jetbrains.intellij.platform.intellijPlatformIdesCache=~/.intellijPlatform/ides/
    

    Note: Using ~ for specifying home directory does not currently work in 2.7.2 - see JetBrains/intellij-platform-gradle-plugin#2011 for details.

Thanks @chriscarini, your PR is now merged and will be available with the upcoming release!

1 Like

Awesome, thank you Jakub! :folded_hands:

1 Like

Thanks a lot for this feature! This helps a lot.

1 Like

FTR, the useCustomCache property is now renamed to customCache.

Minor correction, it’s actually useCache (at least, in 2.9.0) :wink:

1 Like