forked from magento/magento2-phpstorm-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
248 lines (206 loc) · 6.63 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
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
import groovy.json.JsonSlurper
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
plugins {
id("java")
id("checkstyle")
id("pmd")
alias(libs.plugins.kotlin)
alias(libs.plugins.intelliJPlatform)
alias(libs.plugins.changelog)
alias(libs.plugins.qodana)
alias(libs.plugins.kover)
}
group = providers.gradleProperty("pluginGroup").get()
version = providers.gradleProperty("pluginVersion").get()
kotlin {
jvmToolchain(17)
}
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
testImplementation("org.junit.vintage:junit-vintage-engine:5.10.0")
implementation("com.googlecode.json-simple:json-simple:1.1.1")
implementation("org.codehaus.plexus:plexus-utils:3.4.0")
intellijPlatform {
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
plugin("com.intellij.lang.jsgraphql", "243.21565.122")
instrumentationTools()
pluginVerifier()
zipSigner()
testFramework(TestFrameworkType.Platform)
phpstorm("2024.3")
bundledPlugin("com.jetbrains.php")
bundledPlugin("com.intellij.copyright")
}
}
intellijPlatform {
pluginConfiguration {
version = providers.gradleProperty("pluginVersion")
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
changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}
ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
untilBuild = providers.gradleProperty("pluginUntilBuild")
}
}
signing {
certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
privateKey = providers.environmentVariable("PRIVATE_KEY")
password = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
}
publishing {
token = providers.environmentVariable("MAGENTO_PHPSTORM_intellijPublishToken")
channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
}
pluginVerification {
ides {
recommended()
}
}
}
changelog {
groups.empty()
repositoryUrl = providers.gradleProperty("pluginRepositoryUrl")
}
kover {
reports {
total {
xml {
onCheck = true
}
}
}
}
tasks {
wrapper {
gradleVersion = providers.gradleProperty("gradleVersion").get()
}
publishPlugin {
dependsOn(patchChangelog)
}
test {
useJUnitPlatform()
}
checkstyle {
toolVersion = "8.31"
isIgnoreFailures = false
maxWarnings = 0
configFile = rootProject.file("${rootDir}/gradle-tasks/checkstyle/checkstyle.xml")
}
pmd {
toolVersion = "6.21.0"
isConsoleOutput = true
ruleSetFiles = files("${rootDir}/gradle-tasks/pmd/ruleset.xml")
ruleSets = listOf()
}
}
intellijPlatformTesting {
runIde {
register("runIdeForUiTests") {
task {
jvmArgumentProviders += CommandLineArgumentProvider {
listOf(
"-Drobot-server.port=8082",
"-Dide.mac.message.dialogs.as.sheets=false",
"-Djb.privacy.policy.text=<!--999.999-->",
"-Djb.consents.confirmation.enabled=false",
)
}
}
plugins {
robotServerPlugin()
}
}
}
}
// Configure Checkstyle tasks
tasks.withType(Checkstyle::class).configureEach {
// Specify all files that should be checked
classpath = files()
setSource("${project.rootDir}")
}
// Execute Checkstyle on all files
tasks.register<Checkstyle>("checkstyle") {
// Task-specific configuration can go here if necessary
}
// Execute Checkstyle on all modified files
tasks.register<Checkstyle>("checkstyleCI") {
val changedFiles = getChangedFiles()
include(changedFiles)
}
// Configure PMD tasks
tasks.withType(Pmd::class).configureEach {
// Specify all files that should be checked
classpath = files()
setSource("${project.rootDir}")
}
// Execute PMD on all files
tasks.register<Pmd>("pmd") {
// Task-specific configuration can go here if necessary
}
// Execute PMD on all modified files
tasks.register<Pmd>("pmdCI") {
val changedFiles = getChangedFiles()
include(changedFiles)
}
/**
* Get all files that are changed but not deleted nor renamed.
* Compares to master or the specified target branch.
*
* @return list of all changed files
*/
fun getChangedFiles(): List<String> {
val modifiedFilesJson = System.getenv("MODIFIED_FILES")
val files = mutableListOf<String>()
if (modifiedFilesJson == null) {
return files
}
println("Modified Files: $modifiedFilesJson")
// Parse the JSON string into a list of files
val modifiedFiles = JsonSlurper().parseText(modifiedFilesJson) as List<*>
modifiedFiles.forEach {
files.add(it.toString())
}
// Return the list of touched files
return files
}
kover {
currentProject {
instrumentation {
excludedClasses.add("org.apache.velocity.*")
}
}
}