1
+ import org.jetbrains.changelog.Changelog
1
2
import org.jetbrains.changelog.markdownToHTML
2
- import org.jetbrains.kotlin. gradle.tasks.KotlinCompile
3
+ import org.jetbrains.intellij.platform. gradle.IntelliJPlatformType
3
4
4
5
fun properties (key : String )= project.findProperty(key).toString()
5
6
@@ -10,18 +11,34 @@ plugins {
10
11
id(" groovy" )
11
12
// Kotlin support
12
13
id(" org.jetbrains.kotlin.jvm" ) version" 1.9.23"
13
- // Gradle IntelliJ Plugin
14
- id(" org.jetbrains.intellij" ) version" 1.13.3 "
14
+ // Gradle IntelliJPlatform Plugin
15
+ id(" org.jetbrains.intellij.platform " ) version" 2.6.0 "
15
16
// Gradle Changelog Plugin
16
17
id(" org.jetbrains.changelog" ) version" 2.2.1"
17
18
// Gradle Qodana Plugin
18
19
id(" org.jetbrains.qodana" ) version" 0.1.13"
20
+ // Gradle Kover Plugin
21
+ id(" org.jetbrains.kotlinx.kover" ) version" 0.9.1"
19
22
// Generate Moshi adapters.
20
23
id(" com.google.devtools.ksp" ) version" 1.9.23-1.0.20"
21
24
}
22
25
23
- group= properties(" pluginGroup" )
24
- version= properties(" pluginVersion" )
26
+ group= providers.gradleProperty(" pluginGroup" ).get()
27
+ version= providers.gradleProperty(" pluginVersion" ).get()
28
+
29
+ // Set the JVM language level used to build the project.
30
+ kotlin {
31
+ jvmToolchain(17 )
32
+ }
33
+
34
+ // Configure project's dependencies
35
+ repositories {
36
+ mavenCentral()
37
+ // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
38
+ intellijPlatform {
39
+ defaultRepositories()
40
+ }
41
+ }
25
42
26
43
dependencies {
27
44
implementation(platform(" com.squareup.okhttp3:okhttp-bom:4.12.0" ))
@@ -37,23 +54,83 @@ dependencies {
37
54
implementation(" org.zeroturnaround:zt-exec:1.12" )
38
55
39
56
testImplementation(kotlin(" test" ))
40
- }
57
+ // required by the unit tests
58
+ testImplementation(kotlin(" test-junit5" ))
59
+ // required by IntelliJ test framework
60
+ testImplementation(" junit:junit:4.13.2" )
41
61
42
- // Configure project's dependencies
43
- repositories {
44
- mavenCentral()
45
- maven(url= " https://www.jetbrains.com/intellij-repository/snapshots" )
62
+
63
+ // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
64
+ intellijPlatform {
65
+ gateway(providers.gradleProperty(" platformVersion" ))
66
+
67
+ // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
68
+ bundledPlugins(providers.gradleProperty(" platformBundledPlugins" ).map { it.split(' ,' ) })
69
+
70
+ // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
71
+ plugins(providers.gradleProperty(" platformPlugins" ).map { it.split(' ,' ) })
72
+
73
+ pluginVerifier()
74
+ }
46
75
}
47
76
48
77
// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
49
- intellij {
50
- pluginName.set(properties(" pluginName" ))
51
- version.set(properties(" platformVersion" ))
52
- type.set(properties(" platformType" ))
53
-
54
- downloadSources.set(properties(" platformDownloadSources" ).toBoolean())
55
- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
56
- plugins.set(properties(" platformPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
78
+ intellijPlatform {
79
+ buildSearchableOptions= false
80
+ instrumentCode= true
81
+
82
+ pluginConfiguration {
83
+ name= providers.gradleProperty(" pluginName" )
84
+ version= providers.gradleProperty(" pluginVersion" )
85
+
86
+ // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
87
+ description= providers.fileContents(layout.projectDirectory.file(" README.md" )).asText.map {
88
+ val start= " <!-- Plugin description -->"
89
+ val end= " <!-- Plugin description end -->"
90
+
91
+ with (it.lines()) {
92
+ if (! containsAll(listOf (start, end))) {
93
+ throw GradleException (" Plugin description section not found in README.md:\n $start ...$end " )
94
+ }
95
+ subList(indexOf(start)+ 1 , indexOf(end)).joinToString(" \n " ).let (::markdownToHTML)
96
+ }
97
+ }
98
+
99
+ val changelog= project.changelog// local variable for configuration cache compatibility
100
+ // Get the latest available change notes from the changelog file
101
+ changeNotes= providers.gradleProperty(" pluginVersion" ).map { pluginVersion->
102
+ with (changelog) {
103
+ renderItem(
104
+ (getOrNull(pluginVersion)? : getUnreleased())
105
+ .withHeader(false )
106
+ .withEmptySections(false ),
107
+ Changelog .OutputType .HTML ,
108
+ )
109
+ }
110
+ }
111
+
112
+ ideaVersion {
113
+ sinceBuild= providers.gradleProperty(" pluginSinceBuild" )
114
+ untilBuild= provider {null }
115
+ }
116
+ }
117
+
118
+ pluginVerification {
119
+ ides {
120
+ providers.gradleProperty(" verifyVersions" ).get().split(' ,' ).map(String ::trim).forEach { version->
121
+ ide(IntelliJPlatformType .Gateway , version)
122
+ }
123
+ }
124
+ }
125
+
126
+ publishing {
127
+ token= providers.environmentVariable(" PUBLISH_TOKEN" )
128
+ // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
129
+ // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
130
+ // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
131
+ channels= providers.gradleProperty(" pluginVersion" )
132
+ .map {listOf (it.substringAfter(' -' ," " ).substringBefore(' .' ).ifEmpty {" default" }) }
133
+ }
57
134
}
58
135
59
136
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
@@ -62,6 +139,17 @@ changelog {
62
139
groups.set(emptyList())
63
140
}
64
141
142
+ // Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
143
+ kover {
144
+ reports {
145
+ total {
146
+ xml {
147
+ onCheck= true
148
+ }
149
+ }
150
+ }
151
+ }
152
+
65
153
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
66
154
qodana {
67
155
cachePath.set(projectDir.resolve(" .qodana" ).canonicalPath)
@@ -72,88 +160,43 @@ qodana {
72
160
73
161
tasks {
74
162
buildPlugin {
163
+ archiveBaseName= providers.gradleProperty(" artifactName" ).get()
75
164
exclude {" coroutines" in it.name }
76
165
}
77
166
prepareSandbox {
78
167
exclude {" coroutines" in it.name }
79
168
}
80
169
81
- // Set the JVM compatibility versions
82
- properties(" javaVersion" ).let {
83
- withType<JavaCompile > {
84
- sourceCompatibility= it
85
- targetCompatibility= it
86
- }
87
- withType<KotlinCompile > {
88
- kotlinOptions.jvmTarget= it
89
- }
90
- }
91
-
92
170
wrapper {
93
- gradleVersion= properties(" gradleVersion" )
94
- }
95
-
96
- instrumentCode {
97
- compilerVersion.set(properties(" instrumentationCompiler" ))
98
- }
99
-
100
- // TODO - this fails with linkage error, but we don't need it now
101
- // because the plugin does not provide anything to search for in Preferences
102
- buildSearchableOptions {
103
- isEnabled= false
104
- }
105
-
106
- patchPluginXml {
107
- version.set(properties(" pluginVersion" ))
108
- sinceBuild.set(properties(" pluginSinceBuild" ))
109
- untilBuild.set(properties(" pluginUntilBuild" ))
110
-
111
- // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
112
- pluginDescription.set(
113
- projectDir.resolve(" README.md" ).readText().lines().run {
114
- val start= " <!-- Plugin description -->"
115
- val end= " <!-- Plugin description end -->"
116
-
117
- if (! containsAll(listOf (start, end))) {
118
- throw GradleException (" Plugin description section not found in README.md:\n $start ...$end " )
119
- }
120
- subList(indexOf(start)+ 1 , indexOf(end))
121
- }.joinToString(" \n " ).run { markdownToHTML(this ) },
122
- )
123
-
124
- // Get the latest available change notes from the changelog file
125
- changeNotes.set(
126
- provider {
127
- changelog.run {
128
- getOrNull(properties(" pluginVersion" ))? : getLatest()
129
- }.toHTML()
130
- },
131
- )
132
- }
133
-
134
- runIde {
135
- autoReloadPlugins.set(true )
136
- }
137
-
138
- // Configure UI tests plugin
139
- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
140
- runIdeForUiTests {
141
- systemProperty(" robot-server.port" ," 8082" )
142
- systemProperty(" ide.mac.message.dialogs.as.sheets" ," false" )
143
- systemProperty(" jb.privacy.policy.text" ," <!--999.999-->" )
144
- systemProperty(" jb.consents.confirmation.enabled" ," false" )
171
+ gradleVersion= providers.gradleProperty(" gradleVersion" ).get()
145
172
}
146
173
147
174
publishPlugin {
148
- dependsOn(" patchChangelog" )
149
- token.set(System .getenv(" PUBLISH_TOKEN" ))
175
+ dependsOn(patchChangelog)
150
176
}
151
177
152
178
test {
153
179
useJUnitPlatform()
154
180
}
181
+ }
182
+
183
+ intellijPlatformTesting {
184
+ runIde {
185
+ register(" runIdeForUiTests" ) {
186
+ task {
187
+ jvmArgumentProviders+ = CommandLineArgumentProvider {
188
+ listOf (
189
+ " -Drobot-server.port=8082" ,
190
+ " -Dide.mac.message.dialogs.as.sheets=false" ,
191
+ " -Djb.privacy.policy.text=<!--999.999-->" ,
192
+ " -Djb.consents.confirmation.enabled=false" ,
193
+ )
194
+ }
195
+ }
155
196
156
- runPluginVerifier {
157
- ideVersions.set(properties(" verifyVersions" ).split(" ," ))
197
+ plugins {
198
+ robotServerPlugin()
199
+ }
200
+ }
158
201
}
159
- }
202
+ }