@@ -12,11 +12,14 @@ import java.util.EnumSet
12
12
import java.util.jar.JarFile
13
13
import java.util.zip.ZipFile
14
14
import org.jetbrains.changelog.markdownToHTML
15
- import org.jetbrains.intellij.or
16
- import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel
15
+ import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
16
+ import org.jetbrains.intellij.platform.gradle.TestFrameworkType
17
+ import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask.FailureLevel
18
+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
17
19
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
20
+ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
18
21
19
- fun properties (key : String ) = project.findProperty(key).toString()
22
+ fun properties (key : String ) = project.findProperty(key)? .toString()
20
23
21
24
val isForceBuild = properties(" forceBuild" ) == " true"
22
25
val isForceAgentBuild =
@@ -53,42 +56,84 @@ plugins {
53
56
id(" java" )
54
57
id(" jvm-test-suite" )
55
58
id(" org.jetbrains.kotlin.jvm" ) version " 2.0.20"
56
- id(" org.jetbrains.intellij" ) version " 1.17.4 "
59
+ id(" org.jetbrains.intellij.platform " ) version " 2.0.1 "
57
60
id(" org.jetbrains.changelog" ) version " 2.2.1"
58
61
id(" com.diffplug.spotless" ) version " 6.25.0"
59
62
}
60
63
61
64
val platformVersion: String by project
65
+ val platformType: String by project
62
66
val javaVersion: String by project
63
67
64
- group = properties(" pluginGroup" )
68
+ group = properties(" pluginGroup" )!!
65
69
66
- version = properties(" pluginVersion" )
70
+ version = properties(" pluginVersion" )!!
67
71
68
72
repositories {
69
73
maven { url = uri(" https://www.jetbrains.com/intellij-repository/releases" ) }
70
74
mavenCentral()
75
+ gradlePluginPortal()
76
+ intellijPlatform {
77
+ defaultRepositories()
78
+ jetbrainsRuntime()
79
+ }
71
80
}
72
81
73
- intellij {
74
- pluginName.set(properties(" pluginName" ))
75
- version.set(platformVersion)
76
- type.set(properties(" platformType" ))
82
+ intellijPlatform {
83
+ pluginConfiguration {
84
+ name = properties(" pluginName" )
85
+ version = properties(" pluginVersion" )
86
+ ideaVersion {
87
+ sinceBuild = properties(" pluginSinceBuild" )
88
+ untilBuild = properties(" pluginUntilBuild" )
89
+ }
90
+ // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's
91
+ // manifest
92
+ description =
93
+ projectDir
94
+ .resolve(" README.md" )
95
+ .readText()
96
+ .lines()
97
+ .run {
98
+ val start = " <!-- Plugin description -->"
99
+ val end = " <!-- Plugin description end -->"
77
100
78
- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
79
- plugins.set(properties(" platformPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
101
+ if (! containsAll(listOf (start, end))) {
102
+ throw GradleException (
103
+ " Plugin description section not found in README.md:\n $start ... $end " )
104
+ }
105
+ subList(indexOf(start) + 1 , indexOf(end))
106
+ }
107
+ .joinToString(" \n " )
108
+ .run { markdownToHTML(this ) }
109
+ }
80
110
81
- updateSinceUntilBuild.set(false )
111
+ pluginVerification {
112
+ ides { ides(versionsToValidate) }
113
+ failureLevel = EnumSet .complementOf(skippedFailureLevels)
114
+ }
82
115
}
83
116
84
117
dependencies {
85
- // ActionUpdateThread.jar contains copy of the
86
- // com.intellij.openapi.actionSystem.ActionUpdateThread class
87
- compileOnly(files(" libs/ActionUpdateThread.jar" ))
118
+ intellijPlatform {
119
+ jetbrainsRuntime()
120
+ create(platformType, platformVersion)
121
+ bundledPlugins(
122
+ properties(" platformPlugins" )
123
+ .orEmpty()
124
+ .split(' ,' )
125
+ .map(String ::trim)
126
+ .filter(String ::isNotEmpty))
127
+ instrumentationTools()
128
+ pluginVerifier()
129
+ testFramework(TestFrameworkType .Platform )
130
+ }
131
+
88
132
implementation(" org.commonmark:commonmark:0.22.0" )
89
133
implementation(" org.commonmark:commonmark-ext-gfm-tables:0.22.0" )
90
134
implementation(" org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.23.1" )
91
135
implementation(" io.github.java-diff-utils:java-diff-utils:4.12" )
136
+ testImplementation(" net.java.dev.jna:jna:5.10.0" )
92
137
testImplementation(" org.awaitility:awaitility-kotlin:4.2.1" )
93
138
testImplementation(" org.mockito:mockito-core:5.12.0" )
94
139
testImplementation(" org.junit.jupiter:junit-jupiter:5.10.2" )
@@ -118,10 +163,18 @@ spotless {
118
163
}
119
164
120
165
java {
121
- toolchain { languageVersion.set(JavaLanguageVersion .of(properties(" javaVersion" ).toInt())) }
166
+ toolchain {
167
+ languageVersion.set(JavaLanguageVersion .of(javaVersion.toInt()))
168
+ vendor = JvmVendorSpec .JETBRAINS
169
+ }
122
170
}
123
171
124
- tasks.named(" classpathIndexCleanup" ) { dependsOn(" compileIntegrationTestKotlin" ) }
172
+ kotlin {
173
+ jvmToolchain {
174
+ languageVersion.set(JavaLanguageVersion .of(javaVersion.toInt()))
175
+ vendor = JvmVendorSpec .JETBRAINS
176
+ }
177
+ }
125
178
126
179
fun download (url : String , output : File ) {
127
180
if (output.exists()) {
@@ -205,6 +258,22 @@ fun Test.sharedIntegrationTestConfig(buildCodyDir: File, mode: String) {
205
258
206
259
include(" **/AllSuites.class" )
207
260
261
+ jvmArgs(
262
+ " -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader" ,
263
+ " --add-opens=java.desktop/java.awt.event=ALL-UNNAMED" ,
264
+ " --add-opens=java.desktop/sun.font=ALL-UNNAMED" ,
265
+ " --add-opens=java.desktop/java.awt=ALL-UNNAMED" ,
266
+ " --add-opens=java.desktop/sun.awt=ALL-UNNAMED" ,
267
+ " --add-opens=java.base/java.lang=ALL-UNNAMED" ,
268
+ " --add-opens=java.base/java.util=ALL-UNNAMED" ,
269
+ " --add-opens=java.desktop/javax.swing=ALL-UNNAMED" ,
270
+ " --add-opens=java.desktop/sun.swing=ALL-UNNAMED" ,
271
+ " --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED" ,
272
+ " --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED" ,
273
+ " --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED" ,
274
+ " --add-exports=java.base/jdk.internal.vm=ALL-UNNAMED" ,
275
+ " --add-exports=java.desktop/sun.font=ALL-UNNAMED" )
276
+
208
277
val resourcesDir = project.file(" src/integrationTest/resources" )
209
278
systemProperties(
210
279
" cody-agent.trace-path" to
@@ -215,7 +284,7 @@ fun Test.sharedIntegrationTestConfig(buildCodyDir: File, mode: String) {
215
284
(project.property(" cody.autocomplete.enableFormatting" ) as String? ? : " true" ),
216
285
" cody.integration.testing" to " true" ,
217
286
" cody.ignore.policy.timeout" to 1500 , // Increased to 1500ms as CI tends to be slower
218
- " idea.test.execution.policy" to " com.sourcegraph.cody.test. NonEdtIdeaTestExecutionPolicy" ,
287
+ " idea.test.execution.policy" to " com.sourcegraph.cody.NonEdtIdeaTestExecutionPolicy" ,
219
288
" test.resources.dir" to resourcesDir.absolutePath)
220
289
221
290
environment(
@@ -287,8 +356,8 @@ tasks {
287
356
}
288
357
289
358
fun downloadNodeBinaries (): File {
290
- val nodeCommit = properties(" nodeBinaries.commit" )
291
- val nodeVersion = properties(" nodeBinaries.version" )
359
+ val nodeCommit = properties(" nodeBinaries.commit" )!!
360
+ val nodeVersion = properties(" nodeBinaries.version" )!!
292
361
val url = " https://github.com/sourcegraph/node-binaries/archive/$nodeCommit .zip"
293
362
val zipFile = githubArchiveCache.resolve(" $nodeCommit .zip" )
294
363
download(url, zipFile)
@@ -425,37 +494,12 @@ tasks {
425
494
processResources { dependsOn(" :buildCodeSearch" ) }
426
495
427
496
// Set the JVM compatibility versions
428
- properties( " javaVersion" ) .let {
497
+ javaVersion.let {
429
498
withType<JavaCompile > {
430
499
sourceCompatibility = it
431
500
targetCompatibility = it
432
501
}
433
- withType<KotlinCompile > { kotlinOptions.jvmTarget = it }
434
- }
435
-
436
- patchPluginXml {
437
- version.set(properties(" pluginVersion" ))
438
-
439
- // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's
440
- // manifest
441
- pluginDescription.set(
442
- projectDir
443
- .resolve(" README.md" )
444
- .readText()
445
- .lines()
446
- .run {
447
- val start = " <!-- Plugin description -->"
448
- val end = " <!-- Plugin description end -->"
449
-
450
- if (! containsAll(listOf (start, end))) {
451
- throw GradleException (
452
- " Plugin description section not found in README.md:\n $start ... $end " )
453
- }
454
- subList(indexOf(start) + 1 , indexOf(end))
455
- }
456
- .joinToString(" \n " )
457
- .run { markdownToHTML(this ) },
458
- )
502
+ withType<KotlinJvmCompile > { compilerOptions.jvmTarget.set(JvmTarget .JVM_17 ) }
459
503
}
460
504
461
505
buildPlugin {
@@ -488,46 +532,19 @@ tasks {
488
532
}
489
533
}
490
534
491
- patchPluginXml {
492
- sinceBuild = properties(" pluginSinceBuild" )
493
- untilBuild = properties(" pluginUntilBuild" )
494
- }
535
+ val customRunIde by
536
+ intellijPlatformTesting.runIde.registering {
537
+ version.set(properties(" platformRuntimeVersion" ))
538
+ val myType = IntelliJPlatformType .fromCode(properties(" platformRuntimeType" ) ? : " IC" )
539
+ type.set(myType)
540
+ plugins { plugins(properties(" platformRuntimePlugins" ).orEmpty()) }
541
+ }
495
542
496
543
runIde {
497
544
dependsOn(project.tasks.getByPath(" buildCody" ))
498
545
jvmArgs(" -Djdk.module.illegalAccess.silent=true" )
499
546
500
547
agentProperties.forEach { (key, value) -> systemProperty(key, value) }
501
-
502
- val platformRuntimeVersion = project.findProperty(" platformRuntimeVersion" )
503
- val platformRuntimeType = project.findProperty(" platformRuntimeType" )
504
- if (platformRuntimeVersion != null || platformRuntimeType != null ) {
505
- val ideaInstallDir =
506
- getIdeaInstallDir(
507
- platformRuntimeVersion.or (project.property(" platformVersion" )).toString(),
508
- platformRuntimeType.or (project.property(" platformType" )).toString())
509
- ? : throw GradleException (
510
- " Could not find IntelliJ install for version: $platformRuntimeVersion " )
511
- ideDir.set(ideaInstallDir)
512
- }
513
- // TODO: we need to wait to switch to Platform Gradle Plugin 2.0.0 to be able to have separate
514
- // runtime plugins
515
- // https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1489
516
- // val platformRuntimePlugins = project.findProperty("platformRuntimePlugins")
517
- }
518
-
519
- runPluginVerifier {
520
- ideVersions.set(versionsToValidate)
521
- failureLevel.set(EnumSet .complementOf(skippedFailureLevels))
522
- }
523
-
524
- // Configure UI tests plugin
525
- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
526
- runIdeForUiTests {
527
- systemProperty(" robot-server.port" , " 8082" )
528
- systemProperty(" ide.mac.message.dialogs.as.sheets" , " false" )
529
- systemProperty(" jb.privacy.policy.text" , " <!--999.999-->" )
530
- systemProperty(" jb.consents.confirmation.enabled" , " false" )
531
548
}
532
549
533
550
signPlugin {
@@ -544,7 +561,7 @@ tasks {
544
561
// Specify pre-release label to publish the plugin in a custom Release Channel automatically.
545
562
// Read more:
546
563
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
547
- val channel = properties(" pluginVersion" ).split(' -' ).getOrElse(1 ) { " default" }
564
+ val channel = properties(" pluginVersion" )!! .split(' -' ).getOrElse(1 ) { " default" }
548
565
channels.set(listOf (channel))
549
566
550
567
if (channel == " default" ) {
@@ -565,8 +582,8 @@ tasks {
565
582
sourceSets {
566
583
create(" integrationTest" ) {
567
584
kotlin.srcDir(" src/integrationTest/kotlin" )
568
- compileClasspath + = main.get().output
569
- runtimeClasspath + = main. get().output
585
+ compileClasspath + = main.get().output + configurations.testCompileClasspath.get()
586
+ runtimeClasspath + = compileClasspath + configurations.testRuntimeClasspath. get()
570
587
}
571
588
}
572
589
@@ -600,12 +617,11 @@ tasks {
600
617
withType<Test > {
601
618
systemProperty(
602
619
" idea.test.src.dir" , " ${layout.buildDirectory.asFile.get()} /resources/integrationTest" )
620
+ systemProperty(" idea.force.use.core.classloader" , " true" )
603
621
}
604
622
605
623
withType<KotlinCompile > { dependsOn(" copyProtocol" ) }
606
624
607
- named(" classpathIndexCleanup" ) { dependsOn(" processIntegrationTestResources" ) }
608
-
609
625
named(" check" ) { dependsOn(" integrationTest" ) }
610
626
611
627
test {
0 commit comments