@@ -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
@@ -96,11 +99,18 @@ jvmVersion = when (javaVersion) {
9699 throw IllegalArgumentException (" javaVersion must be defined in the product matrix as either \" 17\" or \" 21\" , but is not for $ideaVersion " )
97100 }
98101}
102+
99103kotlin {
100104 compilerOptions {
101105 apiVersion.set(KotlinVersion .KOTLIN_2_1 )
102106 jvmTarget = jvmVersion
103107 }
108+ // This is how you specify the specific JVM requirements, this may be a requirement for the Starter test framework
109+ // jvmToolchain {
110+ // languageVersion = JavaLanguageVersion.of(21)
111+ // @Suppress("UnstableApiUsage")
112+ // vendor = JvmVendorSpec.JETBRAINS
113+ // }
104114}
105115
106116var javaCompatibilityVersion: JavaVersion
@@ -117,18 +127,79 @@ javaCompatibilityVersion = when (javaVersion) {
117127 throw IllegalArgumentException (" javaVersion must be defined in the product matrix as either \" 17\" or \" 21\" , but is not for $ideaVersion " )
118128 }
119129}
130+
120131java {
121132 sourceCompatibility = javaCompatibilityVersion
122133 targetCompatibility = javaCompatibilityVersion
123134}
124135
136+ sourceSets {
137+ main {
138+ java.srcDirs(
139+ listOf (
140+ " src" ,
141+ " third_party/vmServiceDrivers"
142+ )
143+ )
144+ // Add kotlin.srcDirs if we start using Kotlin in the main plugin.
145+ resources.srcDirs(
146+ listOf (
147+ " src" ,
148+ " resources"
149+ )
150+ )
151+ }
152+ test {
153+ java.srcDirs(
154+ listOf (
155+ " src" ,
156+ " testSrc/unit" ,
157+ " third_party/vmServiceDrivers"
158+ )
159+ )
160+ resources.srcDirs(
161+ listOf (
162+ " resources" ,
163+ " testData" ,
164+ " testSrc/unit"
165+ )
166+ )
167+ }
168+
169+ create(" integration" , Action <SourceSet > {
170+ java.srcDirs(" testSrc/integration" )
171+ kotlin.srcDirs(" testSrc/integration" )
172+ resources.srcDirs(" testSrc/integration" )
173+ compileClasspath + = sourceSets[" main" ].output + sourceSets[" test" ].output
174+ runtimeClasspath + = sourceSets[" main" ].output + sourceSets[" test" ].output
175+ })
176+ }
177+
178+ // Configure IntelliJ IDEA to recognize integration as test sources
179+ idea {
180+ module {
181+ testSources.from(sourceSets[" integration" ].kotlin.srcDirs)
182+ testResources.from(sourceSets[" integration" ].resources.srcDirs)
183+ }
184+ }
185+
186+ val integrationImplementation: Configuration by configurations.getting {
187+ extendsFrom(configurations.testImplementation.get())
188+ }
189+
190+ val integrationRuntimeOnly: Configuration by configurations.getting {
191+ extendsFrom(configurations.testRuntimeOnly.get())
192+ }
193+
125194dependencies {
126195 intellijPlatform {
127196 // Documentation on the default target platform methods:
128197 // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#default-target-platforms
129198 // Android Studio versions can be found at: https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html
130199 androidStudio(ideaVersion)
131200 testFramework(TestFrameworkType .Platform )
201+ testFramework(TestFrameworkType .Starter , configurationName = " integrationImplementation" )
202+ testFramework(TestFrameworkType .JUnit5 , configurationName = " integrationImplementation" )
132203
133204 // Plugin dependency documentation:
134205 // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#plugins
@@ -172,6 +243,14 @@ dependencies {
172243 )
173244 )
174245 )
246+
247+ // UI Test dependencies
248+ integrationImplementation(" org.kodein.di:kodein-di-jvm:7.26.1" )
249+ integrationImplementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0" )
250+
251+ // JUnit 5 is required for UI tests
252+ integrationImplementation(" org.junit.jupiter:junit-jupiter:5.11.4" )
253+ integrationRuntimeOnly(" org.junit.platform:junit-platform-launcher" )
175254}
176255
177256intellijPlatform {
@@ -219,37 +298,41 @@ intellijPlatform {
219298 }
220299}
221300
222- sourceSets {
223- main {
224- java.srcDirs(
225- listOf (
226- " src" ,
227- " third_party/vmServiceDrivers"
228- )
229- )
230- // Add kotlin.srcDirs if we start using Kotlin in the main plugin.
231- resources.srcDirs(
232- listOf (
233- " src" ,
234- " resources"
235- )
236- )
237- }
238- test {
239- java.srcDirs(
240- listOf (
241- " src" ,
242- " testSrc/unit" ,
243- " third_party/vmServiceDrivers"
244- )
301+ tasks {
302+ register<Test >(" integration" ) {
303+ description = " Runs only the UI integration tests that start the IDE"
304+ group = " verification"
305+ testClassesDirs = sourceSets[" integration" ].output.classesDirs
306+ classpath = sourceSets[" integration" ].runtimeClasspath
307+ useJUnitPlatform {
308+ includeTags(" ui" )
309+ }
310+
311+ // UI tests should run sequentially (not in parallel) to avoid conflicts
312+ maxParallelForks = 1
313+
314+ // Increase memory for UI tests
315+ minHeapSize = " 1g"
316+ maxHeapSize = " 4g"
317+
318+ systemProperty(" path.to.build.plugin" , buildPlugin.get().archiveFile.get().asFile.absolutePath)
319+ systemProperty(" idea.home.path" , prepareTestSandbox.get().getDestinationDir().parentFile.absolutePath)
320+ systemProperty(
321+ " allure.results.directory" , project.layout.buildDirectory.get().asFile.absolutePath + " /allure-results"
245322 )
246- resources.srcDirs(
247- listOf (
248- " resources" ,
249- " testData" ,
250- " testSrc/unit"
323+
324+ // Disable IntelliJ test listener that conflicts with standard JUnit
325+ systemProperty(" idea.test.cyclic.buffer.size" , " 0" )
326+
327+ // Add required JVM arguments
328+ jvmArgumentProviders + = CommandLineArgumentProvider {
329+ mutableListOf (
330+ " --add-opens=java.base/java.lang=ALL-UNNAMED" ,
331+ " --add-opens=java.desktop/javax.swing=ALL-UNNAMED"
251332 )
252- )
333+ }
334+
335+ dependsOn(buildPlugin)
253336 }
254337}
255338
0 commit comments