@@ -28,6 +28,8 @@ allprojects {
2828
2929repositories {
3030 mavenCentral()
31+ maven(" https://cache-redirector.jetbrains.com/packages.jetbrains.team/maven/p/ij/intellij-ide-starter" )
32+ maven(" https://mvnrepository.com/artifact/com.jetbrains.intellij.tools/ide-starter-driver" )
3133 intellijPlatform {
3234 defaultRepositories()
3335 }
@@ -41,6 +43,7 @@ plugins {
4143 id(" org.jetbrains.intellij.platform" ) version " 2.7.2" // IntelliJ Platform Gradle Plugin
4244 id(" org.jetbrains.kotlin.jvm" ) version " 2.2.0" // Kotlin support
4345 id(" org.jetbrains.changelog" ) version " 2.2.0" // Gradle Changelog Plugin
46+ idea // IntelliJ IDEA support
4447}
4548
4649// By default (e.g. when we call `runIde` during development), the plugin version is SNAPSHOT
@@ -90,11 +93,18 @@ jvmVersion = when (javaVersion) {
9093 throw IllegalArgumentException (" javaVersion must be defined in the product matrix as either \" 17\" or \" 21\" , but is not for $ideaVersion " )
9194 }
9295}
96+
9397kotlin {
9498 compilerOptions {
9599 apiVersion.set(KotlinVersion .KOTLIN_2_1 )
96100 jvmTarget = jvmVersion
97101 }
102+ // This is how you specify the specific JVM requirements, this may be a requirement for the Starter test framework
103+ // jvmToolchain {
104+ // languageVersion = JavaLanguageVersion.of(21)
105+ // @Suppress("UnstableApiUsage")
106+ // vendor = JvmVendorSpec.JETBRAINS
107+ // }
98108}
99109
100110var javaCompatibilityVersion: JavaVersion
@@ -111,18 +121,79 @@ javaCompatibilityVersion = when (javaVersion) {
111121 throw IllegalArgumentException (" javaVersion must be defined in the product matrix as either \" 17\" or \" 21\" , but is not for $ideaVersion " )
112122 }
113123}
124+
114125java {
115126 sourceCompatibility = javaCompatibilityVersion
116127 targetCompatibility = javaCompatibilityVersion
117128}
118129
130+ sourceSets {
131+ main {
132+ java.srcDirs(
133+ listOf (
134+ " src" ,
135+ " third_party/vmServiceDrivers"
136+ )
137+ )
138+ // Add kotlin.srcDirs if we start using Kotlin in the main plugin.
139+ resources.srcDirs(
140+ listOf (
141+ " src" ,
142+ " resources"
143+ )
144+ )
145+ }
146+ test {
147+ java.srcDirs(
148+ listOf (
149+ " src" ,
150+ " testSrc/unit" ,
151+ " third_party/vmServiceDrivers"
152+ )
153+ )
154+ resources.srcDirs(
155+ listOf (
156+ " resources" ,
157+ " testData" ,
158+ " testSrc/unit"
159+ )
160+ )
161+ }
162+
163+ create(" integration" , Action <SourceSet > {
164+ java.srcDirs(" testSrc/integration" )
165+ kotlin.srcDirs(" testSrc/integration" )
166+ resources.srcDirs(" testSrc/integration" )
167+ compileClasspath + = sourceSets[" main" ].output + sourceSets[" test" ].output
168+ runtimeClasspath + = sourceSets[" main" ].output + sourceSets[" test" ].output
169+ })
170+ }
171+
172+ // Configure IntelliJ IDEA to recognize integration as test sources
173+ idea {
174+ module {
175+ testSources.from(sourceSets[" integration" ].kotlin.srcDirs)
176+ testResources.from(sourceSets[" integration" ].resources.srcDirs)
177+ }
178+ }
179+
180+ val integrationImplementation: Configuration by configurations.getting {
181+ extendsFrom(configurations.testImplementation.get())
182+ }
183+
184+ val integrationRuntimeOnly: Configuration by configurations.getting {
185+ extendsFrom(configurations.testRuntimeOnly.get())
186+ }
187+
119188dependencies {
120189 intellijPlatform {
121190 // Documentation on the default target platform methods:
122191 // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#default-target-platforms
123192 // Android Studio versions can be found at: https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
124193 androidStudio(ideaVersion)
125194 testFramework(TestFrameworkType .Platform )
195+ testFramework(TestFrameworkType .Starter , configurationName = " integrationImplementation" )
196+ testFramework(TestFrameworkType .JUnit5 , configurationName = " integrationImplementation" )
126197
127198 // Plugin dependency documentation:
128199 // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#plugins
@@ -166,6 +237,14 @@ dependencies {
166237 )
167238 )
168239 )
240+
241+ // UI Test dependencies
242+ integrationImplementation(" org.kodein.di:kodein-di-jvm:7.26.1" )
243+ integrationImplementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0" )
244+
245+ // JUnit 5 is required for UI tests
246+ integrationImplementation(" org.junit.jupiter:junit-jupiter:5.11.4" )
247+ integrationRuntimeOnly(" org.junit.platform:junit-platform-launcher" )
169248}
170249
171250intellijPlatform {
@@ -213,37 +292,42 @@ intellijPlatform {
213292 }
214293}
215294
216- sourceSets {
217- main {
218- java.srcDirs(
219- listOf (
220- " src" ,
221- " third_party/vmServiceDrivers"
222- )
223- )
224- // Add kotlin.srcDirs if we start using Kotlin in the main plugin.
225- resources.srcDirs(
226- listOf (
227- " src" ,
228- " resources"
229- )
230- )
231- }
232- test {
233- java.srcDirs(
234- listOf (
235- " src" ,
236- " testSrc/unit" ,
237- " third_party/vmServiceDrivers"
238- )
295+ tasks {
296+ register<Test >(" integration" ) {
297+ description = " Runs only the UI integration tests that start the IDE"
298+ group = " verification"
299+ testClassesDirs = sourceSets[" integration" ].output.classesDirs
300+ classpath = sourceSets[" integration" ].runtimeClasspath
301+ useJUnitPlatform {
302+ includeTags(" ui" )
303+ }
304+
305+ // UI tests should run sequentially (not in parallel) to avoid conflicts
306+ maxParallelForks = 1
307+
308+ // Increase memory for UI tests
309+ minHeapSize = " 1g"
310+ maxHeapSize = " 4g"
311+
312+ systemProperty(" path.to.build.plugin" , buildPlugin.get().archiveFile.get().asFile.absolutePath)
313+ systemProperty(" idea.home.path" , prepareTestSandbox.get().getDestinationDir().parentFile.absolutePath)
314+ systemProperty(
315+ " allure.results.directory" , project.layout.buildDirectory.get().asFile.absolutePath + " /allure-results"
239316 )
240- resources.srcDirs(
241- listOf (
242- " resources" ,
243- " testData" ,
244- " testSrc/unit"
317+ // systemProperty("uiPlatformBuildVersion", providers.gradleProperty("uiPlatformBuildVersion").get())
318+
319+ // Disable IntelliJ test listener that conflicts with standard JUnit
320+ systemProperty(" idea.test.cyclic.buffer.size" , " 0" )
321+
322+ // Add required JVM arguments
323+ jvmArgumentProviders + = CommandLineArgumentProvider {
324+ mutableListOf (
325+ " --add-opens=java.base/java.lang=ALL-UNNAMED" ,
326+ " --add-opens=java.desktop/javax.swing=ALL-UNNAMED"
245327 )
246- )
328+ }
329+
330+ dependsOn(buildPlugin)
247331 }
248332}
249333
0 commit comments