3
3
* See COPYING.txt for license details.
4
4
*/
5
5
6
+ import groovy.json.JsonSlurper
6
7
import org.jetbrains.changelog.Changelog
7
8
import org.jetbrains.changelog.markdownToHTML
8
9
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
9
10
10
11
plugins {
11
12
id(" java" )
13
+ id(" checkstyle" )
14
+ id(" pmd" )
12
15
alias(libs.plugins.kotlin)
13
16
alias(libs.plugins.intelliJPlatform)
14
17
alias(libs.plugins.changelog)
@@ -109,10 +112,6 @@ intellijPlatform {
109
112
}
110
113
}
111
114
112
- apply {
113
- from(" ${project.rootDir} /gradle-tasks/staticChecks.gradle" )
114
- }
115
-
116
115
changelog {
117
116
groups.empty()
118
117
repositoryUrl = providers.gradleProperty(" pluginRepositoryUrl" )
@@ -141,6 +140,20 @@ tasks {
141
140
exclude(" com/magento/idea/magento2plugin/actions/**" ) // https://github.com/magento/magento2-phpstorm-plugin/issues/2474
142
141
useJUnitPlatform()
143
142
}
143
+
144
+ checkstyle {
145
+ toolVersion = " 8.31"
146
+ isIgnoreFailures = false
147
+ maxWarnings = 0
148
+ configFile = rootProject.file(" ${rootDir} /gradle-tasks/checkstyle/checkstyle.xml" )
149
+ }
150
+
151
+ pmd {
152
+ toolVersion = " 6.21.0"
153
+ isConsoleOutput = true
154
+ ruleSetFiles = files(" ${rootDir} /gradle-tasks/pmd/ruleset.xml" )
155
+ ruleSets = listOf ()
156
+ }
144
157
}
145
158
146
159
intellijPlatformTesting {
@@ -163,3 +176,66 @@ intellijPlatformTesting {
163
176
}
164
177
}
165
178
}
179
+
180
+ // Configure Checkstyle tasks
181
+ tasks.withType(Checkstyle ::class ).configureEach {
182
+ // Specify all files that should be checked
183
+ classpath = files()
184
+ setSource(" ${project.rootDir} " )
185
+ }
186
+
187
+ // Execute Checkstyle on all files
188
+ tasks.register<Checkstyle >(" checkstyle" ) {
189
+ // Task-specific configuration can go here if necessary
190
+ }
191
+
192
+ // Execute Checkstyle on all modified files
193
+ tasks.register<Checkstyle >(" checkstyleCI" ) {
194
+ val changedFiles = getChangedFiles()
195
+ include(changedFiles)
196
+ }
197
+
198
+ // Configure PMD tasks
199
+ tasks.withType(Pmd ::class ).configureEach {
200
+ // Specify all files that should be checked
201
+ classpath = files()
202
+ setSource(" ${project.rootDir} " )
203
+ }
204
+
205
+ // Execute PMD on all files
206
+ tasks.register<Pmd >(" pmd" ) {
207
+ // Task-specific configuration can go here if necessary
208
+ }
209
+
210
+ // Execute PMD on all modified files
211
+ tasks.register<Pmd >(" pmdCI" ) {
212
+ val changedFiles = getChangedFiles()
213
+ include(changedFiles)
214
+ }
215
+
216
+ /* *
217
+ * Get all files that are changed but not deleted nor renamed.
218
+ * Compares to master or the specified target branch.
219
+ *
220
+ * @return list of all changed files
221
+ */
222
+ fun getChangedFiles (): List <String > {
223
+ val modifiedFilesJson = System .getenv(" MODIFIED_FILES" )
224
+ val files = mutableListOf<String >()
225
+
226
+ if (modifiedFilesJson == null ) {
227
+ return files
228
+ }
229
+
230
+ println (" Modified Files: $modifiedFilesJson " )
231
+
232
+ // Parse the JSON string into a list of files
233
+ val modifiedFiles = JsonSlurper ().parseText(modifiedFilesJson) as List <* >
234
+
235
+ modifiedFiles.forEach {
236
+ files.add(it.toString())
237
+ }
238
+
239
+ // Return the list of touched files
240
+ return files
241
+ }
0 commit comments