Skip to content

Commit

Permalink
Added use installer
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed Oct 1, 2024
1 parent 0e58573 commit f579045
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
40 changes: 36 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -12,6 +14,7 @@ repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots")
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}

Expand All @@ -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
Expand All @@ -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 }

Expand All @@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -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")
}
}
}
30 changes: 30 additions & 0 deletions src/IC-243/kotlin/io/kotest/plugin/intellij/files.kt
Original file line number Diff line number Diff line change
@@ -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<VirtualFile> {
return FilenameIndex
.getVirtualFilesByName(TagsFilename, false, GlobalSearchScope.allScope(project))
.toList()
}

fun getLocationForFile(
project: Project,
scope: GlobalSearchScope,
name: String,
lineNumber: Int
): PsiLocation<PsiElement>? {
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()
}

0 comments on commit f579045

Please sign in to comment.