From f579045460a07b3837f0d784ef70e42c3a4e84c6 Mon Sep 17 00:00:00 2001 From: sksamuel Date: Mon, 30 Sep 2024 19:41:55 -0500 Subject: [PATCH] Added use installer --- build.gradle.kts | 40 +++++++++++++++++-- .../kotlin/io/kotest/plugin/intellij/files.kt | 30 ++++++++++++++ 2 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 src/IC-243/kotlin/io/kotest/plugin/intellij/files.kt diff --git a/build.gradle.kts b/build.gradle.kts index 3c4eef5..d5977d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,6 @@ +import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType import org.jetbrains.intellij.platform.gradle.TestFrameworkType +import org.jetbrains.intellij.platform.gradle.models.ProductRelease plugins { id("java") @@ -12,6 +14,7 @@ repositories { maven("https://oss.sonatype.org/content/repositories/snapshots") intellijPlatform { defaultRepositories() + jetbrainsRuntime() } } @@ -22,6 +25,7 @@ data class PluginDescriptor( // https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties val sdkVersion: String, // the version string passed to the intellij sdk gradle plugin val sourceFolder: String, // used as the source root for specifics of this build + val useInstaller: Boolean, // required to be false for EAP builds ) // https://jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html @@ -46,40 +50,53 @@ val descriptors = listOf( until = "223.*", sdkVersion = "2022.3", sourceFolder = "IC-223", + useInstaller = true, ), PluginDescriptor( since = "231.8109.163", // this version is 2023.1 release until = "231.*", sdkVersion = "2023.1", sourceFolder = "IC-231", + useInstaller = true, ), PluginDescriptor( since = "232.5150.116", // this version is 2023.2 until = "232.*", sdkVersion = "2023.2", sourceFolder = "IC-232", + useInstaller = true, ), PluginDescriptor( since = "233.9802.16", // this version is 2023.3 until = "233.*", sdkVersion = "2023.3", sourceFolder = "IC-233", + useInstaller = true, ), PluginDescriptor( since = "241.15989.150", // this version is 2024.1.x until = "242.*", sdkVersion = "2024.1", sourceFolder = "IC-241", + useInstaller = true, ), PluginDescriptor( since = "242.*", // this version is 2024.2.x until = "243.*", sdkVersion = "2024.2", sourceFolder = "IC-242", + useInstaller = true, + ), + PluginDescriptor( + since = "243.*", // this version is 2024.3.x + until = "244.*", + sdkVersion = "243-EAP-SNAPSHOT", + sourceFolder = "IC-243", + useInstaller = false, ), ) -val productName = System.getenv("PRODUCT_NAME") ?: "IC-242" +val productName = System.getenv("PRODUCT_NAME") ?: "IC-243" val jvmTargetVersion = System.getenv("JVM_TARGET") ?: "11" val descriptor = descriptors.first { it.sourceFolder == productName } @@ -98,11 +115,10 @@ intellijPlatform { buildSearchableOptions = false projectName = project.name instrumentCode = true - pluginConfiguration { name = "kotest-plugin-intellij" id = "kotest-plugin-intellij" - description = "Official Kotest plugin for IntelliJ IDEA fo running tests in the IDE" + description = "Official Kotest plugin for IntelliJ IDEA for running tests in the IDE" version = project.version.toString() + "-" + descriptor.sdkVersion vendor { name = "Kotest" @@ -120,7 +136,10 @@ intellijPlatform { dependencies { testImplementation("junit:junit:4.13.2") intellijPlatform { - intellijIdeaCommunity(descriptor.sdkVersion) + // snapshots here https://www.jetbrains.com/intellij-repository/snapshots/ + intellijIdeaCommunity(descriptor.sdkVersion, useInstaller = descriptor.useInstaller) + if (!descriptor.useInstaller) + jetbrainsRuntime() instrumentationTools() pluginVerifier() zipSigner() @@ -179,3 +198,16 @@ tasks { include("**/*Tests.class") } } + +tasks { + printProductsReleases { + channels = listOf(ProductRelease.Channel.EAP) + types = listOf(IntelliJPlatformType.IntellijIdeaCommunity) + untilBuild = provider { null } + + doLast { + val latestEap = productsReleases.get().max() + println("Latest EAP build: $latestEap") + } + } +} diff --git a/src/IC-243/kotlin/io/kotest/plugin/intellij/files.kt b/src/IC-243/kotlin/io/kotest/plugin/intellij/files.kt new file mode 100644 index 0000000..57a9807 --- /dev/null +++ b/src/IC-243/kotlin/io/kotest/plugin/intellij/files.kt @@ -0,0 +1,30 @@ +package io.kotest.plugin.intellij + +import com.intellij.execution.PsiLocation +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.PsiElement +import com.intellij.psi.search.FilenameIndex +import com.intellij.psi.search.GlobalSearchScope +import io.kotest.plugin.intellij.psi.elementAtLine +import io.kotest.plugin.intellij.psi.isTestFile +import io.kotest.plugin.intellij.psi.toPsiLocation +import io.kotest.plugin.intellij.toolwindow.TagsFilename +import org.jetbrains.kotlin.idea.core.util.toPsiFile + +fun findFiles(project: Project): List { + return FilenameIndex + .getVirtualFilesByName(TagsFilename, false, GlobalSearchScope.allScope(project)) + .toList() +} + +fun getLocationForFile( + project: Project, + scope: GlobalSearchScope, + name: String, + lineNumber: Int +): PsiLocation? { + val testFile = FilenameIndex.getVirtualFilesByName(name, scope).firstOrNull { it.isTestFile(project) } ?: return null + // element at line is 1 indexed, so we need to add one + return testFile.toPsiFile(project)?.elementAtLine(lineNumber + 1)?.toPsiLocation() +}