forked from unshare/hybris-integration-intellij-idea-plugin
-
Notifications
You must be signed in to change notification settings - Fork 41
/
build.gradle.kts
369 lines (318 loc) · 12.3 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
/*
* This file is part of "SAP Commerce Developers Toolset" plugin for IntelliJ IDEA.
* Copyright (C) 2019-2024 EPAM Systems <hybrisideaplugin@epam.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
import org.jetbrains.intellij.platform.gradle.tasks.RunIdeTask
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
plugins {
id("java") // Java support
id("idea") // IDEA support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
alias(libs.plugins.changelog) // Gradle IntelliJ Plugin
alias(libs.plugins.openAPIGenerator) // openapi Generator
}
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.JETBRAINS
}
}
kotlin {
jvmToolchain {
languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.JETBRAINS
}
}
sourceSets {
main {
java.srcDirs("src", "gen", "ccv2")
resources.srcDirs("resources")
}
test {
java.srcDirs("tests")
}
}
idea {
module {
generatedSourceDirs.add(file("gen"))
generatedSourceDirs.add(file("ccv2"))
}
}
changelog {
version = properties("intellij.plugin.version")
groups = listOf()
headerParserRegex = """(\d+(.\d+)*)""".toRegex()
}
val projectJvmArguments = mutableListOf<String>().apply {
add(properties("intellij.jvm.args").get())
if (OperatingSystem.current().isMacOsX) {
add("-Xdock:name=${project.name}")
// converted via ImageMagick, https://gist.github.com/plroebuck/af19a26c908838c7f9e363c571199deb
add("-Xdock:icon=${project.rootDir}/macOS_dockIcon.icns")
}
}
// OpenAPI - Gradle plugin
// https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-gradle-plugin
// OpenAPI - Kotlin generator
// https://openapi-generator.tech/docs/generators/kotlin/
val ccv2OpenApiSpecs = listOf(
Triple("ccv1OpenApiGenerate", "commerce-cloud-management-api-v1.yaml", "com.intellij.idea.plugin.hybris.ccv1"),
Triple("ccv2OpenApiGenerate", "commerce-cloud-management-api-v2.yaml", "com.intellij.idea.plugin.hybris.ccv2"),
)
val ccv2OpenApiTasks = ccv2OpenApiSpecs.mapIndexed { index, (taskName, schema, packagePrefix) ->
tasks.register<GenerateTask>(taskName) {
group = "openapi tools"
generatorName.set("kotlin")
inputSpec.set("$rootDir/resources/specs/$schema")
outputDir.set("$rootDir/ccv2")
// Custom template required to enable request-specific headers for Authentication
// https://openapi-generator.tech/docs/templating
// https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp
templateDir.set("$rootDir/resources/openapi/templates")
apiPackage.set("$packagePrefix.api")
packageName.set("$packagePrefix.invoker")
modelPackage.set("$packagePrefix.model")
cleanupOutput.set(index == 0)
skipOperationExample.set(true)
generateApiDocumentation.set(false)
generateApiTests.set(false)
generateModelTests.set(false)
globalProperties.set(
mapOf(
"modelDocs" to "false",
)
)
configOptions.set(
mapOf(
"useSettingsGradle" to "false",
"omitGradlePluginVersions" to "true",
"omitGradleWrapper" to "true",
"useCoroutines" to "true",
"sourceFolder" to "",
)
)
if (index > 0) {
val previousTaskName = ccv2OpenApiSpecs[index - 1].first
dependsOn(previousTaskName)
} else {
dependsOn("copyChangelog")
}
}
}
intellijPlatform {
buildSearchableOptions = true
pluginConfiguration {
id = properties("intellij.plugin.id")
name = properties("intellij.plugin.name")
version = properties("intellij.plugin.version")
description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
}
}
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes = with(changelog) {
getAll().values
.take(3)
.joinToString("") {
renderItem(
it
.withLinks(true)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}
ideaVersion {
sinceBuild = properties("intellij.plugin.since.build")
untilBuild = properties("intellij.plugin.until.build")
}
vendor {
name = "EPAM_Systems"
email = "hybrisideaplugin@epam.com"
url = "https://github.com/epam/sap-commerce-intellij-idea-plugin"
}
}
verifyPlugin {
freeArgs = listOf("-mute", "TemplateWordInPluginId,TemplateWordInPluginName,ForbiddenPluginIdPrefix")
ides {
select {
types = listOf(IntelliJPlatformType.IntellijIdeaUltimate, IntelliJPlatformType.IntellijIdeaCommunity)
channels = listOf(ProductRelease.Channel.EAP, ProductRelease.Channel.RELEASE)
sinceBuild = properties("intellij.plugin.since.build")
untilBuild = properties("intellij.plugin.until.build")
}
}
}
}
tasks {
val copyChangelog by registering(Copy::class) {
from("CHANGELOG.md")
into("resources")
}
patchPluginXml {
dependsOn(copyChangelog)
}
wrapper {
gradleVersion = properties("gradle.version").get()
}
runIde {
jvmArgs = projectJvmArguments
maxHeapSize = properties("intellij.maxHeapSize").get()
applyRunIdeSystemSettings()
}
clean {
doFirst {
delete("out")
}
}
test {
useJUnitPlatform()
}
compileJava {
dependsOn(ccv2OpenApiTasks)
}
compileKotlin {
dependsOn(ccv2OpenApiTasks)
}
printProductsReleases {
channels = listOf(ProductRelease.Channel.EAP)
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity)
untilBuild = provider { null }
doLast {
productsReleases.get().max()
}
}
}
intellijPlatformTesting {
runIde {
val runIdeCommunity by registering {
type = IntelliJPlatformType.IntellijIdeaCommunity
version = properties("intellij.version")
task {
jvmArgs = projectJvmArguments
maxHeapSize = properties("intellij.maxHeapSize").get()
applyRunIdeSystemSettings()
}
}
}
}
// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
implementation(libs.bundles.openapi)
implementation(libs.bundles.commons)
implementation(libs.bundles.jaxb)
implementation(libs.jsr305)
implementation(libs.jsoup)
implementation(libs.dtdparser)
implementation(libs.maven.model)
implementation(libs.solr.solrj) {
exclude("org.slf4j", "slf4j-api")
exclude("org.apache.httpcomponents", "httpclient")
exclude("org.apache.httpcomponents", "httpcore")
exclude("org.apache.httpcomponents", "httpmime")
}
testImplementation(kotlin("test"))
intellijPlatform {
intellijIdeaUltimate(properties("intellij.version"), useInstaller = false)
instrumentationTools()
pluginVerifier()
// printBundledPlugins for bundled plugins
bundledPlugins(
"com.intellij.java",
"com.intellij.java-i18n",
"org.intellij.intelliLang",
"com.intellij.copyright",
"com.intellij.database",
"com.intellij.diagram",
"com.intellij.spring",
"com.intellij.properties",
"org.intellij.groovy",
"com.intellij.gradle",
"com.intellij.javaee",
"com.intellij.javaee.el",
"com.intellij.javaee.web",
"com.intellij.platform.images",
"org.jetbrains.idea.maven",
"org.jetbrains.idea.maven.model",
"org.jetbrains.idea.maven.server.api",
"org.jetbrains.idea.eclipse",
"org.jetbrains.kotlin",
"JavaScript",
"JUnit",
)
// https://plugins.jetbrains.com/intellij-platform-explorer/extensions
// Ant:
// https://plugins.jetbrains.com/plugin/23025-ant
plugin("AntSupport:242.20224.159")
// PsiViewer:
// https://plugins.jetbrains.com/plugin/227-psiviewer
plugin("PsiViewer:242.4697")
// JRebel and XRebel:
// https://plugins.jetbrains.com/plugin/4441-jrebel-and-xrebel
plugin("JRebelPlugin:2024.3.1")
// Big Data Tools:
// incredibly sad, but as for now API cannot be used by 3rd-party plugins
// https://plugins.jetbrains.com/bundles/8-big-data-tools
// plugins(
// // https://plugins.jetbrains.com/plugin/12494-big-data-tools
// "com.intellij.bigdatatools:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21713-big-data-tools-core
// "com.intellij.bigdatatools.core:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21701-big-data-file-viewer
// "com.intellij.bigdatatools.binary.files:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21712-metastore-core
// "com.intellij.bigdatatools.metastore.core:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21700-spark/versions
// "com.intellij.bigdatatools.spark:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21673-zeppelin
// "com.intellij.bigdatatools.zeppelin:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21702-flink
// "com.intellij.bigdatatools.flink:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21704-kafka
// "com.intellij.bigdatatools.kafka:241.14494.158",
// // https://plugins.jetbrains.com/plugin/21706-remote-file-systems
// "com.intellij.bigdatatools.rfs:241.15989.150",
// )
}
}
fun RunIdeTask.applyRunIdeSystemSettings() {
systemProperty("ide.experimental.ui", "true")
systemProperty("ide.show.tips.on.startup.default.value", false)
systemProperty("idea.trust.all.projects", true)
systemProperty("jb.consents.confirmation.enabled", false)
}