1
1
import org.jetbrains.changelog.Changelog
2
2
import org.jetbrains.changelog.markdownToHTML
3
+ import org.jetbrains.intellij.platform.gradle.tasks.RunIdeTask
4
+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3
5
4
6
fun isWindows (): Boolean {
5
7
return System .getProperty(" os.name" ).lowercase().startsWith(" windows" )
6
8
}
7
9
8
10
val nxlsRoot = " ${rootDir} /dist/apps/nxls"
9
11
10
- buildDir = file(" ${rootDir} /dist/apps/intellij" )
11
-
12
- fun properties (key : String ) = project.findProperty(key).toString()
12
+ layout.buildDirectory = file(" ${rootDir} /dist/apps/intellij" )
13
13
14
14
plugins {
15
15
// Java support
16
16
id(" java" )
17
17
// Kotlin support
18
- id(" org.jetbrains.kotlin.jvm" ) version " 1.9.22 "
18
+ id(" org.jetbrains.kotlin.jvm" ) version " 2.0.20 "
19
19
// Kotlin serialization
20
- id(" org.jetbrains.kotlin.plugin.serialization" ) version " 1.9.22 "
21
- // Gradle IntelliJ Plugin
22
- id(" org.jetbrains.intellij" ) version " 1.17.2 "
20
+ id(" org.jetbrains.kotlin.plugin.serialization" ) version " 2.0.20 "
21
+ // Gradle IntelliJ Platform Plugin
22
+ id(" org.jetbrains.intellij.platform " ) version " 2.0.1 "
23
23
24
24
// Gradle Changelog Plugin
25
25
id(" org.jetbrains.changelog" ) version " 2.0.0"
@@ -31,10 +31,16 @@ plugins {
31
31
id(" com.ncorti.ktfmt.gradle" ) version " 0.11.0"
32
32
}
33
33
34
- group = properties(" pluginGroup" )
34
+ group = providers.gradleProperty(" pluginGroup" ).get()
35
+
36
+ version = providers.gradleProperty(" version" ).get()
35
37
36
38
// Configure project's dependencies
37
- repositories { mavenCentral() }
39
+ repositories {
40
+ mavenCentral()
41
+
42
+ intellijPlatform { defaultRepositories() }
43
+ }
38
44
39
45
configurations.all {
40
46
exclude(" org.slf4j" , " slf4j-api" )
@@ -46,42 +52,131 @@ configurations.all {
46
52
}
47
53
48
54
dependencies {
49
- implementation(" org.eclipse.lsp4j:org.eclipse.lsp4j:0.21.0 " )
55
+ implementation(" org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.1 " )
50
56
51
- val ktorVersion = " 2.3.8 "
57
+ val ktorVersion = " 2.3.12 "
52
58
implementation(" io.ktor:ktor-client-core:$ktorVersion " )
53
59
implementation(" io.ktor:ktor-client-cio:$ktorVersion " )
54
60
implementation(" io.ktor:ktor-client-content-negotiation:$ktorVersion " )
55
61
implementation(" io.ktor:ktor-serialization-kotlinx-json:$ktorVersion " )
56
62
implementation(" io.ktor:ktor-client-logging:$ktorVersion " )
57
63
58
- implementation(" io.github.z4kn4fein:semver:1.4.2" )
64
+ implementation(" org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.2" )
65
+
66
+ implementation(" io.github.z4kn4fein:semver:2.0.0" )
67
+
68
+ implementation(" io.github.nsk90:kstatemachine:0.31.0" )
69
+ implementation(" io.github.nsk90:kstatemachine-coroutines:0.31.0" )
70
+
71
+ intellijPlatform {
72
+ intellijIdeaUltimate(providers.gradleProperty(" platformVersion" ))
73
+
74
+ bundledPlugins(
75
+ providers.gradleProperty(" platformPlugins" ).map { plugins ->
76
+ plugins.split(' ,' ).map(String ::trim).filter(String ::isNotEmpty)
77
+ }
78
+ )
79
+ pluginVerifier()
80
+ zipSigner()
81
+ instrumentationTools()
82
+ }
59
83
}
60
84
61
85
ktfmt { kotlinLangStyle() }
62
86
63
- // Set the JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for
64
- // 2022.2+.
65
87
kotlin { jvmToolchain(17 ) }
66
88
67
- // Configure Gradle IntelliJ Plugin - read more:
68
- // https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
69
- intellij {
70
- pluginName.set(properties(" pluginName" ))
71
- version.set(properties(" platformVersion" ))
72
- type.set(properties(" platformType" ))
73
-
74
- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
75
- plugins.set(
76
- properties(" platformPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty)
77
- )
89
+ intellijPlatform {
90
+ projectName = providers.gradleProperty(" pluginName" ).get()
91
+
92
+ pluginConfiguration {
93
+ version = providers.gradleProperty(" version" ).get()
94
+ ideaVersion {
95
+ sinceBuild = providers.gradleProperty(" pluginSinceBuild" ).get()
96
+ untilBuild = providers.gradleProperty(" pluginUntilBuild" ).get()
97
+ }
98
+ description =
99
+ providers.fileContents(layout.projectDirectory.file(" README.md" )).asText.map {
100
+ val start = " <!-- Plugin description -->"
101
+ val end = " <!-- Plugin description end -->"
102
+
103
+ with (it.lines()) {
104
+ if (! containsAll(listOf (start, end))) {
105
+ throw GradleException (
106
+ " Plugin description section not found in README.md:\n $start ... $end "
107
+ )
108
+ }
109
+ subList(indexOf(start) + 1 , indexOf(end))
110
+ .joinToString(" \n " )
111
+ .let (::markdownToHTML)
112
+ }
113
+ }
114
+
115
+ val changelog = project.changelog // local variable for configuration cache compatibility
116
+ // Get the latest available change notes from the changelog file
117
+ changeNotes =
118
+ providers.gradleProperty(" version" ).map { pluginVersion ->
119
+ with (changelog) {
120
+ renderItem(
121
+ (getOrNull(pluginVersion) ? : getUnreleased())
122
+ .withHeader(false )
123
+ .withEmptySections(false ),
124
+ Changelog .OutputType .HTML ,
125
+ )
126
+ }
127
+ }
128
+ }
129
+ signing {
130
+ certificateChain.set(System .getenv(" CERTIFICATE_CHAIN" ))
131
+ privateKey.set(System .getenv(" PRIVATE_KEY" ))
132
+ password.set(System .getenv(" PRIVATE_KEY_PASSWORD" ))
133
+ }
134
+ publishing {
135
+ token.set(System .getenv(" PUBLISH_TOKEN" ))
136
+ // version is based on the SemVer (https://semver.org) and supports pre-release
137
+ // labels, like 2.1.7-alpha.3
138
+ // Specify pre-release label to publish the plugin in a custom Release Channel
139
+ // automatically. Read more:
140
+ // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
141
+ // val channel: String =
142
+ // properties("pluginVersion").split('-').getOrElse(1) { "default"
143
+ // }.split('.').first()
144
+ // channels.set(listOf(channel))
145
+ }
146
+ pluginVerification { ides { recommended() } }
147
+ }
148
+
149
+ intellijPlatformTesting {
150
+ runIde {
151
+ create(" runIntelliJLatest" ) {
152
+ version = " 243.12818.47"
153
+ prepareSandboxTask {
154
+ from(nxlsRoot) {
155
+ include(" **/*.js" )
156
+ include(" **/package.json" )
157
+ include(" **/*.map" )
158
+ into(intellijPlatform.projectName.map { " $it /nxls" }.get())
159
+ }
160
+ doLast {
161
+ exec {
162
+ workingDir =
163
+ File (
164
+ destinationDir,
165
+ intellijPlatform.projectName.map { " $it /nxls" }.get(),
166
+ )
167
+ commandLine = buildCommands() + " npm install --force"
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
78
173
}
79
174
80
175
// Configure Gradle Changelog Plugin - read more:
81
176
// https://github.com/JetBrains/gradle-changelog-plugin
82
177
changelog {
83
178
groups.set(emptyList())
84
- repositoryUrl.set(properties (" pluginRepositoryUrl" ))
179
+ repositoryUrl.set(providers.gradleProperty (" pluginRepositoryUrl" ).get( ))
85
180
}
86
181
87
182
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
@@ -96,7 +191,7 @@ qodana {
96
191
kover.xmlReport { onCheck.set(true ) }
97
192
98
193
tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > {
99
- kotlinOptions { jvmTarget = " 17 " }
194
+ compilerOptions { jvmTarget.set( JvmTarget . JVM_17 ) }
100
195
}
101
196
102
197
tasks {
@@ -107,110 +202,31 @@ tasks {
107
202
include(" **/*.js" )
108
203
include(" **/package.json" )
109
204
include(" **/*.map" )
110
- into(" ${rootProject.name} /nxls" )
205
+ into(intellijPlatform.projectName.map { " $it /nxls" }.get() )
111
206
}
112
-
113
207
doLast {
114
208
exec {
115
- logger.warn(" rootproject ${rootProject.name} " )
116
- logger.warn(" Working dir: $workingDir " )
117
- logger.warn(" Working dir: $destinationDir " )
118
-
119
209
workingDir =
120
- File (
121
- destinationDir,
122
- rootProject.name + " /nxls" ,
123
- )
210
+ File (destinationDir, intellijPlatform.projectName.map { " $it /nxls" }.get())
124
211
commandLine = buildCommands() + " npm install --force"
125
212
}
126
213
}
127
214
}
128
215
129
- patchPluginXml {
130
- version.set(properties(" version" ))
131
- sinceBuild.set(properties(" pluginSinceBuild" ))
132
- untilBuild.set(properties(" pluginUntilBuild" ))
133
-
134
- // Extract the <!-- Plugin description --> section from README.md and provide for the
135
- // plugin's manifest
136
- pluginDescription.set(
137
- file(" README.md" )
138
- .readText()
139
- .lines()
140
- .run {
141
- val start = " <!-- Plugin description -->"
142
- val end = " <!-- Plugin description end -->"
143
-
144
- if (! containsAll(listOf (start, end))) {
145
- throw GradleException (
146
- " Plugin description section not found in README.md:\n $start ... $end "
147
- )
148
- }
149
- subList(indexOf(start) + 1 , indexOf(end))
150
- }
151
- .joinToString(" \n " )
152
- .let { markdownToHTML(it) }
153
- )
154
-
155
- // Get the latest available change notes from the changelog file
156
- changeNotes.set(
157
- provider {
158
- with (changelog) {
159
- renderItem(
160
- getOrNull(properties(" version" )) ? : getLatest(),
161
- Changelog .OutputType .HTML ,
162
- )
163
- }
164
- }
165
- )
166
- }
167
-
168
- // Configure UI tests plugin
169
- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
170
- runIdeForUiTests {
171
- systemProperty(" robot-server.port" , " 8082" )
172
- systemProperty(" ide.mac.message.dialogs.as.sheets" , " false" )
173
- systemProperty(" jb.privacy.policy.text" , " <!--999.999-->" )
174
- systemProperty(" jb.consents.confirmation.enabled" , " false" )
175
- }
176
-
177
- runIde { maxHeapSize = " 6g" }
178
-
179
- signPlugin {
180
- certificateChain.set(System .getenv(" CERTIFICATE_CHAIN" ))
181
- privateKey.set(System .getenv(" PRIVATE_KEY" ))
182
- password.set(System .getenv(" PRIVATE_KEY_PASSWORD" ))
183
- }
184
-
185
- publishPlugin {
186
- dependsOn(" patchChangelog" )
187
- token.set(System .getenv(" PUBLISH_TOKEN" ))
188
- // version is based on the SemVer (https://semver.org) and supports pre-release
189
- // labels, like 2.1.7-alpha.3
190
- // Specify pre-release label to publish the plugin in a custom Release Channel
191
- // automatically. Read more:
192
- // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
193
- // val channel: String =
194
- // properties("pluginVersion").split('-').getOrElse(1) { "default"
195
- // }.split('.').first()
196
- // channels.set(listOf(channel))
197
- }
198
-
199
216
jar {
200
217
dependsOn(" copyGenerateUiV2Artifacts" )
201
-
202
218
archiveBaseName.set(" nx-console" )
203
219
}
204
220
205
- instrumentedJar {
206
- dependsOn( " copyGenerateUiV2Artifacts " )
207
- }
221
+ instrumentedJar { dependsOn( " copyGenerateUiV2Artifacts " ) }
222
+
223
+ withType< RunIdeTask > { maxHeapSize = " 6g " }
208
224
}
209
225
210
226
tasks.register<Copy >(" copyGenerateUiV2Artifacts" ) {
211
227
from(" ${rootDir} /dist/apps/generate-ui-v2" )
212
228
include(" *.js" , " *.css" )
213
- into(" ${buildDir} / resources/main/generate_ui_v2" )
229
+ into(layout.buildDirectory.file( " resources/main/generate_ui_v2" ) )
214
230
}
215
231
216
232
tasks.register<DefaultTask >(" publish" ) {
0 commit comments