-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
324 lines (290 loc) · 9.92 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
/*
* 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
*
* Copyright IBA Group 2020
*/
import kotlinx.kover.api.KoverTaskExtension
import org.jetbrains.changelog.Changelog
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.LocalDate
import java.time.ZoneId
import java.time.format.DateTimeFormatter
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))
plugins {
id("org.sonarqube") version "5.0.0.4638"
id("org.jetbrains.intellij") version "1.17.2"
id("org.jetbrains.changelog") version "2.2.0"
kotlin("jvm") version "1.9.22"
java
id("org.jetbrains.kotlinx.kover") version "0.6.1"
id("org.owasp.dependencycheck") version "9.1.0"
}
val sonarLinksCi: String by project
apply(plugin = "kotlin")
apply(plugin = "org.jetbrains.intellij")
apply(from = "gradle/sonar.gradle")
group = properties("pluginGroup").get()
version = properties("pluginVersion").get()
val remoteRobotVersion = "0.11.22"
val okHttp3Version = "4.12.0"
val kotestVersion = "5.8.1"
repositories {
mavenCentral()
flatDir {
dirs("libs")
}
maven {
url = uri("https://zowe.jfrog.io/zowe/libs-release")
}
maven {
url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
flatDir {
dir("libs")
}
metadataSources {
mavenPom()
artifact()
ignoreGradleMetadataRedirection()
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
dependencies {
implementation(group = "com.squareup.retrofit2", name = "retrofit", version = "2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("com.squareup.retrofit2:converter-scalars:2.9.0")
implementation("com.squareup.okhttp3:okhttp:$okHttp3Version")
implementation("org.jgrapht:jgrapht-core:1.5.2")
implementation("org.zowe.sdk:zowe-kotlin-sdk:0.4.0")
implementation("com.segment.analytics.java:analytics:3.5.0")
implementation("com.ibm.mq:com.ibm.mq.allclient:9.3.4.1")
testImplementation("io.mockk:mockk:1.13.9")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
testImplementation("com.squareup.okhttp3:mockwebserver:$okHttp3Version")
testImplementation("com.squareup.okhttp3:okhttp-tls:$okHttp3Version")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.1")
}
intellij {
version.set(properties("platformVersion").get())
}
// 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"
}
}
}
tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
languageVersion = org.jetbrains.kotlin.config.LanguageVersion.LATEST_STABLE.versionString
}
}
withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
patchPluginXml {
version.set(properties("pluginVersion").get())
sinceBuild.set(properties("pluginSinceBuild").get())
untilBuild.set(properties("pluginUntilBuild").get())
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()
)
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
// ignoreFailures = true
finalizedBy("koverHtmlReport")
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("**/eu/ibagroup/formainframe/**/*.java")
}
// Kotlin sources
from(kotlin.sourceSets.main.get().kotlin) {
include("**/eu/ibagroup/formainframe/**/*.kt")
}
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveClassifier.set("src")
}
buildPlugin {
dependsOn(createOpenApiSourceJar)
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 {
dependsOn("patchChangelog")
token.set(environment("INTELLIJ_SIGNING_PUBLISH_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('-', "")
.substringAfter('-', "")
.substringBefore('.')
.ifEmpty { "stable" }
)
}
.map { it })
}
downloadRobotServerPlugin {
version.set(remoteRobotVersion)
}
runIdeForUiTests {
systemProperty("idea.trust.all.projects", "true")
systemProperty("ide.show.tips.on.startup.default.value", "false")
}
}
/**
* Adds uiTest source sets
*/
sourceSets {
create("uiTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
java.srcDirs("src/uiTest/java", "src/uiTest/kotlin")
resources.srcDirs("src/uiTest/resources")
}
}
/**
* configures the UI Tests to inherit the testImplementation in dependencies
*/
val uiTestImplementation by configurations.getting {
extendsFrom(configurations.testImplementation.get())
}
/**
* configures the UI Tests to inherit the testRuntimeOnly in dependencies
*/
configurations["uiTestRuntimeOnly"].extendsFrom(configurations.testRuntimeOnly.get())
/**
* runs UI tests
*/
val uiTest = task<Test>("uiTest") {
description = "Runs the integration tests for UI."
group = "verification"
testClassesDirs = sourceSets["uiTest"].output.classesDirs
classpath = sourceSets["uiTest"].runtimeClasspath
useJUnitPlatform() {
excludeTags("FirstTime")
excludeTags("SmokeTest")
}
testLogging {
events("passed", "skipped", "failed")
}
extensions.configure(KoverTaskExtension::class) {
// set to true to disable instrumentation of this task,
// Kover reports will not depend on the results of its execution
isDisabled.set(true)
}
}
/**
* 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")
}
extensions.configure(KoverTaskExtension::class) {
// set to true to disable instrumentation of this task,
// Kover reports will not depend on the results of its execution
isDisabled.set(true)
}
}
/**
* 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")
}
extensions.configure(KoverTaskExtension::class) {
// set to true to disable instrumentation of this task,
// Kover reports will not depend on the results of its execution
isDisabled.set(true)
}
}