Skip to content

Commit

Permalink
Migrate to new IntelliJ platform plugin ``'org.jetbrains.intellij.pla…
Browse files Browse the repository at this point in the history
…tform``

* Requires Java 21
  * Use PMD 7
* This also requires removal of the IDE compatibility check xdev-software/intellij-plugin-template#48
  • Loading branch information
AB-xdev committed Sep 19, 2024
1 parent 946c37d commit ff5992f
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 105 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

strategy:
matrix:
java: [17, 21]
java: [21]
distribution: [temurin]

steps:
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:

strategy:
matrix:
java: [17]
java: [21]
distribution: [temurin]

steps:
Expand All @@ -101,7 +101,7 @@ jobs:

strategy:
matrix:
java: [17]
java: [21]
distribution: [temurin]

steps:
Expand Down
54 changes: 0 additions & 54 deletions .github/workflows/checkIDECompatibility.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'

Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'

- name: Init Git and pull
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21

- name: Cache SonarCloud packages
uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
cache: 'gradle'

- name: Update/Generify version
Expand Down
5 changes: 3 additions & 2 deletions .run/Run Tests.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="scriptParameters" value="-PskipPMD" />
<option name="taskDescriptions">
<list />
</option>
Expand All @@ -19,6 +19,7 @@
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
</component>
2 changes: 1 addition & 1 deletion .run/Run Verifications.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</option>
<option name="taskNames">
<list>
<option value="runPluginVerifier" />
<option value="verifyPlugin" />
</list>
</option>
<option name="vmOptions" value="" />
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ We also encourage you to read the [contribution instructions by GitHub](https://
### Software Requirements
You should have the following things installed:
* Git
* Java 17 - should be as unmodified as possible (Recommended: [Eclipse Adoptium](https://adoptium.net/temurin/releases/))
* Java 21 - should be as unmodified as possible (Recommended: [Eclipse Adoptium](https://adoptium.net/temurin/releases/))
* Gradle (shipped inside the repo as Gradle Wrapper - also available inside IntelliJ)

### Recommended setup
Expand Down
102 changes: 64 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ plugins {
id 'idea'
id 'checkstyle'
id 'pmd'
id 'org.jetbrains.intellij' version '1.17.4'
id 'org.jetbrains.intellij.platform' version '2.0.1'
id 'org.sonarqube' version '5.1.0.4882'
}

ext {
checkstyleVersion = '10.18.1'
pmdVersion = '7.5.0'
}

def properties(String key) {
Expand All @@ -19,7 +20,7 @@ def environment(String key) {
return providers.environmentVariable(key)
}

apply plugin: 'org.jetbrains.intellij'
apply plugin: 'org.jetbrains.intellij.platform'
apply plugin: 'java'
apply plugin: 'checkstyle'

Expand All @@ -30,6 +31,10 @@ version = properties("pluginVersion").get()
// Add build script repository to maven central
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}

// https://github.com/gradle/gradle/issues/27035
Expand All @@ -41,7 +46,17 @@ configurations.checkstyle {

// Add dependencies to test, junit5 api (annotations) and engine (runtime)
dependencies {
intellijPlatform {
create(properties("platformType"), properties("platformVersion"))
bundledPlugins(properties("platformBundledPlugins").map { it.split(",").collect { it.trim() }.findAll { !it.empty } })
plugins(properties("platformPlugins").map { it.split(",").collect { it.trim() }.findAll { !it.empty } })
pluginVerifier()
zipSigner()
instrumentationTools()
}
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
pmd "net.sourceforge.pmd:pmd-ant:${pmdVersion}",
"net.sourceforge.pmd:pmd-java:${pmdVersion}"
testImplementation platform('org.junit:junit-bom:5.11.0'),
'org.junit.jupiter:junit-jupiter',
'org.junit.jupiter:junit-jupiter-engine',
Expand All @@ -55,21 +70,36 @@ dependencies {
// This needs to fit the tag <idea-version since-build="xxx"> in plugin.xml
// See https://www.jetbrains.com/intellij-repository/snapshots
// See https://www.jetbrains.com/intellij-repository/releases
intellij {
pluginName = properties("pluginName")

version = properties("platformVersion")
type = properties("platformType")

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins = properties("platformPlugins").map { it.split(",").collect { it.trim() }.findAll { !it.empty } }

updateSinceUntilBuild = false
}


listProductsReleases {
sinceBuild = "242.*"
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("pluginVersion")
}
patchPluginXml {
pluginId = properties("pluginGroup")
pluginName = properties("pluginName")
pluginVersion = properties("pluginVersion")
sinceBuild = properties("platformSinceBuild")
untilBuild = provider { null }
}
pluginVerification {
ides {
recommended()
}
}
signPlugin {
certificateChain = environment("CERTIFICATE_CHAIN")
privateKey = environment("PRIVATE_KEY")
password = environment("PRIVATE_KEY_PASSWORD")
}
publishPlugin {
token = environment("PUBLISH_TOKEN")
// The 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 = properties("pluginVersion")
.map { [((it.split('-') as List)[1] ?: "default").split('\\.').find { true }.toLowerCase()] }
}
}

checkstyle {
Expand All @@ -82,18 +112,23 @@ checkstyle {
pmd {
consoleOutput = true
ruleSetFiles = files(".config/pmd/ruleset.xml")
toolVersion = pmdVersion
}

tasks.withType(Checkstyle).configureEach {
enabled = project.hasProperty("checkstyleEnabled");
}

tasks.withType(Pmd).configureEach {
enabled = !project.hasProperty("skipPMD")
}

// Configure compileJava AND compileTestJava
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html
tasks.withType(JavaCompile).configureEach {
// JAVA compatibility
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

compileJava.options.encoding = 'UTF-8'
Expand All @@ -105,6 +140,16 @@ test {
useJUnitPlatform()
}

sonar {
properties {
// Ignore sonar warnings globally
property 'sonar.issue.ignore.multicriteria', 'S1948'
// Ignore serialization waring as it's only relevant for RMI which is not used
property 'sonar.issue.ignore.multicriteria.S1948.ruleKey', 'java:S1948'
property 'sonar.issue.ignore.multicriteria.S1948.resourceKey', '**/*.java'
}
}

// Add resources directory because intellij test framework checks there for test resources (instead of build/resources)
sourceSets {
test.output.resourcesDir = "build/classes/java/resources"
Expand All @@ -114,23 +159,4 @@ tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
}

patchPluginXml {
version = properties("pluginVersion")
}

signPlugin {
certificateChain = environment("CERTIFICATE_CHAIN")
privateKey = environment("PRIVATE_KEY")
password = environment("PRIVATE_KEY_PASSWORD")
}

publishPlugin {
token = environment("PUBLISH_TOKEN")
// The 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 = properties("pluginVersion")
.map { [((it.split('-') as List)[1] ?: "default").split('\\.').find { true }.toLowerCase()] }
}
}
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ pluginName=
pluginVersion=
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType=IC
platformVersion=2024.2.1
platformVersion=2024.2.2
platformSinceBuild=242
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
# Example: platformBundledPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformBundledPlugins=
platformPlugins=
# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=8.10.1
Expand Down

0 comments on commit ff5992f

Please sign in to comment.