Skip to content

Commit

Permalink
Update to support 2024.2
Browse files Browse the repository at this point in the history
- Replaced build.gradle.kts to new template from https://github.com/JetBrains/intellij-platform-plugin-template/blob/main/build.gradle.kts due to migration of org.jetbrains.intellij to org.jetbrains.intellij.platform
- updated gradle to 8.10
- updated jvm to 21
  • Loading branch information
Digity101 authored and Pushpavel committed Sep 12, 2024
1 parent 9654e3a commit 09ef0eb
Show file tree
Hide file tree
Showing 10 changed files with 343 additions and 215 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.gradle
.idea
.qodana
.intellijPlatform
build
out
src/main/resources/messages/secrets.properties
Expand Down
226 changes: 135 additions & 91 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,52 +1,40 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel

fun properties(key: String) = project.findProperty(key).toString()

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
val pluginDescriptionFromMd = File(projectDir, "README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

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").run { markdownToHTML(this) }

import org.jetbrains.intellij.platform.gradle.TestFrameworkType

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.9.0"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.13.3"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"

kotlin("plugin.serialization") version "1.7.20"
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
alias(libs.plugins.serialization) // Kotlin compiler plugin for kotlinx.serialization library
}

group = properties("pluginGroup")
version = properties("pluginVersion")
description = pluginDescriptionFromMd
group = providers.gradleProperty("pluginGroup").get()
version = providers.gradleProperty("pluginVersion").get()

// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(21)
}

// Configure project's dependencies
repositories {
mavenCentral()
}

// Set the JVM language level used to compile sources and generate files - Java 11 is required since 2020.3
kotlin {
jvmToolchain(17)
// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
intellijPlatform {
defaultRepositories()
}
}

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
val ktor_version = "2.1.2"

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.8.0")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation("io.ktor:ktor-client-core:$ktor_version")
Expand All @@ -55,82 +43,138 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
testImplementation("io.mockk:mockk:1.13.2")
}

buildscript {
repositories {
google()
mavenCentral()
}
}
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
intellijPlatform {
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))

// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
instrumentCode.set(false)
}
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })

// Configure gradle-changelog-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set(properties("pluginVersion"))
header.set(provider { version.get() })
groups.set(emptyList())
headerParserRegex.set(Regex("""v[0-9]+\.[0-9]+\.[0-9]+(-eap\.[1-9]+)?"""))
instrumentationTools()
pluginVerifier()
zipSigner()
testFramework(TestFrameworkType.Platform)
}
}

tasks {
// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
intellijPlatform {
buildSearchableOptions.set(false)

pluginConfiguration {
version = providers.gradleProperty("pluginVersion")

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
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
// https://github.com/JetBrains/gradle-changelog-plugin/blob/bad5117d3be0b1e77dd0f4fc8d043bde80f2efac/src/main/kotlin/org/jetbrains/changelog/ChangelogPluginConstants.kt#L40
val SEM_VER_REGEX_V_PREFIX =
"""^v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)${'$'}""".toRegex() // ktlint-disable max-line-length
changelog.headerParserRegex.set(SEM_VER_REGEX_V_PREFIX)

// Get the latest available change notes from the changelog file
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")
}
}

buildSearchableOptions {
enabled = false
signing {
certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
privateKey = providers.environmentVariable("PRIVATE_KEY")
password = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
}

test {
useJUnitPlatform()
publishing {
token = providers.environmentVariable("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 = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
}

wrapper {
gradleVersion = properties("gradleVersion")
pluginVerification {
ides {
recommended()
}
}
}

patchPluginXml {
pluginId.set(properties("pluginGroup"))
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
pluginDescription.set(pluginDescriptionFromMd)
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl = providers.gradleProperty("pluginRepositoryUrl")
}

// Get the latest available change notes from CHANGELOG.md
changeNotes.set(provider { changelog.getLatest().toHTML() })
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
kover {
reports {
total {
xml {
onCheck = true
}
}
}
}

runPluginVerifier {
val failLevel = FailureLevel.ALL.clone()
failLevel.remove(FailureLevel.EXPERIMENTAL_API_USAGES)
failLevel.remove(FailureLevel.DEPRECATED_API_USAGES)
failureLevel.set(failLevel)
tasks {
wrapper {
gradleVersion = providers.gradleProperty("gradleVersion").get()
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
publishPlugin {
dependsOn(patchChangelog)
}

publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
// 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
if (properties("pluginVersion").contains('-'))
channels.set(listOf("eap"))
else
channels.set(listOf("default", "eap"))
test {
useJUnitPlatform()
}

}

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()
}
}
}
}
14 changes: 8 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ pluginRepositoryUrl = https://github.com/Pushpavel/AutoCp
pluginVersion=v0.7.20
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild=241
pluginSinceBuild=242

platformType=CL
# Using not EAP now because EAP requires breaking change(Java 21 requirement from 2024.2 EAP)
platformVersion=2024.1.1
# LATEST-EAP-SNAPSHOT
platformVersion=2024.2

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins=
gradleVersion=8.1.1
# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins =

gradleVersion=8.10
# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency=true
kotlin.stdlib.default.dependency=false
17 changes: 17 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[versions]

# plugins
changelog = "2.2.1"
intelliJPlatform = "2.0.1"
kotlin = "2.0.20"
kover = "0.8.3"
qodana = "2024.1.9"
serialization = "2.0.20"

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialization" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 09ef0eb

Please sign in to comment.