-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathbuild.gradle
More file actions
348 lines (312 loc) · 11.7 KB
/
build.gradle
File metadata and controls
348 lines (312 loc) · 11.7 KB
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
//import org.jetbrains.changelog.ExtensionsKt
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.exceptions.MissingVersionException
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask
//import org.jetbrains.changelog.markdownToHTML
plugins {
id 'java'
id 'org.jetbrains.intellij.platform' version '2.10.5'
id("org.jetbrains.kotlin.jvm") version "2.2.21"
id 'org.jetbrains.changelog' version '2.5.0'
id 'org.jetbrains.qodana' version '2025.2.2'
id 'org.jetbrains.kotlinx.kover' version '0.9.3'
id "io.freefair.lombok" version "9.1.0"
id 'idea'
id "org.sonarqube" version '7.2.0.6526'
id 'jacoco'
}
def readPropertyString = (key) -> property(key).toString()
def readPropertyStringUnsetEmpty = (key) -> {
def value = readPropertyString(key)
return value == "" ? null : value
}
def verifyFailureLevel = EnumSet.copyOf(VerifyPluginTask.FailureLevel.ALL)
verifyFailureLevel.remove(VerifyPluginTask.FailureLevel.NOT_DYNAMIC)
def channel = getChannel(readPropertyString('pluginVersion'))
group readPropertyString('pluginGroup')
version "${readPropertyString('pluginVersion')}-${readPropertyString('pluginSincePlatformVersion')}"
apply plugin: 'org.jetbrains.intellij.platform'
apply plugin: 'org.jetbrains.changelog'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: "io.freefair.lombok"
intellijPlatform {
pluginConfiguration {
name.set(readPropertyString('pluginName'))
version.set(project.version)
description.set(file('includes/pluginDescription.html').text)
//changeNotes.set(provider { changelog.getLatest().toHTML() })
def allChanges = { changelog.getAll().values()
.collect { it.withHeader(true) }
.collect { it.withLinks(false) }
.collect { it.withLinkedHeader(false) }
.collect { it.withSummary(true) }
.collect { changelog.renderItem(it as Changelog.Item, Changelog.OutputType.HTML)}
.join('<br>\n')
}
def getChangelogForCurrentBuild = {
def currentChangelog = changelog.getOrNull(readPropertyString("pluginVersion"))
if (!currentChangelog) {
try {
currentChangelog = changelog.getUnreleased()
} catch (MissingVersionException missingVersionException) {
currentChangelog = changelog.getLatest()
}
}
return currentChangelog
}
def lastChanges = {
def item = getChangelogForCurrentBuild()
.withHeader(true)
.withLinks(false)
.withLinkedHeader(false)
.withSummary(true)
changelog.renderItem(item, Changelog.OutputType.HTML)
}
//changeNotes.set(provider { allChanges() } )
changeNotes.set(provider { lastChanges() } )
ideaVersion {
sinceBuild.set(readPropertyString("pluginSinceBuild"))
untilBuild.set(readPropertyStringUnsetEmpty("pluginUntilBuild"))
//untilBuild = provider { null }
}
}
publishing {
token.set(System.getenv("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set([channel])
}
signing {
def _privateKey = file('private/mcmics.pem')
def _certificateChain = file('private/mcmics-sign.crt')
privateKey.set(_privateKey.exists() ? _privateKey.text : System.getenv("PRIVATE_KEY"))
certificateChain.set(_certificateChain.exists() ? _certificateChain.text : System.getenv("CERTIFICATE_CHAIN"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
pluginVerification {
// filled by task printProductsReleases
// ideVersions = ["IU-${ideaVersionToVerify}"]
// ideVersions = ["IC-2020.3", "PS-2020.3", "IU-2020.3"]
failureLevel = verifyFailureLevel
freeArgs = ['-mute', 'TemplateWordInPluginName']
ides {
recommended()
ide IntelliJPlatformType.IntellijIdeaCommunity, "${platformVersionToVerify}"
// select {
// it.types = [IntelliJPlatformType.CLion]
// it.channels = [ProductRelease.Channel.RELEASE]
// it.sinceBuild = "${pluginSinceBuild}"
// it.untilBuild = "${pluginUntilBuild}"
// }
}
}
}
changelog {
version = readPropertyString('pluginVersion')
path = "${project.projectDir}/CHANGELOG.md"
header = provider { "[${version.get()}]" }
//headerParserRegex = ~/\d+\.\d+/
itemPrefix = "-"
keepUnreleasedSection = true
combinePreReleases = true
lineSeparator = "\n"
repositoryUrl = readPropertyString('pluginRepositoryUrl')
unreleasedTerm = "Unreleased"
//groups = ["Added", "Changed", "Deprecated", "Removed"]
groups = []
}
qodana {
cachePath = file(".qodana").canonicalPath
}
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
kover {
reports {
total {
xml {
onCheck = true
}
}
}
}
lombok {
version = "1.18.38"
disableConfig = false
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(readPropertyString("javaVersion"))
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.release.set(Integer.parseInt(readPropertyString("javaVersionTarget")))
}
tasks.wrapper {
gradleVersion = readPropertyString("gradleVersion")
}
configurations {
provided
mockitoAgent
}
sourceSets {
main {
java {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
resources {
}
}
test {
java {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
resources {
}
}
}
repositories {
mavenCentral()
// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
intellijPlatform {
defaultRepositories()
}
}
dependencies {
implementation ('com.github.cliftonlabs:json-simple:4.0.1') {
exclude group: 'junit'
}
implementation('com.offbytwo.jenkins:jenkins-client:0.3.8') {
exclude group: 'org.slf4j'
exclude group: 'org.apache.logging.log4j'
// provided by Idea Platform
//exclude group: 'commons-io' // not exists in all products (missing in PyCharm e.g)
exclude group: 'commons-lang'
exclude group: 'commons-collections'
exclude group: 'commons-logging'
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.fasterxml.jackson.core'
exclude group: 'jaxen'
}
implementation(group: 'xml-apis', name: 'xml-apis', version: '') {
version {
strictly "[1.4.01]"
}
}
testImplementation('org.assertj:assertj-swing-junit:3.17.1') {
exclude group: 'org.assertj', module: 'assertj-core'
exclude group: 'junit'
}
testImplementation(
platform('org.junit:junit-bom:6.0.1'),
'org.junit.jupiter:junit-jupiter-api',
'org.junit.jupiter:junit-jupiter-params',
'junit:junit:4.13.2',
'org.mockito:mockito-core:5.+',
'org.assertj:assertj-core:3.27.6'
)
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine',
'org.junit.vintage:junit-vintage-engine',
'org.junit.platform:junit-platform-launcher'
)
mockitoAgent('org.mockito:mockito-core:5.+') {
transitive = false
}
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
intellijPlatform {
create(
readPropertyString('platformType'),
readPropertyString("platformVersion")
)
//create(IntelliJPlatformType.IntellijIdea, readPropertyString("platformVersion"))
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
//bundledPlugins(readPropertyString("platformBundledPlugins").map { it.split(',') })
bundledPlugins(Arrays.asList(readPropertyString("platformBundledPlugins").split(',')))
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
//plugins(readPropertyString("platformPlugins").map { it.split(',') })
plugins(Arrays.asList(readPropertyString("platformPlugins").split(',')))
// Module Dependencies. Uses `platformBundledModules` property from the gradle.properties file for bundled IntelliJ Platform modules.
//bundledModules(readPropertyString("platformBundledModules").map { it.split(',') })
bundledModules(Arrays.asList(readPropertyString("platformBundledModules").split(',')))
//testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Platform.INSTANCE)
}
}
test {
useJUnitPlatform()
jvmArgs '-enableassertions', '-Djava.awt.headless=true'
testLogging {
exceptionFormat = 'full'
showStandardStreams = true
}
}
runIde {
jvmArgs = ['-XX:+UnlockDiagnosticVMOptions']
systemProperty('ide.plugins.snapshot.on.unload.fail', 'true')
systemProperty('ide.plugins.analyze.snapshot', 'true')
systemProperty('ide.plugins.allow.unload.from.sources', 'true')
}
def snapshotSpec = copySpec {
from 'build/distributions'
include "${readPropertyString('pluginName')}-${project.version}.zip"
}
tasks.register('copyPluginToSnapshots', Copy) {
into "snapshot"
with snapshotSpec
}
tasks {
test {
//jvmArgs += "-javaagent:${configurations.mockitoAgent.asPath}"
}
}
copyPluginToSnapshots.dependsOn buildPlugin
prepareSandbox {
from (['README.md', 'CHANGELOG.md', 'LICENSE.txt']) {
into "${readPropertyString('pluginName')}/"
}
}
sonar {
properties {
property "sonar.organization", "mcmics-github"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.projectKey", "MCMicS_jenkins-control-plugin"
}
}
jacocoTestReport {
dependsOn test
reports {
xml.required.set(true)
}
}
tasks.register('copySignedPluginToSnapshots', () -> {
copy {
from 'build/distributions'
include "${readPropertyString('pluginName')}-${project.version}-signed.zip"
into "snapshot"
}
})
copySignedPluginToSnapshots.dependsOn signPlugin
publishPlugin {
def isRelease = channel == 'default';
if (isRelease) {
dependsOn patchChangelog
}
}
def getChannel(String version) {
def semVerPreReleaseIndex = version.indexOf('-')
final preReleaseVersion = semVerPreReleaseIndex != -1 ? version.substring(semVerPreReleaseIndex + 1) : 'default';
final firstDotInPreRelease = preReleaseVersion.indexOf('.');
return firstDotInPreRelease == -1 ? preReleaseVersion : preReleaseVersion.substring(0, firstDotInPreRelease);
}