@@ -3,12 +3,13 @@ plugins {
33    id ' idea' 
44    id ' checkstyle' 
55    id ' pmd' 
6-     id ' org.jetbrains.intellij'   version ' 1.17.4 ' 
6+     id ' org.jetbrains.intellij.platform '   version ' 2.0.1 ' 
77    id ' org.sonarqube'   version ' 5.1.0.4882' 
88}
99
1010ext  {
1111    checkstyleVersion =  ' 10.18.1' 
12+     pmdVersion =  ' 7.5.0' 
1213}
1314
1415def  properties (String  key ) {
@@ -19,7 +20,7 @@ def environment(String key) {
1920    return  providers. environmentVariable(key)
2021}
2122
22- apply plugin : ' org.jetbrains.intellij' 
23+ apply plugin : ' org.jetbrains.intellij.platform ' 
2324apply plugin : ' java' 
2425apply plugin : ' checkstyle' 
2526
@@ -30,6 +31,10 @@ version = properties("pluginVersion").get()
3031//  Add build script repository to maven central
3132repositories  {
3233    mavenCentral()
34+     intellijPlatform {
35+         defaultRepositories()
36+         jetbrainsRuntime()
37+     }
3338}
3439
3540//  https://github.com/gradle/gradle/issues/27035
@@ -41,7 +46,17 @@ configurations.checkstyle {
4146
4247//  Add dependencies to test, junit5 api (annotations) and engine (runtime)
4348dependencies  {
49+     intellijPlatform {
50+         create(properties(" platformType"  ), properties(" platformVersion"  ))
51+         bundledPlugins(properties(" platformBundledPlugins"  ). map { it. split(" ,"  ). collect { it. trim() }. findAll { ! it. empty } })
52+         plugins(properties(" platformPlugins"  ). map { it. split(" ,"  ). collect { it. trim() }. findAll { ! it. empty } })
53+         pluginVerifier()
54+         zipSigner()
55+         instrumentationTools()
56+     }
4457    checkstyle " com.puppycrawl.tools:checkstyle:${ checkstyleVersion} " 
58+     pmd " net.sourceforge.pmd:pmd-ant:${ pmdVersion} "  ,
59+             " net.sourceforge.pmd:pmd-java:${ pmdVersion} " 
4560    testImplementation platform(' org.junit:junit-bom:5.11.0'  ),
4661            ' org.junit.jupiter:junit-jupiter'  ,
4762            ' org.junit.jupiter:junit-jupiter-engine'  ,
@@ -55,21 +70,36 @@ dependencies {
5570//  This needs to fit the tag <idea-version since-build="xxx"> in plugin.xml
5671//  See https://www.jetbrains.com/intellij-repository/snapshots
5772//  See https://www.jetbrains.com/intellij-repository/releases
58- intellij  {
59-     pluginName =  properties(" pluginName"  )
60- 
61-     version =  properties(" platformVersion"  )
62-     type =  properties(" platformType"  )
63- 
64-     //  Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
65-     plugins =  properties(" platformPlugins"  ). map { it. split(" ,"  ). collect { it. trim() }. findAll { ! it. empty } }
66- 
67-     updateSinceUntilBuild =  false 
68- }
69- 
70- 
71- listProductsReleases  {
72-     sinceBuild =  " 241.*" 
73+ intellijPlatform  {
74+     pluginConfiguration {
75+         name =  properties(" pluginName"  )
76+         version =  properties(" pluginVersion"  )
77+     }
78+     patchPluginXml {
79+         pluginId =  properties(" pluginGroup"  )
80+         pluginName =  properties(" pluginName"  )
81+         pluginVersion =  properties(" pluginVersion"  )
82+         sinceBuild =  properties(" platformSinceBuild"  )
83+         untilBuild =  provider { null  }
84+     }
85+     pluginVerification {
86+         ides {
87+             recommended()
88+         }
89+     }
90+     signPlugin {
91+         certificateChain =  environment(" CERTIFICATE_CHAIN"  )
92+         privateKey =  environment(" PRIVATE_KEY"  )
93+         password =  environment(" PRIVATE_KEY_PASSWORD"  )
94+     }
95+     publishPlugin {
96+         token =  environment(" PUBLISH_TOKEN"  )
97+         //  The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
98+         //  Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
99+         //  https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
100+         channels =  properties(" pluginVersion"  )
101+                 .map { [((it. split(' -'  ) as  List )[1 ] ?:  " default"  ). split(' \\ .'  ). find { true  }. toLowerCase()] }
102+     }
73103}
74104
75105checkstyle  {
@@ -82,18 +112,23 @@ checkstyle {
82112pmd  {
83113    consoleOutput =  true 
84114    ruleSetFiles =  files(" .config/pmd/ruleset.xml"  )
115+     toolVersion =  pmdVersion
85116}
86117
87118tasks. withType(Checkstyle ). configureEach  {
88119    enabled =  project. hasProperty(" checkstyleEnabled"  );
89120}
90121
122+ tasks. withType(Pmd ). configureEach  {
123+     enabled =  ! project. hasProperty(" skipPMD"  )
124+ }
125+ 
91126//  Configure compileJava AND compileTestJava
92127//  https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html
93128tasks. withType(JavaCompile ). configureEach  {
94129    //  JAVA compatibility
95-     sourceCompatibility =  JavaVersion . VERSION_17 
96-     targetCompatibility =  JavaVersion . VERSION_17 
130+     sourceCompatibility =  JavaVersion . VERSION_21 
131+     targetCompatibility =  JavaVersion . VERSION_21 
97132}
98133
99134compileJava. options. encoding =  ' UTF-8' 
@@ -105,6 +140,16 @@ test {
105140    useJUnitPlatform()
106141}
107142
143+ sonar  {
144+     properties {
145+         //  Ignore sonar warnings globally
146+         property ' sonar.issue.ignore.multicriteria'  , ' S1948' 
147+         //  Ignore serialization waring as it's only relevant for RMI which is not used
148+         property ' sonar.issue.ignore.multicriteria.S1948.ruleKey'  , ' java:S1948' 
149+         property ' sonar.issue.ignore.multicriteria.S1948.resourceKey'  , ' **/*.java' 
150+     }
151+ }
152+ 
108153//  Add resources directory because intellij test framework checks there for test resources (instead of build/resources)
109154sourceSets  {
110155    test. output. resourcesDir =  " build/classes/java/resources" 
@@ -114,23 +159,4 @@ tasks {
114159    wrapper {
115160        gradleVersion =  properties(" gradleVersion"  ). get()
116161    }
117- 
118-     patchPluginXml {
119-         version =  properties(" pluginVersion"  )
120-     }
121- 
122-     signPlugin {
123-         certificateChain =  environment(" CERTIFICATE_CHAIN"  )
124-         privateKey =  environment(" PRIVATE_KEY"  )
125-         password =  environment(" PRIVATE_KEY_PASSWORD"  )
126-     }
127- 
128-     publishPlugin {
129-         token =  environment(" PUBLISH_TOKEN"  )
130-         //  The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
131-         //  Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
132-         //  https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
133-         channels =  properties(" pluginVersion"  )
134-                 .map { [((it. split(' -'  ) as  List )[1 ] ?:  " default"  ). split(' \\ .'  ). find { true  }. toLowerCase()] }
135-     }
136162}
0 commit comments