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