-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle.kts
422 lines (383 loc) · 12.8 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBA Group
* Zowe Community
*/
import org.jetbrains.changelog.Changelog
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.LocalDate
import java.time.ZoneId
import java.time.format.DateTimeFormatter
//!IMPORTANT!: to refer "libs", use ./gradle/libs.versions.toml
fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
fun dateValue(pattern: String): String =
LocalDate.now(ZoneId.of("Europe/Warsaw")).format(DateTimeFormatter.ofPattern(pattern))
// https://github.com/kotest/kotest-intellij-plugin/blob/master/build.gradle.kts
data class PluginDescriptor(
val jvmTargetVersion: JavaVersion, // the Java version to use during the plugin build
val since: String, // earliest version string this is compatible with
val getUntil: () -> Provider<String>, // latest version string this is compatible with, can be wildcard like 202.*
// https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
val sdkVersion: String, // the version string passed to the intellij sdk gradle plugin
val sourceFolder: String // used as the source root for specifics of this build
)
val plugins = listOf(
PluginDescriptor(
jvmTargetVersion = JavaVersion.VERSION_17,
since = properties("pluginSinceBuild").get(),
getUntil = { provider { "232.*" } },
sdkVersion = "2023.1.7",
sourceFolder = "IC-231"
),
PluginDescriptor(
jvmTargetVersion = JavaVersion.VERSION_17,
since = "233.11799",
getUntil = { provider { "241.*" } },
sdkVersion = "2023.3",
sourceFolder = "IC-233"
),
PluginDescriptor(
jvmTargetVersion = JavaVersion.VERSION_21,
since = "242.20224",
getUntil = { provider { "242.*" } },
sdkVersion = "2024.2",
sourceFolder = "IC-242"
),
PluginDescriptor(
jvmTargetVersion = JavaVersion.VERSION_21,
since = "243.12818",
getUntil = { provider { null } },
sdkVersion = "2024.3",
sourceFolder = "IC-243"
)
)
val productName = System.getenv("PRODUCT_NAME") ?: "IC-231"
val descriptor = plugins.first { it.sourceFolder == productName }
group = properties("pluginGroup").get()
version = properties("pluginVersion").get()
plugins {
alias(libs.plugins.gradle) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.sonarqube)
alias(libs.plugins.changelog)
alias(libs.plugins.kover)
alias(libs.plugins.dependencycheck)
java
}
repositories {
mavenCentral()
flatDir {
dirs("libs")
}
maven {
url = uri("https://zowe.jfrog.io/zowe/libs-release")
flatDir {
dir("libs")
}
}
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}
java {
sourceCompatibility = descriptor.jvmTargetVersion
targetCompatibility = descriptor.jvmTargetVersion
}
kotlin {
compilerOptions {
jvmToolchain(JavaLanguageVersion.of(descriptor.jvmTargetVersion.toString()).asInt())
}
}
/** Source sets configuration */
sourceSets {
main {
java {
srcDir("src/${descriptor.sourceFolder}/kotlin")
}
resources {
srcDir("src/${descriptor.sourceFolder}/resources")
}
}
create("uiTest") {
compileClasspath += sourceSets.main.get().compileClasspath + sourceSets.test.get().compileClasspath
runtimeClasspath += output + compileClasspath
}
}
configurations["uiTestRuntimeOnly"].extendsFrom(configurations.testRuntimeOnly.get())
configurations["uiTestImplementation"].extendsFrom(configurations.testImplementation.get())
dependencies {
intellijPlatform {
// intellijIdeaCommunity(descriptor.sdkVersion)
// TO TEST EAP:
intellijIdeaCommunity(descriptor.sdkVersion, useInstaller = false)
jetbrainsRuntime()
instrumentationTools()
pluginVerifier()
testFramework(TestFrameworkType.Plugin.Java)
zipSigner()
testFramework(TestFrameworkType.Starter, configurationName = "uiTestImplementation")
zipSigner()
}
implementation(libs.retrofit2)
implementation(libs.retrofit2.converter.gson)
implementation(libs.retrofit2.converter.scalars)
implementation(libs.okhttp3)
implementation(libs.jgrapht.core)
implementation(libs.java.keytar)
implementation(libs.zowe.kotlin.sdk)
testImplementation(libs.mockk)
testImplementation(libs.kotest.assertions.core)
testImplementation(libs.kotest.runner.junit5)
}
intellijPlatform {
pluginConfiguration {
version = "${properties("pluginVersion").get()}-${descriptor.since.substringBefore(".")}"
ideaVersion {
sinceBuild = descriptor.since
untilBuild = descriptor.getUntil()
}
}
pluginVerification {
ides {
recommended()
}
}
}
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set(properties("pluginVersion").get())
header.set(provider { "${version.get()} (${dateValue("yyyy-MM-dd")})" }.get())
groups.set(listOf("Breaking changes", "Features", "Bugfixes", "Deprecations", "Security"))
keepUnreleasedSection.set(false)
itemPrefix.set("*")
repositoryUrl.set(properties("pluginRepositoryUrl").get())
sectionUrlBuilder.set { repositoryUrl, currentVersion, previousVersion, isUnreleased: Boolean ->
repositoryUrl + when {
isUnreleased -> when (previousVersion) {
null -> "/commits"
else -> "/compare/$previousVersion...HEAD"
}
previousVersion == null -> "/commits/$currentVersion"
else -> "/compare/$previousVersion...$currentVersion"
}
}
}
kover {
currentProject {
instrumentation {
/* exclude Gradle test tasks */
disabledForTestTasks.addAll("uiTest", "firstTimeUiTest", "smokeUiTest")
}
}
reports {
filters {
includes {
classes(providers.provider { "org.zowe.explorer.*" })
}
excludes {
classes(providers.provider { "org.zowe.explorer.vfs.MFVFileCreateEvent" })
classes(providers.provider { "org.zowe.explorer.vfs.MFVFilePropertyChangeEvent" })
}
}
}
}
dependencyCheck {
suppressionFiles = listOf("$projectDir/owasp-dependency-check-suppression.xml")
}
tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
}
withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
patchPluginXml {
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes.set(
properties("pluginVersion")
.map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}
.get()
)
}
withType<KotlinCompile>().configureEach {
if (name == "compileUiTestKotlin") {
onlyIf {
gradle.startParameter.taskNames.any { it.contains("uiTests") }
}
}
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
// ignoreFailures = true
finalizedBy("koverHtmlReport")
finalizedBy("koverXmlReport")
systemProperty("idea.force.use.core.classloader", "true")
systemProperty("idea.use.core.classloader.for.plugin.path", "true")
systemProperty("java.awt.headless", "true")
afterSuite(
KotlinClosure2<TestDescriptor, TestResult, Unit>({ desc, result ->
if (desc.parent == null) { // will match the outermost suite
val output =
"Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, " +
"${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
val fileName = "./build/reports/tests/${result.resultType}.txt"
File(fileName).writeText(output)
}
})
)
}
koverHtmlReport {
finalizedBy("koverXmlReport")
}
val createOpenApiSourceJar by registering(Jar::class) {
// Java sources
from(sourceSets.main.get().java) {
include("**/org/zowe/explorer/**/*.java")
}
// Kotlin sources
from(kotlin.sourceSets.main.get().kotlin) {
include("**/org/zowe/explorer/**/*.kt")
}
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("src")
}
buildPlugin {
dependsOn(createOpenApiSourceJar)
archiveClassifier.set(descriptor.sdkVersion)
from(createOpenApiSourceJar) { into("lib/src") }
}
signPlugin {
certificateChain.set(environment("INTELLIJ_SIGNING_CERTIFICATE_CHAIN").map { it })
privateKey.set(environment("INTELLIJ_SIGNING_PRIVATE_KEY").map { it })
password.set(environment("INTELLIJ_SIGNING_PRIVATE_KEY_PASSWORD").map { it })
}
publishPlugin {
token.set(environment("ZOWE_INTELLIJ_MARKET_TOKEN").map { it })
// The pluginVersion is based on the SemVer (https://semver.org)
// Read more: https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(
properties("pluginVersion")
.map {
listOf(
it.substringAfter('-', "")
.ifEmpty { "stable" }
)
}
.map { it }
)
}
}
/**
* UI tests task. Describes setup that provides the tools to run UI tests.
* This task is available only for IDEs since version 242
*/
// https://github.com/JetBrains/intellij-community/blob/master/platform/remote-driver/README.md
val uiTests by intellijPlatformTesting.testIdeUi.registering {
task {
enabled = gradle.startParameter.taskNames.any { it.contains("uiTests") } && descriptor.since >= "242"
archiveFile.set(tasks.buildPlugin.flatMap { it.archiveFile })
testClassesDirs = sourceSets["uiTest"].output.classesDirs
classpath = sourceSets["uiTest"].runtimeClasspath
useJUnitPlatform {
isScanForTestClasses = false
includeTags("New")
}
jvmArgumentProviders += CommandLineArgumentProvider {
listOf(
"-Xmx2g",
"-Xms512m",
"-Dide.test.version=${descriptor.sdkVersion}",
"-Dplugin.path=${tasks.buildPlugin.flatMap { it.archiveFile }.get().asFile.absolutePath}",
"-Dui.tests.mock.project.path=src/uiTest/resources/mock_project",
"-Didea.trust.all.projects=true",
"-Dide.show.tips.on.startup.default.value=false",
"-Didea.log.config.properties.file=src/uiTest/resources/log.properties",
"-Didea.log.path=src/uiTest/resources/mock_project",
// TODO: delete
"-DideLaunchFolder=ide_for_launch",
"-DremoteRobotUrl=http://127.0.0.1",
"-DideaBuildVersionForTest=ideaIC-242.20224.91",
"-DrobotServerForTest=robot-server-plugin-0.11.23",
"-Didea.trust.all.projects=true",
"-Dide.show.tips.on.startup.default.value=false",
"-Dkotest.framework.classpath.scanning.autoscan.disable=true",
)
}
testLogging {
events("passed", "skipped", "failed", "standardOut", "standardError")
}
}
plugins {
robotServerPlugin()
}
dependencies {
// testImplementation(libs.junit.platform.launcher)
// testImplementation(libs.junit.platform.suite)
// testImplementation(libs.junit.jupiter)
// testImplementation(libs.junit.jupiter.engine)
testImplementation(libs.junit.jupiter.api)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.okhttp3.mockwebserver)
testImplementation(libs.okhttp3.okhttp.tls)
// TODO: revise and delete old unnecessary deps
testImplementation("com.intellij.remoterobot:ide-launcher:0.11.23")
testImplementation("com.intellij.remoterobot:remote-robot:0.11.23")
testImplementation("com.intellij.remoterobot:remote-fixtures:0.11.23")
}
}
// TODO: fix
///**
// * Runs the first UI test, which agrees to the license agreement
// */
//val firstTimeUiTest = task<Test>("firstTimeUiTest") {
// description = "Gets rid of license agreement, etc."
// group = "verification"
// testClassesDirs = sourceSets["uiTest"].output.classesDirs
// classpath = sourceSets["uiTest"].runtimeClasspath
// useJUnitPlatform {
// includeTags("FirstTime")
// }
// testLogging {
// events("passed", "skipped", "failed")
// }
//}
//
///**
// * Runs the smoke ui test
// */
//val smokeUiTest = task<Test>("smokeUiTest") {
// description = "Gets rid of license agreement, etc."
// group = "verification"
// testClassesDirs = sourceSets["uiTest"].output.classesDirs
// classpath = sourceSets["uiTest"].runtimeClasspath
// useJUnitPlatform {
// includeTags("SmokeTest")
// }
// testLogging {
// events("passed", "skipped", "failed")
// }
//}