| 1 | import org.jetbrains.changelog.markdownToHTML |
| 2 | import org.jetbrains.intellij.platform.gradle.TestFrameworkType |
| 3 | import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask |
| 4 | import org.gradle.kotlin.dsl.intellijPlatform |
| 5 | |
| 6 | fun environment(key: String) = providers.environmentVariable(key) |
| 7 | |
| 8 | val platformVersion: String by project |
| 9 | val pluginGroup: String by project |
| 10 | val pluginVersion: String by project |
| 11 | val isEap get() = environment("RELEASE_CHANNEL").orNull == "eap" |
| 12 | |
| 13 | plugins { |
| 14 | kotlin("jvm") version "2.1.0" |
| 15 | id("org.jetbrains.intellij.platform") version "2.7.2" |
| 16 | id("org.jetbrains.changelog") version "2.1.2" |
| 17 | id("org.jetbrains.qodana") version "0.1.13" |
| 18 | id("io.sentry.jvm.gradle") version "5.8.0" |
| 19 | } |
| 20 | |
| 21 | group = pluginGroup |
| 22 | version = if (isEap) "$pluginVersion-eap" else pluginVersion |
| 23 | |
| 24 | repositories { |
| 25 | mavenCentral() |
| 26 | intellijPlatform { |
| 27 | defaultRepositories() |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | sourceSets { |
| 32 | val testIntegration = create("testIntegration") |
| 33 | testIntegration.apply { |
| 34 | compileClasspath += sourceSets.main.get().output |
| 35 | runtimeClasspath += sourceSets.main.get().output |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | val testIntegrationImplementation: Configuration by configurations.getting { |
| 40 | extendsFrom(configurations.testImplementation.get()) |
| 41 | } |
| 42 | |
| 43 | dependencies { |
| 44 | intellijPlatform { |
| 45 | intellijIdeaCommunity(platformVersion) |
| 46 | plugins(listOf("org.jetbrains.plugins.terminal:241.14494.150")) |
| 47 | testFramework(TestFrameworkType.Platform) |
| 48 | testFramework(TestFrameworkType.Starter, "243.21565.193", configurationName = "testIntegrationImplementation") |
| 49 | } |
| 50 | implementation("com.posthog.java:posthog:1.2.0") |
| 51 | |
| 52 | testImplementation("junit:junit:4.13.2") |
| 53 | testImplementation("io.mockk:mockk:1.14.2") { |
| 54 | // this transitive dependency (1.6.4) conflicts with built-in version (1.7.3) |
| 55 | // otherwise e2e tests (runIdeForUiTests) will have linkage errors |
| 56 | exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core") |
| 57 | } |
| 58 | testImplementation("com.squareup.okhttp3:logging-interceptor:4.12.0") |
| 59 | testImplementation("com.automation-remarks:video-recorder-junit5:2.0") |
| 60 | testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.0") // required to run both JUnit 5 and JUnit 3 |
| 61 | |
| 62 | testIntegrationImplementation("org.junit.jupiter:junit-jupiter:5.7.1") |
| 63 | testIntegrationImplementation("org.kodein.di:kodein-di-jvm:7.20.2") |
| 64 | testIntegrationImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1") |
| 65 | } |
| 66 | |
| 67 | kotlin { |
| 68 | jvmToolchain(17) |
| 69 | } |
| 70 | |
| 71 | intellijPlatform { |
| 72 | pluginConfiguration { |
| 73 | ideaVersion { |
| 74 | sinceBuild = "241" |
| 75 | } |
| 76 | } |
| 77 | publishing { |
| 78 | token = environment("PUBLISH_TOKEN") |
| 79 | hidden = true |
| 80 | val channel = if (isEap) "eap" else "default" |
| 81 | channels = listOf(channel) |
| 82 | } |
| 83 | signing { |
| 84 | certificateChain = environment("CERTIFICATE_CHAIN") |
| 85 | privateKey = environment("PRIVATE_KEY") |
| 86 | password = environment("PRIVATE_KEY_PASSWORD") |
| 87 | } |
| 88 | pluginVerification { |
| 89 | ides { |
| 90 | create("IC", "2025.2") |
| 91 | create("IC", "2025.1") |
| 92 | create("IC", "2024.3") |
| 93 | create("IC", "2024.2") |
| 94 | create("IC", "2024.1") |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | qodana { |
| 100 | cachePath = provider { file(".qodana").canonicalPath } |
| 101 | reportPath = provider { file("build/reports/inspections").canonicalPath } |
| 102 | saveReport = true |
| 103 | showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) |
| 104 | } |
| 105 | |
| 106 | tasks { |
| 107 | withType<PrepareSandboxTask> { |
| 108 | from("../../binary/bin") { |
| 109 | into(pluginName.map { "$it/core" }) |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | patchPluginXml { |
| 114 | pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.get() |
| 115 | .substringAfter("<!-- Plugin description -->") |
| 116 | .substringBefore("<!-- Plugin description end -->") |
| 117 | .let(::markdownToHTML) |
| 118 | check(pluginDescription.get().isNotEmpty()) { "Plugin description section not found in README.md" } |
| 119 | } |
| 120 | |
| 121 | runIde { |
| 122 | val openProject = "$projectDir/../../manual-testing-sandbox" |
| 123 | argumentProviders += CommandLineArgumentProvider { |
| 124 | listOf(openProject, "$openProject/test.kt") |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | test { |
| 129 | useJUnitPlatform() |
| 130 | environment("CONTINUE_GLOBAL_DIR", "${rootProject.projectDir}/src/test/kotlin/com/github/continuedev/continueintellijextension/test-continue") |
| 131 | jvmArgumentProviders += CommandLineArgumentProvider { listOf("-Dide.browser.jcef.sandbox.enable=false") } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | val testIntegration = task<Test>("testIntegration") { |
| 136 | val integrationTestSourceSet = sourceSets.getByName("testIntegration") |
| 137 | testClassesDirs = integrationTestSourceSet.output.classesDirs |
| 138 | classpath = integrationTestSourceSet.runtimeClasspath |
| 139 | systemProperty("CONTINUE_PLUGIN_DIR", tasks.prepareSandbox.get().pluginDirectory.get().asFile) |
| 140 | environment("CONTINUE_GLOBAL_DIR", "${rootProject.projectDir}/src/testIntegration/kotlin/com/github/continuedev/continueintellijextension/test-continue") |
| 141 | useJUnitPlatform() |
| 142 | dependsOn(tasks.prepareSandbox) |
| 143 | } |