forked from MCMicS/jenkins-control-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
276 lines (255 loc) · 8.76 KB
/
build.gradle
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
//import org.jetbrains.changelog.ExtensionsKt
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.exceptions.MissingVersionException
import org.jetbrains.intellij.tasks.RunPluginVerifierTask
plugins {
id 'java'
id 'org.jetbrains.intellij' version '1.17.4'
id("org.jetbrains.kotlin.jvm") version "2.0.20"
id 'org.jetbrains.changelog' version '2.2.1'
id 'org.jetbrains.qodana' version '2024.2.2'
id "io.freefair.lombok" version "8.10"
id 'idea'
id "org.sonarqube" version '5.1.0.4882'
id 'jacoco'
}
def readPropertyString = (key) -> property(key).toString()
group readPropertyString('pluginGroup')
version "${readPropertyString('pluginVersion')}-${readPropertyString('pluginSincePlatformVersion')}"
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'org.jetbrains.changelog'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: "io.freefair.lombok"
intellij {
pluginName.set(readPropertyString('pluginName'))
version.set(readPropertyString('platformVersion'))
type.set(readPropertyString('platformType'))
configureDefaultDependencies.set(true)
plugins.set(Arrays.asList(readPropertyString("platformPlugins").split(',')))
}
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
}
lombok {
version = "1.18.22"
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")
}
tasks.patchPluginXml {
version.set(project.version)
sinceBuild.set(readPropertyString("pluginSinceBuild"))
untilBuild.set(readPropertyString("pluginUntilBuild"))
pluginDescription.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() } )
}
configurations {
provided
}
sourceSets {
main {
java {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
resources {
}
}
test {
java {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
resources {
}
}
}
repositories {
mavenCentral()
maven { url 'https://www.jetbrains.com/intellij-repository/snapshots' }
}
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:5.11.0'),
'org.junit.jupiter:junit-jupiter-api',
'org.junit.jupiter:junit-jupiter-params',
'junit:junit:4.13.2',
'org.mockito:mockito-core:5.13.0',
'org.assertj:assertj-core:3.26.3'
)
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine',
'org.junit.vintage:junit-vintage-engine',
'org.junit.platform:junit-platform-launcher'
)
}
test {
useJUnitPlatform()
jvmArgs '-enableassertions', '-Djava.awt.headless=true'
doFirst {
systemProperty("idea.plugins.path", project.rootDir.canonicalPath + "/.test-plugins")
}
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')
}
buildPlugin {
doLast {
copy {
from 'build/distributions'
include "${readPropertyString('pluginName')}-${project.version}.zip"
into "snapshot"
}
}
}
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)
}
}
def ideaVersionToVerify = readPropertyString('platformVersionToVerify')
def verifyFailureLevel = EnumSet.copyOf(RunPluginVerifierTask.FailureLevel.ALL)
verifyFailureLevel.remove(RunPluginVerifierTask.FailureLevel.NOT_DYNAMIC)
runPluginVerifier {
// filled by task listProductsReleases
//ideVersions = ["IU-${ideaVersionToVerify}"]
// ideVersions = ["IC-2020.3", "PS-2020.3", "IU-2020.3"]
failureLevel = verifyFailureLevel
verifierVersion = "latest"
}
signPlugin {
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"))
doLast {
copy {
from 'build/distributions'
include "${readPropertyString('pluginName')}-${project.version}-signed.zip"
into "snapshot"
}
}
}
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);
}
publishPlugin {
def channel = getChannel(readPropertyString('pluginVersion'))
def isRelease = channel == 'default';
if (isRelease) {
dependsOn patchChangelog
}
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])
}